diff --git a/maven-core-integration-tests/src/test/resources/it0089/plugin/pom.xml b/maven-core-integration-tests/src/test/resources/it0089/plugin/pom.xml new file mode 100644 index 0000000000..271c608284 --- /dev/null +++ b/maven-core-integration-tests/src/test/resources/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-integration-tests/src/test/resources/it0089/plugin/src/main/java/org/apache/maven/plugins/it0089/Mojo.java b/maven-core-integration-tests/src/test/resources/it0089/plugin/src/main/java/org/apache/maven/plugins/it0089/Mojo.java new file mode 100644 index 0000000000..27617fbc7c --- /dev/null +++ b/maven-core-integration-tests/src/test/resources/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-integration-tests/src/test/resources/it0089/pom.xml b/maven-core-integration-tests/src/test/resources/it0089/pom.xml new file mode 100644 index 0000000000..755fc114fa --- /dev/null +++ b/maven-core-integration-tests/src/test/resources/it0089/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + org.apache.maven.it + it0089-root + Test that Checkstyle PackageNamesLoader.loadModuleFactory(..) method will complete as-is with + the context classloader available to the plugin. + + 1.0 + + pom + + + plugin + project + + diff --git a/maven-core-integration-tests/src/test/resources/it0089/project/pom.xml b/maven-core-integration-tests/src/test/resources/it0089/project/pom.xml new file mode 100644 index 0000000000..8489730af7 --- /dev/null +++ b/maven-core-integration-tests/src/test/resources/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 + + + + + + +