dev.equo.ide.maven.AbstractP2Mojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of equo-ide-maven-plugin Show documentation
Show all versions of equo-ide-maven-plugin Show documentation
Generate a custom IDE as a repeatable build artifact
/*******************************************************************************
* Copyright (c) 2023 EquoTech, Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* EquoTech, Inc. - initial API and implementation
*******************************************************************************/
package dev.equo.ide.maven;
import dev.equo.ide.IdeHook;
import dev.equo.ide.WorkspaceInit;
import dev.equo.solstice.p2.P2Model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
/** Performs arbitrary p2 resolutions. */
public abstract class AbstractP2Mojo extends AbstractMojo {
public static class Filter {
@Parameter private List excludes = Collections.emptyList();
@Parameter private List excludePrefixes = Collections.emptyList();
@Parameter private List excludeSuffixes = Collections.emptyList();
@Parameter private boolean platformNone = false;
private P2Model.Filter toFilter() {
var filter = new P2Model.Filter();
if (platformNone) {
filter.platformNone();
}
excludes.forEach(filter::exclude);
excludePrefixes.forEach(filter::excludePrefix);
excludeSuffixes.forEach(filter::excludeSuffix);
return filter;
}
}
@Parameter private List filters = new ArrayList<>();
@Parameter private List p2repos = new ArrayList<>();
@Parameter private List installs = new ArrayList<>();
protected void modifyModel(P2Model model, IdeHook.List ideHooks, WorkspaceInit workspaceInit) {}
protected P2Model prepareModel(IdeHook.List ideHooks, WorkspaceInit workspaceInit)
throws MojoFailureException {
var model = new P2Model();
modifyModel(model, ideHooks, workspaceInit);
p2repos.forEach(model::addP2Repo);
installs.forEach(model.getInstall()::add);
for (Filter filterModel : filters) {
var filter = filterModel.toFilter();
model.addFilterAndValidate(
"maven-filter-unnamed-" + Integer.toString(filter.hashCode()), filter);
}
if (model.isEmpty()) {
throw new MojoFailureException(
"EquoIDE has nothing to install!\n\n"
+ "We recommend starting with this:\n"
+ "\n"
+ " \n"
+ " \n");
}
model.applyNativeFilterIfNoPlatformFilter();
return model;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy