You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/05/04 12:03:55 UTC
svn commit: r1333847 - in /maven/plugin-tools/branches/MPLUGIN-189:
maven-plugin-plugin/ maven-plugin-plugin/src/it/java-basic-annotations/
maven-plugin-plugin/src/it/java-basic-annotations/src/
maven-plugin-plugin/src/it/java-basic-annotations/src/mai...
Author: olamy
Date: Fri May 4 10:03:54 2012
New Revision: 1333847
URL: http://svn.apache.org/viewvc?rev=1333847&view=rev
Log:
add an it test.
add a flag to prevent error when using only annotations: no descriptors found
extraction is bind to generate-sources in maven core for maven-plugin packaging so at this stage no classes available for scanning annotations
Added:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties (with props)
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml (with props)
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/CoreIt0014Mojo.java (with props)
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java (with props)
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java (with props)
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy (with props)
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/DefaultPluginToolsRequest.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/PluginToolsRequest.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml Fri May 4 10:03:54 2012
@@ -62,6 +62,7 @@
<mavenVersion>2.0.6</mavenVersion>
<doxiaVersion>1.2</doxiaVersion>
<doxia-sitetoolsVersion>1.2</doxia-sitetoolsVersion>
+ <it.debug>true</it.debug>
</properties>
<!-- Copy from project up -->
@@ -292,6 +293,7 @@
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <debug>${it.debug}</debug>
<filterProperties>
<sitePluginVersion>3.0</sitePluginVersion>
</filterProperties>
Added: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties?rev=1333847&view=auto
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties (added)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties Fri May 4 10:03:54 2012
@@ -0,0 +1,2 @@
+invoker.goals.1 = install
+invoker.goals.2 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0:it0014
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml?rev=1333847&view=auto
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml (added)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml Fri May 4 10:03:54 2012
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.basic-java-annotations</groupId>
+ <artifactId>maven-it-basic-java-annotations</artifactId>
+ <version>1.0</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>Maven Integration Test :: basic-java-annotations</name>
+ <description>
+ Test plugin-plugin, which tests maven-plugin-tools-api and
+ maven-plugin-tools-java. This will generate a plugin descriptor from
+ java-based mojo sources, install the plugin, and then use it.
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ <id>mojo-descriptor</id>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/CoreIt0014Mojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/CoreIt0014Mojo.java?rev=1333847&view=auto
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/CoreIt0014Mojo.java (added)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/CoreIt0014Mojo.java Fri May 4 10:03:54 2012
@@ -0,0 +1,66 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Touches a test file.
+ *
+ */
+@Mojo( name = "it0014")
+public class CoreIt0014Mojo
+ extends AbstractMojo
+{
+
+ @Parameter(expression ="${project.build.directory}", required = true)
+ private String outputDirectory;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ getLog().info( "outputDirectory = " + outputDirectory );
+
+ File f = new File( outputDirectory );
+
+ if ( !f.exists() )
+ {
+ f.mkdirs();
+ }
+
+ File touch = new File( f, "touch.txt" );
+
+ try
+ {
+ touch.createNewFile();
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error writing verification file.", e );
+ }
+ }
+
+}
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/CoreIt0014Mojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/CoreIt0014Mojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1333847&view=auto
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java (added)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java Fri May 4 10:03:54 2012
@@ -0,0 +1,66 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import java.io.File;
+
+/**
+ * Touches a test file.
+ *
+ * @since 1.2
+ * @deprecated Don't use!
+ */
+@Mojo( name = "first", requiresDependencyResolution = "test", defaultPhase = LifecyclePhase.INTEGRATION_TEST )
+@Execute( phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura" )
+public class FirstMojo
+ extends AbstractMojo
+{
+
+ @Parameter( defaultValue = "${basedir}", readonly = true )
+ private File basedir;
+
+ @Parameter( expression = "${first.touchFile}", defaultValue = "${project.build.directory}/touch.txt",
+ required = true )
+ private File touchFile;
+
+ /**
+ * @since 0.1
+ * @deprecated As of 0.2
+ */
+ @Parameter( alias = "alias" )
+ private String aliasedParam;
+
+ @Component( role = "org.apache.maven.project.MavenProjectHelper", roleHint = "test" )
+ private Object projectHelper;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ }
+
+}
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java?rev=1333847&view=auto
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java (added)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java Fri May 4 10:03:54 2012
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Does nothing special.
+ *
+ */
+@Mojo( name = "second",requiresDependencyCollection = "compile", threadSafe = true)
+public class SecondMojo
+ extends AbstractMojo
+{
+
+ public void execute()
+ {
+ }
+
+}
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy?rev=1333847&view=auto
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy (added)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy Fri May 4 10:03:54 2012
@@ -0,0 +1,72 @@
+File touchFile = new File( basedir, "target/touch.txt" )
+assert touchFile.isFile()
+
+File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" );
+assert descriptorFile.isFile()
+
+def pluginDescriptor = new XmlParser().parse( descriptorFile );
+
+def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first"}[0]
+
+assert mojo.goal.text() == 'first'
+assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.FirstMojo'
+assert mojo.language.text() == 'java'
+assert mojo.description.text() == 'Touches a test file.'
+assert mojo.deprecated.text() == "Don't use!"
+assert mojo.requiresDependencyResolution.text() == 'test'
+assert mojo.requiresDependencyCollection.text() == ''
+assert mojo.requiresProject.text() == 'true'
+assert mojo.requiresOnline.text() == 'false'
+assert mojo.requiresDirectInvocation.text() == 'false'
+assert mojo.aggregator.text() == 'false'
+assert mojo.threadSafe.text() == 'false'
+assert mojo.phase.text() == 'integration-test'
+assert mojo.executePhase.text() == 'generate-sources'
+assert mojo.executeLifecycle.text() == 'cobertura'
+
+assert mojo.configuration.basedir[0].text() == ''
+assert mojo.configuration.basedir[0].'@implementation' == 'java.io.File'
+assert mojo.configuration.basedir[0].'@default-value' == '${basedir}'
+
+assert mojo.configuration.touchFile[0].text() == '${first.touchFile}'
+assert mojo.configuration.touchFile[0].'@implementation' == 'java.io.File'
+assert mojo.configuration.touchFile[0].'@default-value' == '${project.build.directory}/touch.txt'
+
+assert mojo.requirements.requirement.size() == 1
+
+assert mojo.requirements.requirement[0].role.text() == 'org.apache.maven.project.MavenProjectHelper'
+assert mojo.requirements.requirement[0].'role-hint'.text() == 'test'
+assert mojo.requirements.requirement[0].'field-name'.text() == 'projectHelper'
+
+assert mojo.parameters.parameter.size() == 3
+
+assert mojo.parameters.parameter[0].name.text() == 'aliasedParam'
+assert mojo.parameters.parameter[0].alias.text() == 'alias'
+assert mojo.parameters.parameter[0].type.text() == 'java.lang.String'
+assert mojo.parameters.parameter[0].deprecated.text() == 'As of 0.2'
+assert mojo.parameters.parameter[0].required.text() == 'false'
+assert mojo.parameters.parameter[0].editable.text() == 'true'
+assert mojo.parameters.parameter[0].description.text() == ''
+
+assert mojo.parameters.parameter[1].name.text() == 'basedir'
+assert mojo.parameters.parameter[1].alias.isEmpty()
+assert mojo.parameters.parameter[1].type.text() == 'java.io.File'
+assert mojo.parameters.parameter[1].deprecated.isEmpty()
+assert mojo.parameters.parameter[1].required.text() == 'false'
+assert mojo.parameters.parameter[1].editable.text() == 'false'
+assert mojo.parameters.parameter[1].description.text() == 'Project directory.'
+
+assert mojo.parameters.parameter[2].name.text() == 'touchFile'
+assert mojo.parameters.parameter[2].alias.isEmpty()
+assert mojo.parameters.parameter[2].type.text() == 'java.io.File'
+assert mojo.parameters.parameter[2].deprecated.isEmpty()
+assert mojo.parameters.parameter[2].required.text() == 'true'
+assert mojo.parameters.parameter[2].editable.text() == 'true'
+assert mojo.parameters.parameter[2].description.text() == ''
+
+mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0]
+
+assert mojo.requiresDependencyCollection.text() == 'compile'
+assert mojo.threadSafe.text() == 'true'
+
+return true;
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java Fri May 4 10:03:54 2012
@@ -80,6 +80,15 @@ public abstract class AbstractGeneratorM
protected String goalPrefix;
/**
+ * By default an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the
+ * descriptor generator mojo is bound to generate-resources phase.
+ * But for annotations, the compiled classes are needed, so skip error
+ * @parameter expression="${maven.plugin.skipErrorNoDescriptorsFound}" default-value="false"
+ * @since 3.0
+ */
+ protected boolean skipErrorNoDescriptorsFound;
+
+ /**
* The role names of mojo extractors to use.
* <p/>
* If not set, all mojo extractors will be used. If set to an empty extractor name, no mojo extractors
@@ -193,6 +202,7 @@ public abstract class AbstractGeneratorM
PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
request.setEncoding( encoding );
+ request.setSkipErrorNoDescriptorsFound( skipErrorNoDescriptorsFound );
mojoScanner.populatePluginDescriptor( request );
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java Fri May 4 10:03:54 2012
@@ -34,7 +34,7 @@ import java.io.File;
* @version $Id$
* @since 2.0
* @goal descriptor
- * @phase generate-resources
+ * @phase process-classes
* @requiresDependencyResolution runtime
*/
public class DescriptorGeneratorMojo
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java Fri May 4 10:03:54 2012
@@ -32,7 +32,7 @@ import org.apache.maven.tools.plugin.gen
* @version $Id$
* @since 2.4
* @goal helpmojo
- * @phase generate-sources
+ * @phase process-classes
*/
public class HelpGeneratorMojo
extends AbstractGeneratorMojo
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java Fri May 4 10:03:54 2012
@@ -79,7 +79,7 @@ public class JavaAnnotationsMojoDescript
List<MojoAnnotatedClass> mojoAnnotatedClasses =
mojoAnnotationsScanner.scan( mojoAnnotationsScannerRequest );
- return toMojoDescriptors( mojoAnnotatedClasses );
+ return toMojoDescriptors( mojoAnnotatedClasses, request );
}
catch ( DependencyResolutionRequiredException e )
{
@@ -101,7 +101,8 @@ public class JavaAnnotationsMojoDescript
return files;
}
- private List<MojoDescriptor> toMojoDescriptors( List<MojoAnnotatedClass> mojoAnnotatedClasses )
+ private List<MojoDescriptor> toMojoDescriptors( List<MojoAnnotatedClass> mojoAnnotatedClasses,
+ PluginToolsRequest request )
throws DuplicateParameterException
{
List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>( mojoAnnotatedClasses.size() );
@@ -109,17 +110,25 @@ public class JavaAnnotationsMojoDescript
{
MojoDescriptor mojoDescriptor = new MojoDescriptor();
+ //mojoDescriptor.setRole( mojoAnnotatedClass.getClassName() );
+ //mojoDescriptor.setRoleHint( "default" );
+ mojoDescriptor.setImplementation( mojoAnnotatedClass.getClassName() );
+
MojoAnnotationContent mojo = mojoAnnotatedClass.getMojo();
- ExecuteAnnotationContent execute = mojoAnnotatedClass.getExecute();
mojoDescriptor.setAggregator( mojo.aggregator() );
mojoDescriptor.setDependencyResolutionRequired( mojo.requiresDependencyResolution() );
mojoDescriptor.setDirectInvocationOnly( mojo.requiresDirectInvocation() );
mojoDescriptor.setDeprecated( mojo.getDeprecated() );
- mojoDescriptor.setExecuteGoal( execute.goal() );
- mojoDescriptor.setExecuteLifecycle( execute.lifecycle() );
- mojoDescriptor.setExecutePhase( execute.phase().id() );
+ ExecuteAnnotationContent execute = mojoAnnotatedClass.getExecute();
+
+ if ( execute != null )
+ {
+ mojoDescriptor.setExecuteGoal( execute.goal() );
+ mojoDescriptor.setExecuteLifecycle( execute.lifecycle() );
+ mojoDescriptor.setExecutePhase( execute.phase().id() );
+ }
mojoDescriptor.setExecutionStrategy( mojo.executionStrategy() );
// FIXME olamy wtf ?
@@ -157,6 +166,8 @@ public class JavaAnnotationsMojoDescript
mojoDescriptor.addParameter( parameter );
}
+ mojoDescriptor.setPluginDescriptor( request.getPluginDescriptor() );
+
mojoDescriptors.add( mojoDescriptor );
}
return mojoDescriptors;
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java Fri May 4 10:03:54 2012
@@ -49,7 +49,7 @@ public class ComponentAnnotationContent
public String role()
{
- return role;
+ return role == null ? "" : role;
}
public void role( String role )
@@ -59,7 +59,7 @@ public class ComponentAnnotationContent
public String roleHint()
{
- return roleHint;
+ return roleHint == null ? "" : roleHint;
}
public void roleHint( String roleHint )
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/DefaultPluginToolsRequest.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/DefaultPluginToolsRequest.java?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/DefaultPluginToolsRequest.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/DefaultPluginToolsRequest.java Fri May 4 10:03:54 2012
@@ -44,6 +44,8 @@ public class DefaultPluginToolsRequest
private String encoding = DEFAULT_ENCODING;
+ private boolean skipErrorNoDescriptorsFound;
+
public DefaultPluginToolsRequest( MavenProject project, PluginDescriptor pluginDescriptor )
{
this.project = project;
@@ -109,4 +111,20 @@ public class DefaultPluginToolsRequest
return this;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSkipErrorNoDescriptorsFound()
+ {
+ return skipErrorNoDescriptorsFound;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PluginToolsRequest setSkipErrorNoDescriptorsFound( boolean skipErrorNoDescriptorsFound )
+ {
+ this.skipErrorNoDescriptorsFound = skipErrorNoDescriptorsFound;
+ return this;
+ }
}
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/PluginToolsRequest.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/PluginToolsRequest.java?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/PluginToolsRequest.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/PluginToolsRequest.java Fri May 4 10:03:54 2012
@@ -26,23 +26,23 @@ import org.apache.maven.project.MavenPro
/**
* Request that encapsulates all information relevant to the process of extracting {@link MojoDescriptor}
* instances from metadata for a certain type of mojo.
- *
+ *
* @author jdcasey
* @since 2.5
*/
public interface PluginToolsRequest
{
-
+
/**
* Return the current {@link MavenProject} instance in use.
*/
MavenProject getProject();
-
+
/**
* @see PluginToolsRequest#getProject()
*/
PluginToolsRequest setProject( MavenProject project );
-
+
/**
* Return the {@link PluginDescriptor} currently being populated as part of the build of the
* current plugin project.
@@ -53,21 +53,37 @@ public interface PluginToolsRequest
* @see PluginToolsRequest#getPluginDescriptor()
*/
PluginToolsRequest setPluginDescriptor( PluginDescriptor pluginDescriptor );
-
+
/**
* Gets the file encoding of the source files.
- *
+ *
* @return The file encoding of the source files, never <code>null</code>.
*/
String getEncoding();
/**
* Sets the file encoding of the source files.
- *
+ *
* @param encoding The file encoding of the source files, may be empty or <code>null</code> to use the platform's
- * default encoding.
+ * default encoding.
* @return This request.
*/
PluginToolsRequest setEncoding( String encoding );
+ /**
+ * By default an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the
+ * descriptor generator mojo is bound to generate-resources phase.
+ * But for annotations, the compiled classes are needed, so skip error
+ * @since 3.0
+ */
+ PluginToolsRequest setSkipErrorNoDescriptorsFound( boolean skipErrorNoDescriptorsFound );
+
+ /**
+ * @since 3.0
+ * @return
+ */
+ boolean isSkipErrorNoDescriptorsFound();
+
+
+
}
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java?rev=1333847&r1=1333846&r2=1333847&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java Fri May 4 10:03:54 2012
@@ -19,11 +19,6 @@ package org.apache.maven.tools.plugin.sc
* under the License.
*/
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
@@ -36,6 +31,11 @@ import org.codehaus.plexus.logging.Abstr
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* @author jdcasey
*/
@@ -71,14 +71,18 @@ public class DefaultMojoScanner
// nop
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void populatePluginDescriptor( MavenProject project, PluginDescriptor pluginDescriptor )
throws ExtractionException, InvalidPluginDescriptorException
{
populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
}
-
- /** {@inheritDoc} */
+
+ /**
+ * {@inheritDoc}
+ */
public void populatePluginDescriptor( PluginToolsRequest request )
throws ExtractionException, InvalidPluginDescriptorException
{
@@ -103,7 +107,7 @@ public class DefaultMojoScanner
List<MojoDescriptor> extractorDescriptors = extractor.execute( request );
logger.info( "Mojo extractor for language: " + language + " found " + extractorDescriptors.size()
- + " mojo descriptors." );
+ + " mojo descriptors." );
numMojoDescriptors += extractorDescriptors.size();
for ( MojoDescriptor descriptor : extractorDescriptors )
@@ -116,10 +120,11 @@ public class DefaultMojoScanner
}
}
- if ( numMojoDescriptors == 0 )
+ if ( numMojoDescriptors == 0 && !request.isSkipErrorNoDescriptorsFound() )
{
- throw new InvalidPluginDescriptorException( "No mojo definitions were found for plugin: "
- + request.getPluginDescriptor().getPluginLookupKey() + "." );
+ throw new InvalidPluginDescriptorException(
+ "No mojo definitions were found for plugin: " + request.getPluginDescriptor().getPluginLookupKey()
+ + "." );
}
}