diff --git a/src/it/projects/project6/pom.xml b/src/it/projects/project6/pom.xml new file mode 100644 index 00000000..63ba6faa --- /dev/null +++ b/src/it/projects/project6/pom.xml @@ -0,0 +1,29 @@ + + 4.0.0 + + + org.codehaus.mojo.exec.it + parent + 0.1 + + + org.codehaus.mojo.exec.project5 + project5 + pom + 1.0-SNAPSHOT + Exec Plugin Example Project 5 Parent + + + + junit + junit + 3.8.1 + + + + + project5exec + project5lib + project5libB + + diff --git a/src/it/projects/project6/project5exec/pom.xml b/src/it/projects/project6/project5exec/pom.xml new file mode 100644 index 00000000..c63f702b --- /dev/null +++ b/src/it/projects/project6/project5exec/pom.xml @@ -0,0 +1,71 @@ + + + org.codehaus.mojo.exec.project5 + project5 + 1.0-SNAPSHOT + + 4.0.0 + project5exec + jar + Exec Plugin Example Project 5 Exec + http://maven.apache.org + + + + org.codehaus.mojo + exec-maven-plugin + @pom.version@ + + + process-classes + + java + + + + + + + propkey + propvalue + + + + org.codehaus.mojo.exec.project5libB.App + + + argument1 + argument2 + + false + true + + org.codehaus.mojo.exec.project5 + project5libB + + + + + org.codehaus.mojo.exec.project5 + project5libB + ${project.version} + + + + junit + junit + 3.8.1 + runtime + + + + + + + + commons-logging + commons-logging + 1.0.4 + + + diff --git a/src/it/projects/project6/project5lib/pom.xml b/src/it/projects/project6/project5lib/pom.xml new file mode 100644 index 00000000..225e0a1a --- /dev/null +++ b/src/it/projects/project6/project5lib/pom.xml @@ -0,0 +1,22 @@ + + + org.codehaus.mojo.exec.project5 + project5 + 1.0-SNAPSHOT + + 4.0.0 + project5lib + jar + Exec Plugin Example Project 5 Lib + http://maven.apache.org + + + commons-io + commons-io + 1.1 + runtime + + + diff --git a/src/it/projects/project6/project5lib/src/main/java/org/codehaus/mojo/exec/project5lib/ExampleLibrary.java b/src/it/projects/project6/project5lib/src/main/java/org/codehaus/mojo/exec/project5lib/ExampleLibrary.java new file mode 100644 index 00000000..fc086d60 --- /dev/null +++ b/src/it/projects/project6/project5lib/src/main/java/org/codehaus/mojo/exec/project5lib/ExampleLibrary.java @@ -0,0 +1,14 @@ +package org.codehaus.mojo.exec.project5lib; + +/** + * Used for manual integrationtest of the java goal. + * + */ +public class ExampleLibrary +{ + public ExampleLibrary() { + } + public boolean isAGoodDay() { + return true; + } +} diff --git a/src/it/projects/project6/project5libB/pom.xml b/src/it/projects/project6/project5libB/pom.xml new file mode 100644 index 00000000..e85a47d6 --- /dev/null +++ b/src/it/projects/project6/project5libB/pom.xml @@ -0,0 +1,21 @@ + + + org.codehaus.mojo.exec.project5 + project5 + 1.0-SNAPSHOT + + 4.0.0 + project5libB + jar + Exec Plugin Example Project 5 Lib B + http://maven.apache.org + + + org.codehaus.mojo.exec.project5 + project5lib + ${project.version} + + + diff --git a/src/it/projects/project6/project5libB/src/main/java/org/codehaus/mojo/exec/project5libB/App.java b/src/it/projects/project6/project5libB/src/main/java/org/codehaus/mojo/exec/project5libB/App.java new file mode 100644 index 00000000..91934de6 --- /dev/null +++ b/src/it/projects/project6/project5libB/src/main/java/org/codehaus/mojo/exec/project5libB/App.java @@ -0,0 +1,49 @@ +package org.codehaus.mojo.exec.project5libB; + +/** + * Used for manual integrationtest of the java goal. + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println("I was started. So obviously I found the main class"); + + App app = new App(); + + try + { + Class fileUtils = app.getClass().getClassLoader().loadClass( "org.codehaus.mojo.exec.project5lib.ExampleLibrary" ); + if ( null != fileUtils ) + { + System.out.println( "Found the ExampleLibrary" ); + } + } + + catch ( Exception e ) + { + System.out.println( "Did not find the ExampleLibrary" ); + } + + try + { + Class fileUtils = app.getClass().getClassLoader().loadClass( "org.apache.commons.io.FileUtils" ); + if ( null != fileUtils ) + { + System.out.println( "Found the runtime dependency" ); + } + } + catch ( Exception e ) + { + System.out.println( "Did not find the runtime dependency" ); + } + + + String value = System.getProperty("propkey"); + if (null != value) + { + System.out.println("Found the system property passed"); + } + } +} diff --git a/src/it/projects/project6/verify.groovy b/src/it/projects/project6/verify.groovy new file mode 100644 index 00000000..22a93d21 --- /dev/null +++ b/src/it/projects/project6/verify.groovy @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File log = new File(basedir, 'build.log') +assert log.exists() +assert log.getText().contains("I was started. So obviously I found the main class") +assert log.getText().contains("Found the ExampleLibrary") +assert log.getText().contains("Found the runtime dependency") +assert log.getText().contains("Found the system property passed") \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/exec/AbstractExecMojo.java b/src/main/java/org/codehaus/mojo/exec/AbstractExecMojo.java index 90f63184..e72cb564 100644 --- a/src/main/java/org/codehaus/mojo/exec/AbstractExecMojo.java +++ b/src/main/java/org/codehaus/mojo/exec/AbstractExecMojo.java @@ -249,6 +249,11 @@ protected final MavenSession getSession() return session; } + protected final List getPluginDependencies() + { + return pluginDependencies; + } + /** * Examine the plugin dependencies to find the executable artifact. * diff --git a/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java b/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java index c7a740e4..6aae6ba8 100644 --- a/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java +++ b/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java @@ -30,6 +30,8 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.artifact.filter.resolve.AndFilter; +import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; @@ -53,12 +55,6 @@ public class ExecJavaMojo @Component private ProjectBuilder projectBuilder; - /** - * @since 1.1-beta-1 - */ - @Parameter( readonly = true, defaultValue = "${plugin.artifacts}" ) - private List pluginDependencies; - /** * The main class to execute.
* With Java 9 and above you can prefix it with the modulename, e.g. com.greetings/com.greetings.Main @@ -679,7 +675,7 @@ private Set determineRelevantPluginDependencies() if ( this.executableDependency == null ) { getLog().debug( "All Plugin Dependencies will be included." ); - relevantDependencies = new HashSet( this.pluginDependencies ); + relevantDependencies = new HashSet( this.getPluginDependencies() ); } else { @@ -715,7 +711,9 @@ private Set resolveExecutableDependencies( Artifact executablePomArtif MavenProject executableProject = this.projectBuilder.build( executablePomArtifact, buildingRequest ).getProject(); - for ( ArtifactResult artifactResult : dependencyResolver.resolveDependencies( buildingRequest, executableProject.getModel(), null ) ) + for ( ArtifactResult artifactResult : dependencyResolver.resolveDependencies( buildingRequest, + executableProject.getModel(), + new AndFilter( Collections.emptyList() ) ) ) { executableDependencies.add( artifactResult.getArtifact() ); }