From de55808dc77d2955e92329a0776486b5ae56131a Mon Sep 17 00:00:00 2001 From: Vincent Siveton Date: Thu, 31 Jan 2008 23:54:48 +0000 Subject: [PATCH] MPLUGIN-53: Plugin descriptor extractor crashes on certain types of Java source files Submitted by: Paul Gier Reviewed by: Vincent Siveton o applied git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@617308 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/JavaMojoDescriptorExtractorTest.java | 30 +++++++++++++++++++ .../resources/source3/TestAnnotation.java | 8 +++++ 2 files changed, 38 insertions(+) create mode 100644 maven-plugin-tools-java/src/test/resources/source3/TestAnnotation.java diff --git a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java index 731dcfe..39ea17c 100644 --- a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java +++ b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java @@ -117,5 +117,35 @@ public class JavaMojoDescriptorExtractorTest return result; } + + /** + * Check that the mojo descriptor extractor will ignore any annotations that are found. + * + * @throws Exception + */ + public void testAnnotationInPlugin() + throws Exception + { + JavaMojoDescriptorExtractor extractor = new JavaMojoDescriptorExtractor(); + + File sourceFile = fileOf( "dir-flag.txt" ); + + File dir = sourceFile.getParentFile(); + + Model model = new Model(); + model.setArtifactId( "maven-unitTesting-plugin" ); + + MavenProject project = new MavenProject( model ); + + project.setFile( new File( dir, "pom.xml" ) ); + project.addCompileSourceRoot( new File( dir, "source3" ).getPath() ); + + PluginDescriptor pluginDescriptor = new PluginDescriptor(); + pluginDescriptor.setGoalPrefix( "test" ); + List results = extractor.execute( project, pluginDescriptor ); + assertEquals( 0, results.size() ); + + } + } diff --git a/maven-plugin-tools-java/src/test/resources/source3/TestAnnotation.java b/maven-plugin-tools-java/src/test/resources/source3/TestAnnotation.java new file mode 100644 index 0000000..1e9e8b1 --- /dev/null +++ b/maven-plugin-tools-java/src/test/resources/source3/TestAnnotation.java @@ -0,0 +1,8 @@ +package source3; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) + +public @interface TestAnnotation { + +}