diff --git a/maven-core-it/README.txt b/maven-core-it/README.txt index 1cd37823db..4c9b8710a9 100644 --- a/maven-core-it/README.txt +++ b/maven-core-it/README.txt @@ -234,12 +234,16 @@ it0085: Verify that system-scoped dependencies get resolved with system scope dependency. Inherited scope should not apply in the case of system-scoped dependencies, no matter where they are. -it0086: Verify that a class in a plugin's dependencies can be loaded by both - .getClass().getClassLoader() and Thread.currentThread().getContextClassLoader(). +it0086: Verify that a plugin dependency class can be loaded from both the plugin classloader and the + context classloader available to the plugin. -it0087: Verify that a class in the project-level dependencies for a plugin can be loaded by both - .getClass().getClassLoader() and Thread.currentThread().getContextClassLoader(). +it0087: Verify that a project-level plugin dependency class can be loaded from both the plugin classloader + and the context classloader available to the plugin. +it0088: Test path translation + +it0089: Test that Checkstyle PackageNamesLoader.loadModuleFactory(..) method will complete as-is with + the context classloader available to the plugin. ------------------------------------------------------------------------------- - generated sources diff --git a/maven-core-it/integration-tests.txt b/maven-core-it/integration-tests.txt index 6232d10fce..3469956764 100644 --- a/maven-core-it/integration-tests.txt +++ b/maven-core-it/integration-tests.txt @@ -1,4 +1,7 @@ +it0089 it0088 +it0087 +it0086 it0085 it0084 it0083 diff --git a/maven-core-it/it0089/expected-results.txt b/maven-core-it/it0089/expected-results.txt new file mode 100644 index 0000000000..3c0f791ce1 --- /dev/null +++ b/maven-core-it/it0089/expected-results.txt @@ -0,0 +1 @@ +project/target/output.txt diff --git a/maven-core-it/it0089/goals.txt b/maven-core-it/it0089/goals.txt new file mode 100644 index 0000000000..7c32f55981 --- /dev/null +++ b/maven-core-it/it0089/goals.txt @@ -0,0 +1 @@ +install diff --git a/maven-core-it/it0089/plugin/pom.xml b/maven-core-it/it0089/plugin/pom.xml new file mode 100644 index 0000000000..271c608284 --- /dev/null +++ b/maven-core-it/it0089/plugin/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + + org.apache.maven.it + 1.0 + it0089-root + + + org.apache.maven.plugins + maven-it0089-plugin + 1.0-SNAPSHOT + maven-plugin + + + + checkstyle + checkstyle + 4.1 + + + org.apache.maven + maven-plugin-api + 2.0 + + + diff --git a/maven-core-it/it0089/plugin/src/main/java/org/apache/maven/plugins/it0089/Mojo.java b/maven-core-it/it0089/plugin/src/main/java/org/apache/maven/plugins/it0089/Mojo.java new file mode 100644 index 0000000000..27617fbc7c --- /dev/null +++ b/maven-core-it/it0089/plugin/src/main/java/org/apache/maven/plugins/it0089/Mojo.java @@ -0,0 +1,71 @@ +package org.apache.maven.plugins.it0089; + +import com.puppycrawl.tools.checkstyle.PackageNamesLoader; +import com.puppycrawl.tools.checkstyle.api.CheckstyleException; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; + + +/** + * @goal test + */ +public class Mojo + extends AbstractMojo +{ + + /** + * @parameter default-value="${basedir}/target" + * @required + * @readonly + */ + private File outDir; + + public void execute() throws MojoExecutionException, MojoFailureException + { + try + { + PackageNamesLoader.loadModuleFactory(Thread.currentThread().getContextClassLoader()); + getLog().info( "Loaded checkstyle module factory."); + + outDir.mkdirs(); + + File output = new File( outDir, "output.txt" ); + Writer writer = null; + + try + { + writer = new FileWriter( output ); + writer.write( "Success." ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write output file.", e ); + } + finally + { + if ( writer != null ) + { + try + { + writer.close(); + } + catch ( IOException e ) + { + } + } + } + } + catch ( CheckstyleException e ) + { + throw new MojoExecutionException( "Error loading checkstyle module factory.", e ); + } + } + +} diff --git a/maven-core-it/it0089/pom.xml b/maven-core-it/it0089/pom.xml new file mode 100644 index 0000000000..5bef40d146 --- /dev/null +++ b/maven-core-it/it0089/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + org.apache.maven.it + it0089-root + 1.0 + + pom + + + plugin + project + + diff --git a/maven-core-it/it0089/prebuild-hook.txt b/maven-core-it/it0089/prebuild-hook.txt new file mode 100644 index 0000000000..3ce9c85a20 --- /dev/null +++ b/maven-core-it/it0089/prebuild-hook.txt @@ -0,0 +1 @@ +rm ${artifact:org.apache.maven.plugins:maven-core-it-plugin:1.0-SNAPSHOT:maven-plugin} diff --git a/maven-core-it/it0089/project/pom.xml b/maven-core-it/it0089/project/pom.xml new file mode 100644 index 0000000000..8489730af7 --- /dev/null +++ b/maven-core-it/it0089/project/pom.xml @@ -0,0 +1,30 @@ + + 4.0.0 + + org.apache.maven.it + 1.0 + it0089-root + + + it0089 + + Plugin Transitive Dependency Classloading Test + + + + + maven-it0089-plugin + + + + validate + + + test + + + + + + +