use of org.apache.maven.model.Plugin in project sts4 by spring-projects.
the class MavenBridge method resolvePluginVersion.
public String resolvePluginVersion(String groupId, String artifactId, MavenSession session) throws MavenException {
Plugin plugin = new Plugin();
plugin.setGroupId(groupId);
plugin.setArtifactId(artifactId);
PluginVersionRequest request = new DefaultPluginVersionRequest(plugin, session);
try {
return lookup(PluginVersionResolver.class).resolve(request).getVersion();
} catch (PluginVersionResolutionException ex) {
throw new MavenException(ex);
}
}
use of org.apache.maven.model.Plugin in project gradle by gradle.
the class Maven2Gradle method globalExclusions.
private void globalExclusions(MavenProject project, BuildScriptBuilder builder) {
Plugin enforcerPlugin = plugin("maven-enforcer-plugin", project);
PluginExecution enforceGoal = pluginGoal("enforce", enforcerPlugin);
if (enforceGoal != null) {
Xpp3Dom configuration = (Xpp3Dom) enforceGoal.getConfiguration();
Xpp3Dom bannedDependencies = configuration.getChild("rules").getChild("bannedDependencies");
if (bannedDependencies != null) {
Xpp3Dom[] children = bannedDependencies.getChild("excludes").getChildren();
ScriptBlockBuilder block = builder.block(null, "configurations.all");
if (children != null) {
for (Xpp3Dom exclude : children) {
String[] tokens = exclude.getValue().split(":");
Map<String, String> params = new LinkedHashMap<>();
params.put("group", tokens[0]);
if (tokens.length > 1 && !tokens[1].equals("*")) {
params.put("module", tokens[1]);
}
block.methodInvocation(null, "exclude", params);
}
}
}
}
}
use of org.apache.maven.model.Plugin in project gradle by gradle.
the class Maven2Gradle method packageTests.
boolean packageTests(MavenProject project, BuildScriptBuilder builder) {
Plugin jarPlugin = plugin("maven-jar-plugin", project);
if (pluginGoal("test-jar", jarPlugin) != null) {
builder.taskRegistration(null, "testsJar", "Jar", task -> {
task.propertyAssignment(null, "archiveClassifier", "tests", false);
task.methodInvocation(null, "from", builder.propertyExpression(builder.containerElementExpression("sourceSets", "test"), "output"));
});
return true;
}
return false;
}
use of org.apache.maven.model.Plugin in project gradle by gradle.
the class Maven2Gradle method compilerSettings.
private void compilerSettings(MavenProject project, BuildScriptBuilder builder) {
String source = "1.8";
String target = "1.8";
Plugin compilerPlugin = plugin("maven-compiler-plugin", project);
if (compilerPlugin != null) {
Xpp3Dom configuration = (Xpp3Dom) compilerPlugin.getConfiguration();
if (configuration != null) {
Xpp3Dom configuredSource = configuration.getChild("source");
Xpp3Dom configuredTarget = configuration.getChild("target");
if (configuredSource != null && !configuredSource.getValue().trim().isEmpty()) {
source = configuredSource.getValue();
}
if (configuredTarget != null && !configuredTarget.getValue().trim().isEmpty()) {
target = configuredTarget.getValue();
}
}
}
builder.propertyAssignment(null, "java.sourceCompatibility", JavaVersion.toVersion(source));
if (!target.equals(source)) {
builder.propertyAssignment(null, "java.targetCompatibility", JavaVersion.toVersion(target));
}
String encoding = (String) project.getProperties().get("project.build.sourceEncoding");
if (StringUtils.isNotEmpty(encoding)) {
builder.taskPropertyAssignment(null, "JavaCompile", "options.encoding", encoding);
}
}
use of org.apache.maven.model.Plugin in project docker-maven-plugin by fabric8io.
the class MojoExecutionService method callPluginGoal.
// Call another goal after restart has finished
public void callPluginGoal(String fullGoal) throws MojoFailureException, MojoExecutionException {
String[] parts = splitGoalSpec(fullGoal);
Plugin plugin = project.getPlugin(parts[0]);
String goal = parts[1];
if (plugin == null) {
throw new MojoFailureException("No goal " + fullGoal + " found in pom.xml");
}
try {
String executionId = null;
if (goal != null && goal.length() > 0 && goal.indexOf('#') > -1) {
int pos = goal.indexOf('#');
executionId = goal.substring(pos + 1);
goal = goal.substring(0, pos);
}
PluginDescriptor pluginDescriptor = getPluginDescriptor(project, plugin);
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
if (mojoDescriptor == null) {
throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion());
}
MojoExecution exec = getMojoExecution(executionId, mojoDescriptor);
pluginManager.executeMojo(session, exec);
} catch (Exception e) {
throw new MojoExecutionException("Unable to execute mojo", e);
}
}
Aggregations