Index: maven-plugin-tools-anno/pom.xml
===================================================================
--- maven-plugin-tools-anno/pom.xml (revision 0)
+++ maven-plugin-tools-anno/pom.xml (revision 0)
@@ -0,0 +1,130 @@
+
+
+
+ org.apache.maven
+ maven-plugin-tools
+ 2.0.4
+
+
+ 4.0.0
+ org.apache.maven
+ maven-plugin-tools-anno
+ 1.1-SNAPSHOT
+
+
+ 2.0.4
+
+
+ Maven Annotated Mojo
+ Maven2 extention that allows writing annotatd Mojos using JDK 1.5 annotations instead of doclet
+ comments.
+
+ http://sourceforge.net/projects/mvn-anno-mojo/
+ 2006
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ https://sourceforge.net/tracker/?group_id=166880
+
+
+
+ scm:svn:https://svn.sourceforge.net/svnroot/mvn-anno-mojo/mvn-anno-mojo/trunk
+ scm:svn:https://svn.sourceforge.net/svnroot/mvn-anno-mojo/mvn-anno-mojo/trunk
+
+ http://svn.sourceforge.net/viewcvs.py/mvn-anno-mojo/mvn-anno-mojo/trunk
+
+
+
+
+ org.apache.maven
+ maven-plugin-tools-api
+ 2.0.4
+
+
+ org.apache.maven
+ maven-plugin-descriptor
+ 2.0.4
+
+
+ org.apache.maven
+ maven-settings
+ 2.0.4
+
+
+ org.codehaus.plexus
+ plexus-utils
+ 1.1
+
+
+ com.sun
+ tools
+ 1.5.0
+ system
+ ${java.home}/../lib/tools.jar
+
+
+
+
+ install
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 2.1
+
+
+ src/main/assembly/assembly.xml
+
+ ${artifactId}-${version}
+ target/distribution
+ target/assembly/work
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 2.1
+ sources
+
+
+
+
+ org.codehaus.mojo
+ surefire-report-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.5
+ 1.5
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-project-info-reports-plugin
+
+
+ org.codehaus.mojo
+ surefire-report-maven-plugin
+
+
+
+
Index: maven-plugin-tools-anno.patch
===================================================================
--- maven-plugin-tools-anno.patch (revision 0)
+++ maven-plugin-tools-anno.patch (revision 0)
@@ -0,0 +1,135 @@
+Index: maven-plugin-tools-anno/pom.xml
+===================================================================
+--- maven-plugin-tools-anno/pom.xml (revision 0)
++++ maven-plugin-tools-anno/pom.xml (revision 0)
+@@ -0,0 +1,130 @@
++
++
++
++ org.apache.maven
++ maven-plugin-tools
++ 2.0.4
++
++
++ 4.0.0
++ org.apache.maven
++ maven-plugin-tools-anno
++ 1.1-SNAPSHOT
++
++
++ 2.0.4
++
++
++ Maven Annotated Mojo
++ Maven2 extention that allows writing annotatd Mojos using JDK 1.5 annotations instead of doclet
++ comments.
++
++ http://sourceforge.net/projects/mvn-anno-mojo/
++ 2006
++
++
++
++ The Apache Software License, Version 2.0
++ http://www.apache.org/licenses/LICENSE-2.0.txt
++ repo
++
++
++
++
++ https://sourceforge.net/tracker/?group_id=166880
++
++
++
++ scm:svn:https://svn.sourceforge.net/svnroot/mvn-anno-mojo/mvn-anno-mojo/trunk
++ scm:svn:https://svn.sourceforge.net/svnroot/mvn-anno-mojo/mvn-anno-mojo/trunk
++
++ http://svn.sourceforge.net/viewcvs.py/mvn-anno-mojo/mvn-anno-mojo/trunk
++
++
++
++
++ org.apache.maven
++ maven-plugin-tools-api
++ 2.0.4
++
++
++ org.apache.maven
++ maven-plugin-descriptor
++ 2.0.4
++
++
++ org.apache.maven
++ maven-settings
++ 2.0.4
++
++
++ org.codehaus.plexus
++ plexus-utils
++ 1.1
++
++
++ com.sun
++ tools
++ 1.5.0
++ system
++ ${java.home}/../lib/tools.jar
++
++
++
++
++ install
++
++
++
++
++ org.apache.maven.plugins
++ maven-assembly-plugin
++ 2.1
++
++
++ src/main/assembly/assembly.xml
++
++ ${artifactId}-${version}
++ target/distribution
++ target/assembly/work
++
++
++
++ org.apache.maven.plugins
++ maven-assembly-plugin
++ 2.1
++ sources
++
++
++
++
++ org.codehaus.mojo
++ surefire-report-maven-plugin
++
++
++ org.apache.maven.plugins
++ maven-compiler-plugin
++
++ 1.5
++ 1.5
++
++
++
++
++
++
++
++
++ org.apache.maven.plugins
++ maven-project-info-reports-plugin
++
++
++ org.codehaus.mojo
++ surefire-report-maven-plugin
++
++
++
++
Index: maven-plugin-tools-anno/pom.xml
===================================================================
--- maven-plugin-tools-anno/pom.xml (revision 0)
+++ maven-plugin-tools-anno/pom.xml (revision 0)
@@ -0,0 +1,130 @@
+
+
+
+ org.apache.maven
+ maven-plugin-tools
+ 2.0.4
+
+
+ 4.0.0
+ org.apache.maven
+ maven-plugin-tools-anno
+ 1.1-SNAPSHOT
+
+
+ 2.0.4
+
+
+ Maven Annotated Mojo
+ Maven2 extention that allows writing annotatd Mojos using JDK 1.5 annotations instead of doclet
+ comments.
+
+ http://sourceforge.net/projects/mvn-anno-mojo/
+ 2006
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ https://sourceforge.net/tracker/?group_id=166880
+
+
+
+ scm:svn:https://svn.sourceforge.net/svnroot/mvn-anno-mojo/mvn-anno-mojo/trunk
+ scm:svn:https://svn.sourceforge.net/svnroot/mvn-anno-mojo/mvn-anno-mojo/trunk
+
+ http://svn.sourceforge.net/viewcvs.py/mvn-anno-mojo/mvn-anno-mojo/trunk
+
+
+
+
+ org.apache.maven
+ maven-plugin-tools-api
+ 2.0.4
+
+
+ org.apache.maven
+ maven-plugin-descriptor
+ 2.0.4
+
+
+ org.apache.maven
+ maven-settings
+ 2.0.4
+
+
+ org.codehaus.plexus
+ plexus-utils
+ 1.1
+
+
+ com.sun
+ tools
+ 1.5.0
+ system
+ ${java.home}/../lib/tools.jar
+
+
+
+
+ install
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 2.1
+
+
+ src/main/assembly/assembly.xml
+
+ ${artifactId}-${version}
+ target/distribution
+ target/assembly/work
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 2.1
+ sources
+
+
+
+
+ org.codehaus.mojo
+ surefire-report-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.5
+ 1.5
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-project-info-reports-plugin
+
+
+ org.codehaus.mojo
+ surefire-report-maven-plugin
+
+
+
+
Index: maven-plugin-tools-anno/src/main/assembly/assembly.xml
===================================================================
--- maven-plugin-tools-anno/src/main/assembly/assembly.xml (revision 0)
+++ maven-plugin-tools-anno/src/main/assembly/assembly.xml (revision 0)
@@ -0,0 +1,57 @@
+
+ bin
+
+ zip
+
+ false
+
+
+
+ ${artifactId}
+ false
+ false
+
+
+ ${artifactId}
+
+
+
+
+
+
+ README*
+ LICENSE*
+ NOTICE*
+ pom.xml
+
+
+
+ target
+
+
+ *.jar
+
+
+
+ src
+ src
+
+ **/*
+
+
+
+ target/site
+ docs
+
+ **/*
+
+
+
+
+
+ lib
+ false
+ compile
+
+
+
\ No newline at end of file
Index: maven-plugin-tools-anno/src/main/assembly/assembly.xml
===================================================================
--- maven-plugin-tools-anno/src/main/assembly/assembly.xml (revision 0)
+++ maven-plugin-tools-anno/src/main/assembly/assembly.xml (revision 0)
@@ -0,0 +1,57 @@
+
+ bin
+
+ zip
+
+ false
+
+
+
+ ${artifactId}
+ false
+ false
+
+
+ ${artifactId}
+
+
+
+
+
+
+ README*
+ LICENSE*
+ NOTICE*
+ pom.xml
+
+
+
+ target
+
+
+ *.jar
+
+
+
+ src
+ src
+
+ **/*
+
+
+
+ target/site
+ docs
+
+ **/*
+
+
+
+
+
+ lib
+ false
+ compile
+
+
+
\ No newline at end of file
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MavenHelper.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MavenHelper.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MavenHelper.java (revision 0)
@@ -0,0 +1,11 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+public interface MavenHelper {
+ ArtifactRepository getLocalRepository() throws Exception;
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoDescriptorTls.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoDescriptorTls.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoDescriptorTls.java (revision 0)
@@ -0,0 +1,27 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+class MojoDescriptorTls {
+
+ private static ThreadLocal> TL = new ThreadLocal>();
+
+ static void addDescriptor(MojoDescriptor descriptor) {
+ List descriptors = TL.get();
+ descriptors.add(descriptor);
+ }
+
+ static List getDescriptors() {
+ return TL.get();
+ }
+
+ static void setDescriptors(List descriptors) {
+ TL.set(descriptors);
+ }
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven20Helper.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven20Helper.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven20Helper.java (revision 0)
@@ -0,0 +1,232 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.settings.MavenSettingsBuilder;
+import org.apache.maven.settings.RuntimeInfo;
+import org.apache.maven.settings.Settings;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author Jason van Zyl
+ */
+public class Maven20Helper implements MavenHelper {
+
+ private static final String userHome = System.getProperty("user.home");
+
+ private static final File userMavenConfigurationHome = new File(userHome, ".m2");
+
+ private static final String mavenHome = System.getProperty("maven.home");
+
+ // ----------------------------------------------------------------------
+ // Settings
+ // ----------------------------------------------------------------------
+
+ private static final File defaultUserSettingsFile = new File(userMavenConfigurationHome, "settings.xml");
+
+ private static final File defaultGlobalSettingsFile = new File(mavenHome, "conf/settings.xml");
+
+ private static final String ALT_USER_SETTINGS_XML_LOCATION = "org.apache.maven.user-settings";
+
+ private static final String ALT_GLOBAL_SETTINGS_XML_LOCATION = "org.apache.maven.global-settings";
+
+ // ----------------------------------------------------------------------
+ // Local Repository
+ // ----------------------------------------------------------------------
+
+ String ALT_LOCAL_REPOSITORY_LOCATION = "maven.repo.local";
+
+ File defaultUserLocalRepository = new File(userMavenConfigurationHome, "repository");
+
+ private ArtifactRepositoryLayout repositoryLayout;
+
+ private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+ private MavenSettingsBuilder settingsBuilder;
+
+ Maven20Helper(PlexusContainer container) throws ComponentLookupException {
+ repositoryLayout =
+ (ArtifactRepositoryLayout) container.lookup(ArtifactRepositoryLayout.ROLE);
+ artifactRepositoryFactory =
+ (ArtifactRepositoryFactory) container.lookup(ArtifactRepositoryFactory.ROLE);
+ settingsBuilder =
+ (MavenSettingsBuilder) container.lookup(MavenSettingsBuilder.ROLE);
+ }
+
+ // ----------------------------------------------------------------------------
+ // ArtifactRepository
+ // ----------------------------------------------------------------------------
+
+ public ArtifactRepository createLocalRepository(File directory) {
+ String localRepositoryUrl = directory.getAbsolutePath();
+
+ if (!localRepositoryUrl.startsWith("file:")) {
+ localRepositoryUrl = "file://" + localRepositoryUrl;
+ }
+
+ return createRepository("local", localRepositoryUrl, false, true, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
+ }
+
+ public ArtifactRepository createRepository(String repositoryId,
+ String repositoryUrl,
+ boolean offline,
+ boolean updateSnapshots,
+ String globalChecksumPolicy) {
+ ArtifactRepository localRepository =
+ new DefaultArtifactRepository(repositoryId, repositoryUrl, repositoryLayout);
+
+ boolean snapshotPolicySet = false;
+
+ if (offline) {
+ snapshotPolicySet = true;
+ }
+
+ if (!snapshotPolicySet && updateSnapshots) {
+ artifactRepositoryFactory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
+ }
+
+ artifactRepositoryFactory.setGlobalChecksumPolicy(globalChecksumPolicy);
+
+ return localRepository;
+ }
+
+ // ----------------------------------------------------------------------------
+ // Settings
+ // ----------------------------------------------------------------------------
+
+ public Settings buildSettings(File userSettingsPath,
+ File globalSettingsPath,
+ boolean interactive,
+ boolean offline,
+ boolean usePluginRegistry,
+ Boolean pluginUpdateOverride)
+ throws Exception {
+ Settings settings = buildSettings(userSettingsPath,
+ globalSettingsPath,
+ pluginUpdateOverride);
+ if (offline) {
+ settings.setOffline(true);
+ }
+
+ settings.setInteractiveMode(interactive);
+
+ settings.setUsePluginRegistry(usePluginRegistry);
+
+ return settings;
+ }
+
+ public Settings buildSettings(File userSettingsPath,
+ File globalSettingsPath,
+ Boolean pluginUpdateOverride)
+ throws Exception {
+ Settings settings;
+
+ try {
+ settings = settingsBuilder.buildSettings(userSettingsPath);
+ }
+ catch (IOException e) {
+ throw new Exception("Error reading settings file", e);
+ }
+ catch (XmlPullParserException e) {
+ throw new Exception(e.getMessage() + e.getDetail() + e.getLineNumber() +
+ e.getColumnNumber());
+ }
+
+ RuntimeInfo runtimeInfo = new RuntimeInfo(settings);
+
+ runtimeInfo.setPluginUpdateOverride(pluginUpdateOverride);
+
+ settings.setRuntimeInfo(runtimeInfo);
+
+ return settings;
+ }
+
+ /**
+ * Retrieve the user settings path using the followiwin search pattern:
+ *
+ * 1. System Property
+ * 2. Optional path
+ * 3. ${user.home}/.m2/settings.xml
+ */
+ public File getUserSettingsPath(String optionalSettingsPath) {
+ File userSettingsPath = new File(System.getProperty(ALT_USER_SETTINGS_XML_LOCATION) + "");
+
+ if (!userSettingsPath.exists()) {
+ if (optionalSettingsPath != null) {
+ File optionalSettingsPathFile = new File(optionalSettingsPath);
+
+ if (optionalSettingsPathFile.exists()) {
+ userSettingsPath = optionalSettingsPathFile;
+ } else {
+ userSettingsPath = defaultUserSettingsFile;
+ }
+ } else {
+ userSettingsPath = defaultUserSettingsFile;
+ }
+ }
+
+ return userSettingsPath;
+ }
+
+ /**
+ * Retrieve the global settings path using the followiwin search pattern:
+ *
+ * 1. System Property
+ * 2. CLI Option
+ * 3. ${maven.home}/conf/settings.xml
+ */
+ public File getGlobalSettingsPath() {
+ File globalSettingsFile = new File(System.getProperty(ALT_GLOBAL_SETTINGS_XML_LOCATION) + "");
+
+ if (!globalSettingsFile.exists()) {
+ globalSettingsFile = defaultGlobalSettingsFile;
+ }
+
+ return globalSettingsFile;
+ }
+
+ /**
+ * Retrieve the local repository path using the followiwin search pattern:
+ *
+ * 1. System Property
+ * 2. localRepository specified in user settings file
+ * 3. ${user.home}/.m2/repository
+ */
+ public String getLocalRepositoryPath(Settings settings) {
+ String localRepositoryPath = System.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);
+
+ if (localRepositoryPath == null) {
+ localRepositoryPath = settings.getLocalRepository();
+ }
+
+ if (localRepositoryPath == null) {
+ localRepositoryPath = defaultUserLocalRepository.getAbsolutePath();
+ }
+
+ return localRepositoryPath;
+ }
+
+ public String getLocalRepositoryPath()
+ throws Exception {
+ return getLocalRepositoryPath(buildSettings(getUserSettingsPath(null),
+ getGlobalSettingsPath(),
+ false,
+ true,
+ false,
+ Boolean.FALSE));
+ }
+
+ public ArtifactRepository getLocalRepository()
+ throws Exception {
+ return createLocalRepository(new File(getLocalRepositoryPath()));
+ }
+}
+
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven21Helper.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven21Helper.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven21Helper.java (revision 0)
@@ -0,0 +1,27 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+public class Maven21Helper implements MavenHelper {
+
+ //private MavenTools tools;
+
+ Maven21Helper(PlexusContainer container) throws ComponentLookupException {
+ //tools = (MavenTools) container.lookup(MavenTools.ROLE);
+ }
+
+ /*public ArtifactRepository getLocalRepository() throws Exception {
+ String localRepositoryPath = tools.getLocalRepositoryPath();
+ return tools.createLocalRepository(new File(localRepositoryPath));
+ }*/
+
+ public ArtifactRepository getLocalRepository() throws Exception {
+ return null;
+ }
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractor.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractor.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractor.java (revision 0)
@@ -0,0 +1,176 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import com.sun.tools.apt.Main;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.factory.DefaultArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Java 1.5+ Annotation-based MojoDescriptorExtractor
+ */
+public class AnnoMojoDescriptorExtractor
+ extends AbstractLogEnabled implements MojoDescriptorExtractor, Contextualizable {
+
+ protected PlexusContainer container;
+
+ private MavenHelper helper;
+
+ public void contextualize(Context context) throws ContextException {
+ container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
+ //Decide which helper to use, depending on the Maven version
+ try {
+ try {
+ Thread.currentThread().getContextClassLoader().loadClass(
+ "org.apache.maven.MavenTools");
+ helper = new Maven21Helper(container);
+ } catch (ClassNotFoundException e) {
+ helper = new Maven20Helper(container);
+ }
+ } catch (ComponentLookupException e) {
+ throw new ContextException("Failed to configure the extractor Maven helper.", e);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public List execute(MavenProject project, PluginDescriptor descriptor)
+ throws InvalidPluginDescriptorException {
+ List sourceRoots = project.getCompileSourceRoots();
+ Set sourcePathElements = new HashSet();
+ String srcRoot = null;
+ try {
+ for (String sourceRoot : sourceRoots) {
+ srcRoot = sourceRoot;
+ List files = FileUtils.getFiles(new File(srcRoot), "**/*.java", null, true);
+ for (File file : files) {
+ String path = file.getPath();
+ sourcePathElements.add(path);
+ }
+ }
+ } catch (Exception e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get source files from " + srcRoot, e);
+ }
+ List argsList = new ArrayList();
+ argsList.add("-nocompile");
+ argsList.add("-cp");
+ StringBuilder cp = new StringBuilder();
+ //Add the compile classpath
+ List compileClasspathElements;
+ try {
+ compileClasspathElements = project.getCompileClasspathElements();
+ } catch (DependencyResolutionRequiredException e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get compileClasspathElements.", e);
+ }
+ for (String ccpe : compileClasspathElements) {
+ cp.append(ccpe);
+ cp.append(File.pathSeparator);
+ }
+ //Resolve dependencies and add them to the classpath
+ resolveDependencies(project, cp);
+ //Add the current CL classptah
+ URL[] urls = ((URLClassLoader) getClass().getClassLoader()).getURLs();
+ for (URL url : urls) {
+ String path;
+ try {
+ path = url.getPath();
+ } catch (Exception e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get classpath files from " + url, e);
+ }
+ cp.append(path);
+ cp.append(File.pathSeparator);
+ }
+ argsList.add(cp.toString());
+ argsList.addAll(sourcePathElements);
+ String[] args = argsList.toArray(new String[argsList.size()]);
+ ArrayList descriptors = new ArrayList();
+ MojoDescriptorTls.setDescriptors(descriptors);
+ try {
+ Main.process(new MojoApf(descriptor), new PrintWriter(System.out), args);
+ } catch (Throwable t) {
+ //TODO: [by yl] This is never caught - apt swallows the exception.
+ //Use the TLS to hold thrown exception
+ throw new InvalidPluginDescriptorException(
+ "Failed to extract plugin descriptor.", t);
+ }
+ return MojoDescriptorTls.getDescriptors();
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private void resolveDependencies(MavenProject project, StringBuilder cp) throws InvalidPluginDescriptorException {
+ if (container == null) {
+ return;
+ }
+ ArtifactResolver resolver;
+ try {
+ resolver = (ArtifactResolver) container.lookup(ArtifactResolver.ROLE);
+ } catch (ComponentLookupException e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get the ArtifactResolver.", e);
+ }
+ ArtifactRepository localRepository;
+ try {
+ localRepository = helper.getLocalRepository();
+ } catch (Exception e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get the local repository.", e);
+ }
+ DefaultArtifactFactory artifactFactory;
+ try {
+ artifactFactory = (DefaultArtifactFactory) container.lookup(ArtifactFactory.ROLE);
+ } catch (ComponentLookupException e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to locate the artifact factory.", e);
+ }
+ List dependencies = project.getDependencies();
+ for (Dependency dependency : dependencies) {
+ String scope = dependency.getScope();
+ if (scope != null && (scope.equals("system") || scope.equals("runtime"))) {
+ continue;
+ }
+ Artifact artifact = artifactFactory.createArtifact(
+ dependency.getGroupId(),
+ dependency.getArtifactId(),
+ dependency.getVersion(),
+ scope,
+ dependency.getType());
+ try {
+ resolver.resolve(artifact, project.getRemoteArtifactRepositories(),
+ localRepository);
+ File file = artifact.getFile();
+ cp.append(file.getCanonicalPath());
+ cp.append(File.pathSeparator);
+ } catch (Exception e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to resolve artifact: " + artifact, e);
+ }
+ }
+ }
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoApf.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoApf.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoApf.java (revision 0)
@@ -0,0 +1,406 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.apt.AnnotationProcessorFactory;
+import com.sun.mirror.declaration.*;
+import com.sun.mirror.type.ClassType;
+import com.sun.mirror.type.InterfaceType;
+import com.sun.mirror.util.DeclarationVisitors;
+import com.sun.mirror.util.SimpleDeclarationVisitor;
+import org.apache.maven.plugin.descriptor.*;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.*;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.*;
+
+class MojoApf implements AnnotationProcessorFactory {
+ //Process any set of annotations
+ private static final Collection supportedAnnotations
+ = Collections.unmodifiableCollection(Arrays.asList(
+ AnnoMojoDescriptorExtractor.class.getPackage().getName() + ".annotations.*"));
+ //No supported options
+ private static final Collection supportedOptions = Collections.emptySet();
+
+ private final PluginDescriptor descriptor;
+
+ public MojoApf(PluginDescriptor descriptor) {
+ this.descriptor = descriptor;
+ }
+
+ public Collection supportedAnnotationTypes() {
+ return supportedAnnotations;
+ }
+
+ public Collection supportedOptions() {
+ return supportedOptions;
+ }
+
+ public AnnotationProcessor getProcessorFor(
+ Set atds, AnnotationProcessorEnvironment env) {
+ return new MojoAp(env);
+ }
+
+ private class MojoAp implements AnnotationProcessor {
+ private final AnnotationProcessorEnvironment env;
+
+ MojoAp(AnnotationProcessorEnvironment env) {
+ this.env = env;
+ }
+
+ public void process() {
+ Collection declarations = env.getSpecifiedTypeDeclarations();
+ for (TypeDeclaration typeDecl : declarations) {
+ try {
+ typeDecl.accept(DeclarationVisitors.getDeclarationScanner(
+ new MojoClassVisitor(), DeclarationVisitors.NO_OP));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private class MojoClassVisitor extends SimpleDeclarationVisitor {
+
+ private MojoDescriptor mojoDescriptor;
+ private Set visitedDeclarations = new HashSet();
+
+ public void visitClassDeclaration(ClassDeclaration d) {
+ //Merge supper classes and interfaces declarations in top down fashion
+ //(actually we're overriding topmost metadata with bottom-most one)
+ Collection modifiers = d.getModifiers();
+ boolean abstarct = false;
+ for (Modifier modifier : modifiers) {
+ if (modifier.equals(Modifier.ABSTRACT)) {
+ abstarct = true;
+ break;
+ }
+ }
+ if (checkVisited(d)) {
+ return;
+ }
+ if (abstarct && mojoDescriptor == null) {
+ return;
+ }
+ // ----------------------------------------------------------------------
+ // Goal flag
+ // ----------------------------------------------------------------------
+ MojoGoal goal = d.getAnnotation(MojoGoal.class);
+ //Do not process classes/interfaces that are non-mojos.
+ //These will be processes later on on the chain if inherited by a mojo.
+ if (goal == null && mojoDescriptor == null) {
+ return;
+ }
+ //Create a new descriptor and set the following only for the concrete mojo
+ if (mojoDescriptor == null) {
+ mojoDescriptor = new MojoDescriptor();
+ mojoDescriptor = new MojoDescriptor();
+ mojoDescriptor.setPluginDescriptor(descriptor);
+ mojoDescriptor.setLanguage("java");
+ mojoDescriptor.setImplementation(d.getQualifiedName());
+ mojoDescriptor.setDescription(d.getDocComment());
+ mojoDescriptor.setGoal(goal.value());
+ MojoDescriptorTls.addDescriptor(mojoDescriptor);
+ }
+ //First visit super classes and interfaces recursively
+ ClassType superclass = d.getSuperclass();
+ if (shouldProcessClass(superclass)) {
+ visitClassDeclaration(superclass.getDeclaration());
+ }
+ Collection superinterfaces = d.getSuperinterfaces();
+ for (InterfaceType superinterface : superinterfaces) {
+ visitInterfaceDeclaration(superinterface.getDeclaration());
+ }
+ //Then process our own metadata and override
+ if (mojoDescriptor != null) {
+ processTypeMetadata(d);
+ }
+ // ----------------------------------------------------------------------
+ // Phase flag
+ // ----------------------------------------------------------------------
+ MojoPhase phase = d.getAnnotation(MojoPhase.class);
+ if (phase != null) {
+ mojoDescriptor.setPhase(phase.value());
+ }
+ //Continue the delegation chain
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ this, DeclarationVisitors.NO_OP));
+ }
+
+ public void visitInterfaceDeclaration(InterfaceDeclaration d) {
+ //Do nothing unless this is called from a concrete type
+ if (checkVisited(d) || mojoDescriptor == null) {
+ return;
+ }
+ Collection superinterfaces = d.getSuperinterfaces();
+ for (InterfaceType superinterface : superinterfaces) {
+ visitInterfaceDeclaration(superinterface.getDeclaration());
+ }
+ processTypeMetadata(d);
+ //Continue the delegation chain
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ this, DeclarationVisitors.NO_OP));
+ }
+
+ public void visitMethodDeclaration(MethodDeclaration d) {
+ if (checkVisited(d) || mojoDescriptor == null) {
+ return;
+ }
+ //Find getters
+ Parameter pd;
+ String propertyName;
+ String propertyType;
+ String methodName = d.getSimpleName();
+ if (methodName.startsWith("get")) {
+ pd = new Parameter();
+ propertyName =
+ methodName.substring(3, 4).toLowerCase() + methodName.substring(4);
+ propertyType = d.getReturnType().toString();
+ processPropertyMetadata(d, pd, propertyType, propertyName);
+ }
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ this, DeclarationVisitors.NO_OP));
+ }
+
+ public void visitFieldDeclaration(FieldDeclaration d) {
+ if (checkVisited(d) || mojoDescriptor == null) {
+ return;
+ }
+ String propertyName = d.getSimpleName();
+ String propertyType = d.getType().toString();
+ Parameter pd = new Parameter();
+ processPropertyMetadata(d, pd, propertyType, propertyName);
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ this, DeclarationVisitors.NO_OP));
+ }
+
+ private void processTypeMetadata(Declaration d) {
+ // ----------------------------------------------------------------------
+ // Instantiation strategy
+ // ----------------------------------------------------------------------
+ MojoInstantiationStrategy instantiationStrategy =
+ d.getAnnotation(MojoInstantiationStrategy.class);
+ if (instantiationStrategy != null) {
+ mojoDescriptor.setInstantiationStrategy(instantiationStrategy.value());
+ }
+ // ----------------------------------------------------------------------
+ // Multi execution
+ // ----------------------------------------------------------------------
+ MojoMultiExecution multiExecution =
+ d.getAnnotation(MojoMultiExecution.class);
+ if (multiExecution != null) {
+ mojoDescriptor.setExecutionStrategy(MojoDescriptor.MULTI_PASS_EXEC_STRATEGY);
+ } else {
+ mojoDescriptor.setExecutionStrategy(MojoDescriptor.SINGLE_PASS_EXEC_STRATEGY);
+ }
+ // ----------------------------------------------------------------------
+ // Configurator hint
+ // ----------------------------------------------------------------------
+ MojoConfigurator configurator = d.getAnnotation(MojoConfigurator.class);
+ if (instantiationStrategy != null) {
+ mojoDescriptor.setComponentConfigurator(configurator.value());
+ }
+ // ----------------------------------------------------------------------
+ // Execute flag
+ // ----------------------------------------------------------------------
+ MojoExecute execute = d.getAnnotation(MojoExecute.class);
+ if (execute != null) {
+ String executePhase = execute.phase();
+ String executeGoal = execute.goal();
+ String lifecycle = execute.lifecycle();
+ //Nullify empty values
+ if (executePhase.length() == 0) {
+ executePhase = null;
+ }
+ if (executeGoal.length() == 0) {
+ executeGoal = null;
+ }
+ if (lifecycle.length() == 0) {
+ lifecycle = null;
+ }
+ if (executePhase == null && executeGoal == null) {
+ throw new IllegalArgumentException(
+ "Eexecute tag requires a 'phase' or 'goal' parameter");
+ } else if (executePhase != null && executeGoal != null) {
+ throw new IllegalArgumentException(
+ "@Execute tag can have only one of a 'phase' or 'goal' parameter");
+ }
+ mojoDescriptor.setExecutePhase(executePhase);
+ mojoDescriptor.setExecuteGoal(executeGoal);
+
+ if (lifecycle != null) {
+ mojoDescriptor.setExecuteLifecycle(lifecycle);
+ if (executeGoal != null) {
+ throw new IllegalArgumentException(
+ "@Execute lifecycle requires a phase instead of a goal");
+ }
+ }
+ }
+ // ----------------------------------------------------------------------
+ // Dependency flag
+ // ----------------------------------------------------------------------
+ MojoRequiresDependencyResolution requiresDependencyResolution =
+ d.getAnnotation(MojoRequiresDependencyResolution.class);
+ if (requiresDependencyResolution != null) {
+ String value = requiresDependencyResolution.value();
+ mojoDescriptor.setDependencyResolutionRequired(value);
+ }
+ // ----------------------------------------------------------------------
+ // Project flag
+ // ----------------------------------------------------------------------
+ MojoRequiresProject requiresProject = d.getAnnotation(MojoRequiresProject.class);
+ if (requiresProject != null) {
+ mojoDescriptor.setProjectRequired(true);
+ } else {
+ mojoDescriptor.setProjectRequired(mojoDescriptor.isProjectRequired());
+ }
+ // ----------------------------------------------------------------------
+ // Aggregator flag
+ // ----------------------------------------------------------------------
+ MojoAggregator aggregator = d.getAnnotation(MojoAggregator.class);
+ if (aggregator != null) {
+ mojoDescriptor.setAggregator(true);
+ }
+ // ----------------------------------------------------------------------
+ // requiresDirectInvocation flag
+ // ----------------------------------------------------------------------
+ MojoRequiresDirectInvocation requiresDirectInvocation =
+ d.getAnnotation(MojoRequiresDirectInvocation.class);
+ if (requiresDirectInvocation != null) {
+ mojoDescriptor.setDirectInvocationOnly(true);
+ } else {
+ mojoDescriptor.setDirectInvocationOnly(mojoDescriptor.isDirectInvocationOnly());
+ }
+ // ----------------------------------------------------------------------
+ // Online flag
+ // ----------------------------------------------------------------------
+ MojoRequiresOnline requiresOnline = d.getAnnotation(MojoRequiresOnline.class);
+ if (requiresOnline != null) {
+ mojoDescriptor.setOnlineRequired(true);
+ } else {
+ mojoDescriptor.setOnlineRequired(mojoDescriptor.isOnlineRequired());
+ }
+ // ----------------------------------------------------------------------
+ // inheritByDefault flag
+ // ----------------------------------------------------------------------
+ MojoInheritedByDefault inheritedByDefault =
+ d.getAnnotation(MojoInheritedByDefault.class);
+ if (inheritedByDefault != null) {
+ mojoDescriptor.setInheritedByDefault(true);
+ } else {
+ mojoDescriptor.setInheritedByDefault(mojoDescriptor.isInheritedByDefault());
+ }
+ }
+
+ private void processPropertyMetadata(
+ MemberDeclaration d, Parameter pd, String propertyType, String propertyName) {
+ MojoParameter parameter = d.getAnnotation(MojoParameter.class);
+ MojoComponent component = d.getAnnotation(MojoComponent.class);
+ if (parameter != null || component != null) {
+ pd.setName(propertyName);
+ pd.setType(propertyType);
+ } else {
+ return;
+ }
+ if (component != null) {
+ String description = component.description();
+ if (StringUtils.isEmpty(description)) {
+ description = d.getDocComment();
+ }
+ pd.setDescription(description);
+ String role = component.role();
+ if (role.length() == 0) {
+ role = propertyType;
+ }
+ String roleHint = component.roleHint();
+ if (roleHint.length() == 0) {
+ roleHint = null;
+ }
+ pd.setRequirement(new Requirement(role, roleHint));
+ pd.setName(propertyName);
+ } else {
+ String description = parameter.description();
+ if (StringUtils.isEmpty(description)) {
+ description = d.getDocComment();
+ }
+ pd.setDescription(description);
+ String property = parameter.property();
+ if (!StringUtils.isEmpty(property)) {
+ pd.setName(property);
+ } else {
+ pd.setName(propertyName);
+ }
+ pd.setRequired(parameter.required());
+ pd.setEditable(!parameter.readonly());
+ String deprecated = parameter.deprecated();
+ if (!StringUtils.isEmpty(deprecated)) {
+ pd.setDeprecated(deprecated);
+ }
+ String alias = parameter.alias();
+ if (!StringUtils.isEmpty(alias)) {
+ pd.setAlias(alias);
+ }
+ String expression = parameter.expression();
+ if (StringUtils.isEmpty(expression)) {
+ expression = null;
+ }
+ pd.setExpression(expression);
+ if ("${reports}".equals(pd.getExpression())) {
+ mojoDescriptor.setRequiresReports(true);
+ }
+ String defaultValue = parameter.defaultValue();
+ if (!StringUtils.isEmpty(defaultValue)) {
+ pd.setDefaultValue(defaultValue);
+ }
+ }
+ try {
+ mojoDescriptor.addParameter(pd);
+ } catch (DuplicateParameterException e) {
+ throw new IllegalArgumentException(
+ "DuplicateParameter parameter: " + propertyName);
+ }
+ }
+
+ @SuppressWarnings({"UNUSED_SYMBOL"})
+ private boolean isMojo(TypeDeclaration d) {
+ Collection superinterfaces = d.getSuperinterfaces();
+ for (InterfaceType superinterface : superinterfaces) {
+ if (superinterface.getDeclaration().getQualifiedName().equals(
+ "org.apache.maven.plugin.Mojo")) {
+ return true;
+ } else {
+ if (isMojo(superinterface.getDeclaration())) {
+ return true;
+ }
+ }
+ }
+ //Check in super classes
+ if (d instanceof ClassDeclaration) {
+ ClassType superclass = ((ClassDeclaration) d).getSuperclass();
+ if (shouldProcessClass(superclass)) {
+ if (isMojo(superclass.getDeclaration())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean shouldProcessClass(ClassType superclass) {
+ return superclass != null && (!superclass.getDeclaration().getQualifiedName()
+ .equals("java.lang.Object"));
+ }
+
+ private boolean checkVisited(Declaration d) {
+ if (visitedDeclarations.contains(d)) {
+ return true;
+ } else {
+ if (mojoDescriptor != null) {
+ visitedDeclarations.add(d);
+ }
+ return false;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractor.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractor.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractor.java (revision 0)
@@ -0,0 +1,176 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import com.sun.tools.apt.Main;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.factory.DefaultArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Java 1.5+ Annotation-based MojoDescriptorExtractor
+ */
+public class AnnoMojoDescriptorExtractor
+ extends AbstractLogEnabled implements MojoDescriptorExtractor, Contextualizable {
+
+ protected PlexusContainer container;
+
+ private MavenHelper helper;
+
+ public void contextualize(Context context) throws ContextException {
+ container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
+ //Decide which helper to use, depending on the Maven version
+ try {
+ try {
+ Thread.currentThread().getContextClassLoader().loadClass(
+ "org.apache.maven.MavenTools");
+ helper = new Maven21Helper(container);
+ } catch (ClassNotFoundException e) {
+ helper = new Maven20Helper(container);
+ }
+ } catch (ComponentLookupException e) {
+ throw new ContextException("Failed to configure the extractor Maven helper.", e);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public List execute(MavenProject project, PluginDescriptor descriptor)
+ throws InvalidPluginDescriptorException {
+ List sourceRoots = project.getCompileSourceRoots();
+ Set sourcePathElements = new HashSet();
+ String srcRoot = null;
+ try {
+ for (String sourceRoot : sourceRoots) {
+ srcRoot = sourceRoot;
+ List files = FileUtils.getFiles(new File(srcRoot), "**/*.java", null, true);
+ for (File file : files) {
+ String path = file.getPath();
+ sourcePathElements.add(path);
+ }
+ }
+ } catch (Exception e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get source files from " + srcRoot, e);
+ }
+ List argsList = new ArrayList();
+ argsList.add("-nocompile");
+ argsList.add("-cp");
+ StringBuilder cp = new StringBuilder();
+ //Add the compile classpath
+ List compileClasspathElements;
+ try {
+ compileClasspathElements = project.getCompileClasspathElements();
+ } catch (DependencyResolutionRequiredException e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get compileClasspathElements.", e);
+ }
+ for (String ccpe : compileClasspathElements) {
+ cp.append(ccpe);
+ cp.append(File.pathSeparator);
+ }
+ //Resolve dependencies and add them to the classpath
+ resolveDependencies(project, cp);
+ //Add the current CL classptah
+ URL[] urls = ((URLClassLoader) getClass().getClassLoader()).getURLs();
+ for (URL url : urls) {
+ String path;
+ try {
+ path = url.getPath();
+ } catch (Exception e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get classpath files from " + url, e);
+ }
+ cp.append(path);
+ cp.append(File.pathSeparator);
+ }
+ argsList.add(cp.toString());
+ argsList.addAll(sourcePathElements);
+ String[] args = argsList.toArray(new String[argsList.size()]);
+ ArrayList descriptors = new ArrayList();
+ MojoDescriptorTls.setDescriptors(descriptors);
+ try {
+ Main.process(new MojoApf(descriptor), new PrintWriter(System.out), args);
+ } catch (Throwable t) {
+ //TODO: [by yl] This is never caught - apt swallows the exception.
+ //Use the TLS to hold thrown exception
+ throw new InvalidPluginDescriptorException(
+ "Failed to extract plugin descriptor.", t);
+ }
+ return MojoDescriptorTls.getDescriptors();
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private void resolveDependencies(MavenProject project, StringBuilder cp) throws InvalidPluginDescriptorException {
+ if (container == null) {
+ return;
+ }
+ ArtifactResolver resolver;
+ try {
+ resolver = (ArtifactResolver) container.lookup(ArtifactResolver.ROLE);
+ } catch (ComponentLookupException e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get the ArtifactResolver.", e);
+ }
+ ArtifactRepository localRepository;
+ try {
+ localRepository = helper.getLocalRepository();
+ } catch (Exception e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to get the local repository.", e);
+ }
+ DefaultArtifactFactory artifactFactory;
+ try {
+ artifactFactory = (DefaultArtifactFactory) container.lookup(ArtifactFactory.ROLE);
+ } catch (ComponentLookupException e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to locate the artifact factory.", e);
+ }
+ List dependencies = project.getDependencies();
+ for (Dependency dependency : dependencies) {
+ String scope = dependency.getScope();
+ if (scope != null && (scope.equals("system") || scope.equals("runtime"))) {
+ continue;
+ }
+ Artifact artifact = artifactFactory.createArtifact(
+ dependency.getGroupId(),
+ dependency.getArtifactId(),
+ dependency.getVersion(),
+ scope,
+ dependency.getType());
+ try {
+ resolver.resolve(artifact, project.getRemoteArtifactRepositories(),
+ localRepository);
+ File file = artifact.getFile();
+ cp.append(file.getCanonicalPath());
+ cp.append(File.pathSeparator);
+ } catch (Exception e) {
+ throw new InvalidPluginDescriptorException(
+ "Failed to resolve artifact: " + artifact, e);
+ }
+ }
+ }
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAnnotation.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAnnotation.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAnnotation.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * . User: yoavl
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface MojoAnnotation {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInheritedByDefault.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInheritedByDefault.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInheritedByDefault.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoInheritedByDefault {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoMultiExecution.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoMultiExecution.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoMultiExecution.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoMultiExecution {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoParameter.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoParameter.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoParameter.java (revision 0)
@@ -0,0 +1,29 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Inherited
+public @interface MojoParameter {
+ String description() default "";
+
+ String property() default "";
+
+ boolean required() default false;
+
+ boolean readonly() default false;
+
+ String deprecated() default "";
+
+ String alias() default "";
+
+ String expression() default "";
+
+ String defaultValue() default "";
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAggregator.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAggregator.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAggregator.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoAggregator {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoGoal.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoGoal.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoGoal.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoGoal {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDependencyResolution.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDependencyResolution.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDependencyResolution.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoRequiresDependencyResolution {
+ String value() default "runtime";
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDirectInvocation.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDirectInvocation.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDirectInvocation.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoRequiresDirectInvocation {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresProject.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresProject.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresProject.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoRequiresProject {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoPhase.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoPhase.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoPhase.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoPhase {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoComponent.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoComponent.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoComponent.java (revision 0)
@@ -0,0 +1,17 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Inherited
+public @interface MojoComponent {
+ String description() default "";
+ String role() default "";
+ String roleHint() default "";
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoConfigurator.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoConfigurator.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoConfigurator.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoConfigurator {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoExecute.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoExecute.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoExecute.java (revision 0)
@@ -0,0 +1,17 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoExecute {
+ String phase() default "";
+ String goal() default "";
+ String lifecycle() default "";
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresOnline.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresOnline.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresOnline.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoRequiresOnline {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInstantiationStrategy.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInstantiationStrategy.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInstantiationStrategy.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoInstantiationStrategy {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAggregator.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAggregator.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAggregator.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoAggregator {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAnnotation.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAnnotation.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoAnnotation.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * . User: yoavl
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface MojoAnnotation {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoComponent.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoComponent.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoComponent.java (revision 0)
@@ -0,0 +1,17 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Inherited
+public @interface MojoComponent {
+ String description() default "";
+ String role() default "";
+ String roleHint() default "";
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoConfigurator.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoConfigurator.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoConfigurator.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoConfigurator {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoExecute.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoExecute.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoExecute.java (revision 0)
@@ -0,0 +1,17 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoExecute {
+ String phase() default "";
+ String goal() default "";
+ String lifecycle() default "";
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoGoal.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoGoal.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoGoal.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoGoal {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInheritedByDefault.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInheritedByDefault.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInheritedByDefault.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoInheritedByDefault {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInstantiationStrategy.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInstantiationStrategy.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoInstantiationStrategy.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoInstantiationStrategy {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoMultiExecution.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoMultiExecution.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoMultiExecution.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoMultiExecution {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoParameter.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoParameter.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoParameter.java (revision 0)
@@ -0,0 +1,29 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Inherited
+public @interface MojoParameter {
+ String description() default "";
+
+ String property() default "";
+
+ boolean required() default false;
+
+ boolean readonly() default false;
+
+ String deprecated() default "";
+
+ String alias() default "";
+
+ String expression() default "";
+
+ String defaultValue() default "";
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoPhase.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoPhase.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoPhase.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoPhase {
+ String value();
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDependencyResolution.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDependencyResolution.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDependencyResolution.java (revision 0)
@@ -0,0 +1,15 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoRequiresDependencyResolution {
+ String value() default "runtime";
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDirectInvocation.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDirectInvocation.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresDirectInvocation.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoRequiresDirectInvocation {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresOnline.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresOnline.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresOnline.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoRequiresOnline {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresProject.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresProject.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/annotations/MojoRequiresProject.java (revision 0)
@@ -0,0 +1,14 @@
+package org.apache.maven.tools.plugin.extractor.anno.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ *
+ * . User: yoavl
+ */
+@MojoAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Inherited
+public @interface MojoRequiresProject {
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven20Helper.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven20Helper.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven20Helper.java (revision 0)
@@ -0,0 +1,232 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.settings.MavenSettingsBuilder;
+import org.apache.maven.settings.RuntimeInfo;
+import org.apache.maven.settings.Settings;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author Jason van Zyl
+ */
+public class Maven20Helper implements MavenHelper {
+
+ private static final String userHome = System.getProperty("user.home");
+
+ private static final File userMavenConfigurationHome = new File(userHome, ".m2");
+
+ private static final String mavenHome = System.getProperty("maven.home");
+
+ // ----------------------------------------------------------------------
+ // Settings
+ // ----------------------------------------------------------------------
+
+ private static final File defaultUserSettingsFile = new File(userMavenConfigurationHome, "settings.xml");
+
+ private static final File defaultGlobalSettingsFile = new File(mavenHome, "conf/settings.xml");
+
+ private static final String ALT_USER_SETTINGS_XML_LOCATION = "org.apache.maven.user-settings";
+
+ private static final String ALT_GLOBAL_SETTINGS_XML_LOCATION = "org.apache.maven.global-settings";
+
+ // ----------------------------------------------------------------------
+ // Local Repository
+ // ----------------------------------------------------------------------
+
+ String ALT_LOCAL_REPOSITORY_LOCATION = "maven.repo.local";
+
+ File defaultUserLocalRepository = new File(userMavenConfigurationHome, "repository");
+
+ private ArtifactRepositoryLayout repositoryLayout;
+
+ private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+ private MavenSettingsBuilder settingsBuilder;
+
+ Maven20Helper(PlexusContainer container) throws ComponentLookupException {
+ repositoryLayout =
+ (ArtifactRepositoryLayout) container.lookup(ArtifactRepositoryLayout.ROLE);
+ artifactRepositoryFactory =
+ (ArtifactRepositoryFactory) container.lookup(ArtifactRepositoryFactory.ROLE);
+ settingsBuilder =
+ (MavenSettingsBuilder) container.lookup(MavenSettingsBuilder.ROLE);
+ }
+
+ // ----------------------------------------------------------------------------
+ // ArtifactRepository
+ // ----------------------------------------------------------------------------
+
+ public ArtifactRepository createLocalRepository(File directory) {
+ String localRepositoryUrl = directory.getAbsolutePath();
+
+ if (!localRepositoryUrl.startsWith("file:")) {
+ localRepositoryUrl = "file://" + localRepositoryUrl;
+ }
+
+ return createRepository("local", localRepositoryUrl, false, true, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
+ }
+
+ public ArtifactRepository createRepository(String repositoryId,
+ String repositoryUrl,
+ boolean offline,
+ boolean updateSnapshots,
+ String globalChecksumPolicy) {
+ ArtifactRepository localRepository =
+ new DefaultArtifactRepository(repositoryId, repositoryUrl, repositoryLayout);
+
+ boolean snapshotPolicySet = false;
+
+ if (offline) {
+ snapshotPolicySet = true;
+ }
+
+ if (!snapshotPolicySet && updateSnapshots) {
+ artifactRepositoryFactory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
+ }
+
+ artifactRepositoryFactory.setGlobalChecksumPolicy(globalChecksumPolicy);
+
+ return localRepository;
+ }
+
+ // ----------------------------------------------------------------------------
+ // Settings
+ // ----------------------------------------------------------------------------
+
+ public Settings buildSettings(File userSettingsPath,
+ File globalSettingsPath,
+ boolean interactive,
+ boolean offline,
+ boolean usePluginRegistry,
+ Boolean pluginUpdateOverride)
+ throws Exception {
+ Settings settings = buildSettings(userSettingsPath,
+ globalSettingsPath,
+ pluginUpdateOverride);
+ if (offline) {
+ settings.setOffline(true);
+ }
+
+ settings.setInteractiveMode(interactive);
+
+ settings.setUsePluginRegistry(usePluginRegistry);
+
+ return settings;
+ }
+
+ public Settings buildSettings(File userSettingsPath,
+ File globalSettingsPath,
+ Boolean pluginUpdateOverride)
+ throws Exception {
+ Settings settings;
+
+ try {
+ settings = settingsBuilder.buildSettings(userSettingsPath);
+ }
+ catch (IOException e) {
+ throw new Exception("Error reading settings file", e);
+ }
+ catch (XmlPullParserException e) {
+ throw new Exception(e.getMessage() + e.getDetail() + e.getLineNumber() +
+ e.getColumnNumber());
+ }
+
+ RuntimeInfo runtimeInfo = new RuntimeInfo(settings);
+
+ runtimeInfo.setPluginUpdateOverride(pluginUpdateOverride);
+
+ settings.setRuntimeInfo(runtimeInfo);
+
+ return settings;
+ }
+
+ /**
+ * Retrieve the user settings path using the followiwin search pattern:
+ *
+ * 1. System Property
+ * 2. Optional path
+ * 3. ${user.home}/.m2/settings.xml
+ */
+ public File getUserSettingsPath(String optionalSettingsPath) {
+ File userSettingsPath = new File(System.getProperty(ALT_USER_SETTINGS_XML_LOCATION) + "");
+
+ if (!userSettingsPath.exists()) {
+ if (optionalSettingsPath != null) {
+ File optionalSettingsPathFile = new File(optionalSettingsPath);
+
+ if (optionalSettingsPathFile.exists()) {
+ userSettingsPath = optionalSettingsPathFile;
+ } else {
+ userSettingsPath = defaultUserSettingsFile;
+ }
+ } else {
+ userSettingsPath = defaultUserSettingsFile;
+ }
+ }
+
+ return userSettingsPath;
+ }
+
+ /**
+ * Retrieve the global settings path using the followiwin search pattern:
+ *
+ * 1. System Property
+ * 2. CLI Option
+ * 3. ${maven.home}/conf/settings.xml
+ */
+ public File getGlobalSettingsPath() {
+ File globalSettingsFile = new File(System.getProperty(ALT_GLOBAL_SETTINGS_XML_LOCATION) + "");
+
+ if (!globalSettingsFile.exists()) {
+ globalSettingsFile = defaultGlobalSettingsFile;
+ }
+
+ return globalSettingsFile;
+ }
+
+ /**
+ * Retrieve the local repository path using the followiwin search pattern:
+ *
+ * 1. System Property
+ * 2. localRepository specified in user settings file
+ * 3. ${user.home}/.m2/repository
+ */
+ public String getLocalRepositoryPath(Settings settings) {
+ String localRepositoryPath = System.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);
+
+ if (localRepositoryPath == null) {
+ localRepositoryPath = settings.getLocalRepository();
+ }
+
+ if (localRepositoryPath == null) {
+ localRepositoryPath = defaultUserLocalRepository.getAbsolutePath();
+ }
+
+ return localRepositoryPath;
+ }
+
+ public String getLocalRepositoryPath()
+ throws Exception {
+ return getLocalRepositoryPath(buildSettings(getUserSettingsPath(null),
+ getGlobalSettingsPath(),
+ false,
+ true,
+ false,
+ Boolean.FALSE));
+ }
+
+ public ArtifactRepository getLocalRepository()
+ throws Exception {
+ return createLocalRepository(new File(getLocalRepositoryPath()));
+ }
+}
+
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven21Helper.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven21Helper.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/Maven21Helper.java (revision 0)
@@ -0,0 +1,27 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+public class Maven21Helper implements MavenHelper {
+
+ //private MavenTools tools;
+
+ Maven21Helper(PlexusContainer container) throws ComponentLookupException {
+ //tools = (MavenTools) container.lookup(MavenTools.ROLE);
+ }
+
+ /*public ArtifactRepository getLocalRepository() throws Exception {
+ String localRepositoryPath = tools.getLocalRepositoryPath();
+ return tools.createLocalRepository(new File(localRepositoryPath));
+ }*/
+
+ public ArtifactRepository getLocalRepository() throws Exception {
+ return null;
+ }
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MavenHelper.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MavenHelper.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MavenHelper.java (revision 0)
@@ -0,0 +1,11 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+public interface MavenHelper {
+ ArtifactRepository getLocalRepository() throws Exception;
+}
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoApf.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoApf.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoApf.java (revision 0)
@@ -0,0 +1,406 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.apt.AnnotationProcessorFactory;
+import com.sun.mirror.declaration.*;
+import com.sun.mirror.type.ClassType;
+import com.sun.mirror.type.InterfaceType;
+import com.sun.mirror.util.DeclarationVisitors;
+import com.sun.mirror.util.SimpleDeclarationVisitor;
+import org.apache.maven.plugin.descriptor.*;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.*;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.*;
+
+class MojoApf implements AnnotationProcessorFactory {
+ //Process any set of annotations
+ private static final Collection supportedAnnotations
+ = Collections.unmodifiableCollection(Arrays.asList(
+ AnnoMojoDescriptorExtractor.class.getPackage().getName() + ".annotations.*"));
+ //No supported options
+ private static final Collection supportedOptions = Collections.emptySet();
+
+ private final PluginDescriptor descriptor;
+
+ public MojoApf(PluginDescriptor descriptor) {
+ this.descriptor = descriptor;
+ }
+
+ public Collection supportedAnnotationTypes() {
+ return supportedAnnotations;
+ }
+
+ public Collection supportedOptions() {
+ return supportedOptions;
+ }
+
+ public AnnotationProcessor getProcessorFor(
+ Set atds, AnnotationProcessorEnvironment env) {
+ return new MojoAp(env);
+ }
+
+ private class MojoAp implements AnnotationProcessor {
+ private final AnnotationProcessorEnvironment env;
+
+ MojoAp(AnnotationProcessorEnvironment env) {
+ this.env = env;
+ }
+
+ public void process() {
+ Collection declarations = env.getSpecifiedTypeDeclarations();
+ for (TypeDeclaration typeDecl : declarations) {
+ try {
+ typeDecl.accept(DeclarationVisitors.getDeclarationScanner(
+ new MojoClassVisitor(), DeclarationVisitors.NO_OP));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private class MojoClassVisitor extends SimpleDeclarationVisitor {
+
+ private MojoDescriptor mojoDescriptor;
+ private Set visitedDeclarations = new HashSet();
+
+ public void visitClassDeclaration(ClassDeclaration d) {
+ //Merge supper classes and interfaces declarations in top down fashion
+ //(actually we're overriding topmost metadata with bottom-most one)
+ Collection modifiers = d.getModifiers();
+ boolean abstarct = false;
+ for (Modifier modifier : modifiers) {
+ if (modifier.equals(Modifier.ABSTRACT)) {
+ abstarct = true;
+ break;
+ }
+ }
+ if (checkVisited(d)) {
+ return;
+ }
+ if (abstarct && mojoDescriptor == null) {
+ return;
+ }
+ // ----------------------------------------------------------------------
+ // Goal flag
+ // ----------------------------------------------------------------------
+ MojoGoal goal = d.getAnnotation(MojoGoal.class);
+ //Do not process classes/interfaces that are non-mojos.
+ //These will be processes later on on the chain if inherited by a mojo.
+ if (goal == null && mojoDescriptor == null) {
+ return;
+ }
+ //Create a new descriptor and set the following only for the concrete mojo
+ if (mojoDescriptor == null) {
+ mojoDescriptor = new MojoDescriptor();
+ mojoDescriptor = new MojoDescriptor();
+ mojoDescriptor.setPluginDescriptor(descriptor);
+ mojoDescriptor.setLanguage("java");
+ mojoDescriptor.setImplementation(d.getQualifiedName());
+ mojoDescriptor.setDescription(d.getDocComment());
+ mojoDescriptor.setGoal(goal.value());
+ MojoDescriptorTls.addDescriptor(mojoDescriptor);
+ }
+ //First visit super classes and interfaces recursively
+ ClassType superclass = d.getSuperclass();
+ if (shouldProcessClass(superclass)) {
+ visitClassDeclaration(superclass.getDeclaration());
+ }
+ Collection superinterfaces = d.getSuperinterfaces();
+ for (InterfaceType superinterface : superinterfaces) {
+ visitInterfaceDeclaration(superinterface.getDeclaration());
+ }
+ //Then process our own metadata and override
+ if (mojoDescriptor != null) {
+ processTypeMetadata(d);
+ }
+ // ----------------------------------------------------------------------
+ // Phase flag
+ // ----------------------------------------------------------------------
+ MojoPhase phase = d.getAnnotation(MojoPhase.class);
+ if (phase != null) {
+ mojoDescriptor.setPhase(phase.value());
+ }
+ //Continue the delegation chain
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ this, DeclarationVisitors.NO_OP));
+ }
+
+ public void visitInterfaceDeclaration(InterfaceDeclaration d) {
+ //Do nothing unless this is called from a concrete type
+ if (checkVisited(d) || mojoDescriptor == null) {
+ return;
+ }
+ Collection superinterfaces = d.getSuperinterfaces();
+ for (InterfaceType superinterface : superinterfaces) {
+ visitInterfaceDeclaration(superinterface.getDeclaration());
+ }
+ processTypeMetadata(d);
+ //Continue the delegation chain
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ this, DeclarationVisitors.NO_OP));
+ }
+
+ public void visitMethodDeclaration(MethodDeclaration d) {
+ if (checkVisited(d) || mojoDescriptor == null) {
+ return;
+ }
+ //Find getters
+ Parameter pd;
+ String propertyName;
+ String propertyType;
+ String methodName = d.getSimpleName();
+ if (methodName.startsWith("get")) {
+ pd = new Parameter();
+ propertyName =
+ methodName.substring(3, 4).toLowerCase() + methodName.substring(4);
+ propertyType = d.getReturnType().toString();
+ processPropertyMetadata(d, pd, propertyType, propertyName);
+ }
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ this, DeclarationVisitors.NO_OP));
+ }
+
+ public void visitFieldDeclaration(FieldDeclaration d) {
+ if (checkVisited(d) || mojoDescriptor == null) {
+ return;
+ }
+ String propertyName = d.getSimpleName();
+ String propertyType = d.getType().toString();
+ Parameter pd = new Parameter();
+ processPropertyMetadata(d, pd, propertyType, propertyName);
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ this, DeclarationVisitors.NO_OP));
+ }
+
+ private void processTypeMetadata(Declaration d) {
+ // ----------------------------------------------------------------------
+ // Instantiation strategy
+ // ----------------------------------------------------------------------
+ MojoInstantiationStrategy instantiationStrategy =
+ d.getAnnotation(MojoInstantiationStrategy.class);
+ if (instantiationStrategy != null) {
+ mojoDescriptor.setInstantiationStrategy(instantiationStrategy.value());
+ }
+ // ----------------------------------------------------------------------
+ // Multi execution
+ // ----------------------------------------------------------------------
+ MojoMultiExecution multiExecution =
+ d.getAnnotation(MojoMultiExecution.class);
+ if (multiExecution != null) {
+ mojoDescriptor.setExecutionStrategy(MojoDescriptor.MULTI_PASS_EXEC_STRATEGY);
+ } else {
+ mojoDescriptor.setExecutionStrategy(MojoDescriptor.SINGLE_PASS_EXEC_STRATEGY);
+ }
+ // ----------------------------------------------------------------------
+ // Configurator hint
+ // ----------------------------------------------------------------------
+ MojoConfigurator configurator = d.getAnnotation(MojoConfigurator.class);
+ if (instantiationStrategy != null) {
+ mojoDescriptor.setComponentConfigurator(configurator.value());
+ }
+ // ----------------------------------------------------------------------
+ // Execute flag
+ // ----------------------------------------------------------------------
+ MojoExecute execute = d.getAnnotation(MojoExecute.class);
+ if (execute != null) {
+ String executePhase = execute.phase();
+ String executeGoal = execute.goal();
+ String lifecycle = execute.lifecycle();
+ //Nullify empty values
+ if (executePhase.length() == 0) {
+ executePhase = null;
+ }
+ if (executeGoal.length() == 0) {
+ executeGoal = null;
+ }
+ if (lifecycle.length() == 0) {
+ lifecycle = null;
+ }
+ if (executePhase == null && executeGoal == null) {
+ throw new IllegalArgumentException(
+ "Eexecute tag requires a 'phase' or 'goal' parameter");
+ } else if (executePhase != null && executeGoal != null) {
+ throw new IllegalArgumentException(
+ "@Execute tag can have only one of a 'phase' or 'goal' parameter");
+ }
+ mojoDescriptor.setExecutePhase(executePhase);
+ mojoDescriptor.setExecuteGoal(executeGoal);
+
+ if (lifecycle != null) {
+ mojoDescriptor.setExecuteLifecycle(lifecycle);
+ if (executeGoal != null) {
+ throw new IllegalArgumentException(
+ "@Execute lifecycle requires a phase instead of a goal");
+ }
+ }
+ }
+ // ----------------------------------------------------------------------
+ // Dependency flag
+ // ----------------------------------------------------------------------
+ MojoRequiresDependencyResolution requiresDependencyResolution =
+ d.getAnnotation(MojoRequiresDependencyResolution.class);
+ if (requiresDependencyResolution != null) {
+ String value = requiresDependencyResolution.value();
+ mojoDescriptor.setDependencyResolutionRequired(value);
+ }
+ // ----------------------------------------------------------------------
+ // Project flag
+ // ----------------------------------------------------------------------
+ MojoRequiresProject requiresProject = d.getAnnotation(MojoRequiresProject.class);
+ if (requiresProject != null) {
+ mojoDescriptor.setProjectRequired(true);
+ } else {
+ mojoDescriptor.setProjectRequired(mojoDescriptor.isProjectRequired());
+ }
+ // ----------------------------------------------------------------------
+ // Aggregator flag
+ // ----------------------------------------------------------------------
+ MojoAggregator aggregator = d.getAnnotation(MojoAggregator.class);
+ if (aggregator != null) {
+ mojoDescriptor.setAggregator(true);
+ }
+ // ----------------------------------------------------------------------
+ // requiresDirectInvocation flag
+ // ----------------------------------------------------------------------
+ MojoRequiresDirectInvocation requiresDirectInvocation =
+ d.getAnnotation(MojoRequiresDirectInvocation.class);
+ if (requiresDirectInvocation != null) {
+ mojoDescriptor.setDirectInvocationOnly(true);
+ } else {
+ mojoDescriptor.setDirectInvocationOnly(mojoDescriptor.isDirectInvocationOnly());
+ }
+ // ----------------------------------------------------------------------
+ // Online flag
+ // ----------------------------------------------------------------------
+ MojoRequiresOnline requiresOnline = d.getAnnotation(MojoRequiresOnline.class);
+ if (requiresOnline != null) {
+ mojoDescriptor.setOnlineRequired(true);
+ } else {
+ mojoDescriptor.setOnlineRequired(mojoDescriptor.isOnlineRequired());
+ }
+ // ----------------------------------------------------------------------
+ // inheritByDefault flag
+ // ----------------------------------------------------------------------
+ MojoInheritedByDefault inheritedByDefault =
+ d.getAnnotation(MojoInheritedByDefault.class);
+ if (inheritedByDefault != null) {
+ mojoDescriptor.setInheritedByDefault(true);
+ } else {
+ mojoDescriptor.setInheritedByDefault(mojoDescriptor.isInheritedByDefault());
+ }
+ }
+
+ private void processPropertyMetadata(
+ MemberDeclaration d, Parameter pd, String propertyType, String propertyName) {
+ MojoParameter parameter = d.getAnnotation(MojoParameter.class);
+ MojoComponent component = d.getAnnotation(MojoComponent.class);
+ if (parameter != null || component != null) {
+ pd.setName(propertyName);
+ pd.setType(propertyType);
+ } else {
+ return;
+ }
+ if (component != null) {
+ String description = component.description();
+ if (StringUtils.isEmpty(description)) {
+ description = d.getDocComment();
+ }
+ pd.setDescription(description);
+ String role = component.role();
+ if (role.length() == 0) {
+ role = propertyType;
+ }
+ String roleHint = component.roleHint();
+ if (roleHint.length() == 0) {
+ roleHint = null;
+ }
+ pd.setRequirement(new Requirement(role, roleHint));
+ pd.setName(propertyName);
+ } else {
+ String description = parameter.description();
+ if (StringUtils.isEmpty(description)) {
+ description = d.getDocComment();
+ }
+ pd.setDescription(description);
+ String property = parameter.property();
+ if (!StringUtils.isEmpty(property)) {
+ pd.setName(property);
+ } else {
+ pd.setName(propertyName);
+ }
+ pd.setRequired(parameter.required());
+ pd.setEditable(!parameter.readonly());
+ String deprecated = parameter.deprecated();
+ if (!StringUtils.isEmpty(deprecated)) {
+ pd.setDeprecated(deprecated);
+ }
+ String alias = parameter.alias();
+ if (!StringUtils.isEmpty(alias)) {
+ pd.setAlias(alias);
+ }
+ String expression = parameter.expression();
+ if (StringUtils.isEmpty(expression)) {
+ expression = null;
+ }
+ pd.setExpression(expression);
+ if ("${reports}".equals(pd.getExpression())) {
+ mojoDescriptor.setRequiresReports(true);
+ }
+ String defaultValue = parameter.defaultValue();
+ if (!StringUtils.isEmpty(defaultValue)) {
+ pd.setDefaultValue(defaultValue);
+ }
+ }
+ try {
+ mojoDescriptor.addParameter(pd);
+ } catch (DuplicateParameterException e) {
+ throw new IllegalArgumentException(
+ "DuplicateParameter parameter: " + propertyName);
+ }
+ }
+
+ @SuppressWarnings({"UNUSED_SYMBOL"})
+ private boolean isMojo(TypeDeclaration d) {
+ Collection superinterfaces = d.getSuperinterfaces();
+ for (InterfaceType superinterface : superinterfaces) {
+ if (superinterface.getDeclaration().getQualifiedName().equals(
+ "org.apache.maven.plugin.Mojo")) {
+ return true;
+ } else {
+ if (isMojo(superinterface.getDeclaration())) {
+ return true;
+ }
+ }
+ }
+ //Check in super classes
+ if (d instanceof ClassDeclaration) {
+ ClassType superclass = ((ClassDeclaration) d).getSuperclass();
+ if (shouldProcessClass(superclass)) {
+ if (isMojo(superclass.getDeclaration())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean shouldProcessClass(ClassType superclass) {
+ return superclass != null && (!superclass.getDeclaration().getQualifiedName()
+ .equals("java.lang.Object"));
+ }
+
+ private boolean checkVisited(Declaration d) {
+ if (visitedDeclarations.contains(d)) {
+ return true;
+ } else {
+ if (mojoDescriptor != null) {
+ visitedDeclarations.add(d);
+ }
+ return false;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoDescriptorTls.java
===================================================================
--- maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoDescriptorTls.java (revision 0)
+++ maven-plugin-tools-anno/src/main/java/org/apache/maven/tools/plugin/extractor/anno/MojoDescriptorTls.java (revision 0)
@@ -0,0 +1,27 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+class MojoDescriptorTls {
+
+ private static ThreadLocal> TL = new ThreadLocal>();
+
+ static void addDescriptor(MojoDescriptor descriptor) {
+ List descriptors = TL.get();
+ descriptors.add(descriptor);
+ }
+
+ static List getDescriptors() {
+ return TL.get();
+ }
+
+ static void setDescriptors(List descriptors) {
+ TL.set(descriptors);
+ }
+}
Index: maven-plugin-tools-anno/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- maven-plugin-tools-anno/src/main/resources/META-INF/plexus/components.xml (revision 0)
+++ maven-plugin-tools-anno/src/main/resources/META-INF/plexus/components.xml (revision 0)
@@ -0,0 +1,17 @@
+
+
+
+
+
+ org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor
+ java
+ org.apache.maven.tools.plugin.extractor.anno.AnnoMojoDescriptorExtractor
+
+
+
+
\ No newline at end of file
Index: maven-plugin-tools-anno/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- maven-plugin-tools-anno/src/main/resources/META-INF/plexus/components.xml (revision 0)
+++ maven-plugin-tools-anno/src/main/resources/META-INF/plexus/components.xml (revision 0)
@@ -0,0 +1,17 @@
+
+
+
+
+
+ org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor
+ java
+ org.apache.maven.tools.plugin.extractor.anno.AnnoMojoDescriptorExtractor
+
+
+
+
\ No newline at end of file
Index: maven-plugin-tools-anno/src/site/site.xml
===================================================================
--- maven-plugin-tools-anno/src/site/site.xml (revision 0)
+++ maven-plugin-tools-anno/src/site/site.xml (revision 0)
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+ Maven Annotated Mojo Tool
+ http://maven.apache.org/images/apache-maven-project.png
+ http://maven.apache.org/maven2/
+
+
+ http://maven.apache.org/images/maven-small.gif
+
+
+
+
+
+
+
+
+
+ ${reports}
+
+
Index: maven-plugin-tools-anno/src/site/apt/introduction.apt
===================================================================
--- maven-plugin-tools-anno/src/site/apt/introduction.apt (revision 0)
+++ maven-plugin-tools-anno/src/site/apt/introduction.apt (revision 0)
@@ -0,0 +1,19 @@
+ -----
+Introduction
+ -----
+Yoav Landman
+ -----
+11 May 2006
+ -----
+
+Introduction
+
+ This is a Maven2 extention that allows writing Annotatd Plug-in Mojos using JDK 1.5+ annotations.
+ This has a couple of benefits over using JavaDoc-style annotations:
+
+ First, you will get compile-time checks for your plugin metadata.
+ Second, you can use annotations on interface getter methods instead of field annotations,
+ which allows for greater flexibility in your plugin object model.
+ Finally, since JDK 1.5 annotations are supported in most IDEs, you will benefit from code-completion and syntactic checks.
+
+ Enjoy.
Index: maven-plugin-tools-anno/src/site/apt/usage.apt
===================================================================
--- maven-plugin-tools-anno/src/site/apt/usage.apt (revision 0)
+++ maven-plugin-tools-anno/src/site/apt/usage.apt (revision 0)
@@ -0,0 +1,116 @@
+ -----
+Usage
+ -----
+Yoav Landman
+ -----
+11 May 2006
+ -----
+
+Usage
+
+* POM Settings
+
+ Simply add the following to your POM:
+
++---+
+
+ ...
+
+ ...
+
+ org.apache.maven
+ maven-plugin-tools-anno
+ 1.0-SNAPSHOT
+
+ ...
+
+
+
+
+ ...
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ 2.1
+
+
+ org.apache.maven
+ maven-plugin-tools-anno
+ 1.0-SNAPSHOT
+ runtime
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.5
+ 1.5
+
+
+ ...
+
+
+
++---+
+
+
+
+* Using Annotations
+
+** Class and Field Annotations
+
+ {{{apidocs//org/apache/maven/tools/plugin/extractor/anno/annotations/package-summary.html}<<>>}} annotations can be applied to classes or fields.
+
+ For example:
+
++---+
+/**
+ * My mojo description
+ */
+@MojoGoal("doIt")
+@MojoPhase("package")
+@MojoExecute(phase = "package")
+public class MyMojo {
+
+ @MojoParameter
+ private List artifacts;
+
+ @MojoParameter(expression = "${project}", required = true, readonly = true,
+ description = "The Maven Project")
+ private MavenProject project;
+
+ /**
+ * The local repository
+ */
+ @MojoParameter(expression = "${localRepository}")
+ private ArtifactRepository localRepository;
+ ...
+}
++---+
+
+ Element description is taken either from the element's JavaDoc comment or from a <<>> attribute on appropriate annotations.
+
+** Getter Methods Annotations
+
+ You can also use field annotations on getter methods, either in interfaces or regular classes.
+
+ For example:
+
++---+
+public interface MvnInjectable {
+
+ /**
+ * project-helper instance, used to make addition of resources simpler.
+ */
+ @MojoComponent
+ MavenProjectHelper getProjectHelper();
+}
++---+
+
+** Limitations
+
+
\ No newline at end of file
Index: maven-plugin-tools-anno/src/site/apt/introduction.apt
===================================================================
--- maven-plugin-tools-anno/src/site/apt/introduction.apt (revision 0)
+++ maven-plugin-tools-anno/src/site/apt/introduction.apt (revision 0)
@@ -0,0 +1,19 @@
+ -----
+Introduction
+ -----
+Yoav Landman
+ -----
+11 May 2006
+ -----
+
+Introduction
+
+ This is a Maven2 extention that allows writing Annotatd Plug-in Mojos using JDK 1.5+ annotations.
+ This has a couple of benefits over using JavaDoc-style annotations:
+
+ First, you will get compile-time checks for your plugin metadata.
+ Second, you can use annotations on interface getter methods instead of field annotations,
+ which allows for greater flexibility in your plugin object model.
+ Finally, since JDK 1.5 annotations are supported in most IDEs, you will benefit from code-completion and syntactic checks.
+
+ Enjoy.
Index: maven-plugin-tools-anno/src/site/apt/usage.apt
===================================================================
--- maven-plugin-tools-anno/src/site/apt/usage.apt (revision 0)
+++ maven-plugin-tools-anno/src/site/apt/usage.apt (revision 0)
@@ -0,0 +1,116 @@
+ -----
+Usage
+ -----
+Yoav Landman
+ -----
+11 May 2006
+ -----
+
+Usage
+
+* POM Settings
+
+ Simply add the following to your POM:
+
++---+
+
+ ...
+
+ ...
+
+ org.apache.maven
+ maven-plugin-tools-anno
+ 1.0-SNAPSHOT
+
+ ...
+
+
+
+
+ ...
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ 2.1
+
+
+ org.apache.maven
+ maven-plugin-tools-anno
+ 1.0-SNAPSHOT
+ runtime
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.5
+ 1.5
+
+
+ ...
+
+
+
++---+
+
+
+
+* Using Annotations
+
+** Class and Field Annotations
+
+ {{{apidocs//org/apache/maven/tools/plugin/extractor/anno/annotations/package-summary.html}<<>>}} annotations can be applied to classes or fields.
+
+ For example:
+
++---+
+/**
+ * My mojo description
+ */
+@MojoGoal("doIt")
+@MojoPhase("package")
+@MojoExecute(phase = "package")
+public class MyMojo {
+
+ @MojoParameter
+ private List artifacts;
+
+ @MojoParameter(expression = "${project}", required = true, readonly = true,
+ description = "The Maven Project")
+ private MavenProject project;
+
+ /**
+ * The local repository
+ */
+ @MojoParameter(expression = "${localRepository}")
+ private ArtifactRepository localRepository;
+ ...
+}
++---+
+
+ Element description is taken either from the element's JavaDoc comment or from a <<>> attribute on appropriate annotations.
+
+** Getter Methods Annotations
+
+ You can also use field annotations on getter methods, either in interfaces or regular classes.
+
+ For example:
+
++---+
+public interface MvnInjectable {
+
+ /**
+ * project-helper instance, used to make addition of resources simpler.
+ */
+ @MojoComponent
+ MavenProjectHelper getProjectHelper();
+}
++---+
+
+** Limitations
+
+
\ No newline at end of file
Index: maven-plugin-tools-anno/src/site/site.xml
===================================================================
--- maven-plugin-tools-anno/src/site/site.xml (revision 0)
+++ maven-plugin-tools-anno/src/site/site.xml (revision 0)
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+ Maven Annotated Mojo Tool
+ http://maven.apache.org/images/apache-maven-project.png
+ http://maven.apache.org/maven2/
+
+
+ http://maven.apache.org/images/maven-small.gif
+
+
+
+
+
+
+
+
+
+ ${reports}
+
+
Index: maven-plugin-tools-anno/src/test/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractorTest.java
===================================================================
--- maven-plugin-tools-anno/src/test/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractorTest.java (revision 0)
+++ maven-plugin-tools-anno/src/test/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractorTest.java (revision 0)
@@ -0,0 +1,48 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import junit.framework.TestCase;
+import org.apache.maven.model.Model;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+public class AnnoMojoDescriptorExtractorTest extends TestCase {
+
+ public void testCreateMojoDescriptor() throws Exception {
+ AnnoMojoDescriptorExtractor extractor = new AnnoMojoDescriptorExtractor();
+
+ File sourceFile = fileOf("dir-flag.txt");
+ System.out.println("found source file: " + sourceFile);
+
+ 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, "source").getCanonicalPath());
+
+ PluginDescriptor pluginDescriptor = new PluginDescriptor();
+ pluginDescriptor.setGoalPrefix("test");
+ List results = extractor.execute(project, pluginDescriptor);
+ assertEquals(2, results.size());
+ }
+
+ private File fileOf(String classpathResource) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL resource = cl.getResource(classpathResource);
+
+ File result = null;
+ if (resource != null) {
+ result = new File(resource.getPath());
+ }
+
+ return result;
+ }
+
+}
\ No newline at end of file
Index: maven-plugin-tools-anno/src/test/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractorTest.java
===================================================================
--- maven-plugin-tools-anno/src/test/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractorTest.java (revision 0)
+++ maven-plugin-tools-anno/src/test/java/org/apache/maven/tools/plugin/extractor/anno/AnnoMojoDescriptorExtractorTest.java (revision 0)
@@ -0,0 +1,48 @@
+package org.apache.maven.tools.plugin.extractor.anno;
+
+import junit.framework.TestCase;
+import org.apache.maven.model.Model;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+public class AnnoMojoDescriptorExtractorTest extends TestCase {
+
+ public void testCreateMojoDescriptor() throws Exception {
+ AnnoMojoDescriptorExtractor extractor = new AnnoMojoDescriptorExtractor();
+
+ File sourceFile = fileOf("dir-flag.txt");
+ System.out.println("found source file: " + sourceFile);
+
+ 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, "source").getCanonicalPath());
+
+ PluginDescriptor pluginDescriptor = new PluginDescriptor();
+ pluginDescriptor.setGoalPrefix("test");
+ List results = extractor.execute(project, pluginDescriptor);
+ assertEquals(2, results.size());
+ }
+
+ private File fileOf(String classpathResource) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL resource = cl.getResource(classpathResource);
+
+ File result = null;
+ if (resource != null) {
+ result = new File(resource.getPath());
+ }
+
+ return result;
+ }
+
+}
\ No newline at end of file
Index: maven-plugin-tools-anno/src/test/resources/dir-flag.txt
===================================================================
--- maven-plugin-tools-anno/src/test/resources/dir-flag.txt (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/dir-flag.txt (revision 0)
@@ -0,0 +1,10 @@
+This file is used by ClassLoader.getResource() to find the current path to the
+test resources. Uses this code:
+
+URL resource = classloader.getResource("dir-flag.txt");
+File resourceFile = new File(resource.getPath());
+File testResourcesDir= resourceFile.getParentFile();
+
+This way, the unit test can depend on a FileReader or somesuch, and still work
+fine regardless of ${user.dir} as long as the classpath is right. Useful for
+Eclipse...
\ No newline at end of file
Index: maven-plugin-tools-anno/src/test/resources/dir-flag.txt
===================================================================
--- maven-plugin-tools-anno/src/test/resources/dir-flag.txt (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/dir-flag.txt (revision 0)
@@ -0,0 +1,10 @@
+This file is used by ClassLoader.getResource() to find the current path to the
+test resources. Uses this code:
+
+URL resource = classloader.getResource("dir-flag.txt");
+File resourceFile = new File(resource.getPath());
+File testResourcesDir= resourceFile.getParentFile();
+
+This way, the unit test can depend on a FileReader or somesuch, and still work
+fine regardless of ${user.dir} as long as the classpath is right. Useful for
+Eclipse...
\ No newline at end of file
Index: maven-plugin-tools-anno/src/test/resources/source/MojoSupport.java
===================================================================
--- maven-plugin-tools-anno/src/test/resources/source/MojoSupport.java (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/source/MojoSupport.java (revision 0)
@@ -0,0 +1,26 @@
+package source;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoComponent;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoParameter;
+
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+@SuppressWarnings({"UNUSED_SYMBOL"})
+public abstract class MojoSupport implements MojoIfc {
+ @MojoParameter(expression = "${project}", required = true, readonly = true,
+ description = "The Maven Project")
+ private MavenProject project;
+
+ /**
+ * project-helper instance, used to make addition of resources
+ * simpler.
+ */
+ @MojoComponent
+ private MavenProjectHelper projectHelper;
+
+}
Index: maven-plugin-tools-anno/src/test/resources/source/Mojo1.java
===================================================================
--- maven-plugin-tools-anno/src/test/resources/source/Mojo1.java (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/source/Mojo1.java (revision 0)
@@ -0,0 +1,35 @@
+package source;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoGoal;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoParameter;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoPhase;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Jar and (optionally) sign multiple jar artifacts
+ */
+@MojoGoal("test")
+@MojoPhase("test")
+@SuppressWarnings({"UNUSED_SYMBOL"})
+public class Mojo1 extends MojoSupport {
+
+ @MojoParameter
+ private List param1;
+
+ @MojoParameter
+ private String param2;
+
+ private File param3;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ //NOP
+ }
+
+ public File getParam3() {
+ return param3;
+ }
+}
Index: maven-plugin-tools-anno/src/test/resources/source/Mojo2.java
===================================================================
--- maven-plugin-tools-anno/src/test/resources/source/Mojo2.java (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/source/Mojo2.java (revision 0)
@@ -0,0 +1,27 @@
+package source;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoGoal;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoPhase;
+
+import java.io.File;
+
+/**
+ * Jar and (optionally) sign multiple jar artifacts
+ */
+@MojoGoal("test")
+@MojoPhase("test")
+public class Mojo2 implements MojoIfc {
+
+ @SuppressWarnings({"UNUSED_SYMBOL"})
+ private File param3;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ //NOP
+ }
+
+ public File getParam3() {
+ return param3;
+ }
+}
Index: maven-plugin-tools-anno/src/test/resources/source/MojoIfc.java
===================================================================
--- maven-plugin-tools-anno/src/test/resources/source/MojoIfc.java (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/source/MojoIfc.java (revision 0)
@@ -0,0 +1,14 @@
+package source;
+
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoParameter;
+
+import java.io.File;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+public interface MojoIfc {
+ @MojoParameter
+ public File getParam3();
+}
Index: maven-plugin-tools-anno/src/test/resources/source/Mojo1.java
===================================================================
--- maven-plugin-tools-anno/src/test/resources/source/Mojo1.java (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/source/Mojo1.java (revision 0)
@@ -0,0 +1,35 @@
+package source;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoGoal;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoParameter;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoPhase;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Jar and (optionally) sign multiple jar artifacts
+ */
+@MojoGoal("test")
+@MojoPhase("test")
+@SuppressWarnings({"UNUSED_SYMBOL"})
+public class Mojo1 extends MojoSupport {
+
+ @MojoParameter
+ private List param1;
+
+ @MojoParameter
+ private String param2;
+
+ private File param3;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ //NOP
+ }
+
+ public File getParam3() {
+ return param3;
+ }
+}
Index: maven-plugin-tools-anno/src/test/resources/source/Mojo2.java
===================================================================
--- maven-plugin-tools-anno/src/test/resources/source/Mojo2.java (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/source/Mojo2.java (revision 0)
@@ -0,0 +1,27 @@
+package source;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoGoal;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoPhase;
+
+import java.io.File;
+
+/**
+ * Jar and (optionally) sign multiple jar artifacts
+ */
+@MojoGoal("test")
+@MojoPhase("test")
+public class Mojo2 implements MojoIfc {
+
+ @SuppressWarnings({"UNUSED_SYMBOL"})
+ private File param3;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ //NOP
+ }
+
+ public File getParam3() {
+ return param3;
+ }
+}
Index: maven-plugin-tools-anno/src/test/resources/source/MojoIfc.java
===================================================================
--- maven-plugin-tools-anno/src/test/resources/source/MojoIfc.java (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/source/MojoIfc.java (revision 0)
@@ -0,0 +1,14 @@
+package source;
+
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoParameter;
+
+import java.io.File;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+public interface MojoIfc {
+ @MojoParameter
+ public File getParam3();
+}
Index: maven-plugin-tools-anno/src/test/resources/source/MojoSupport.java
===================================================================
--- maven-plugin-tools-anno/src/test/resources/source/MojoSupport.java (revision 0)
+++ maven-plugin-tools-anno/src/test/resources/source/MojoSupport.java (revision 0)
@@ -0,0 +1,26 @@
+package source;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoComponent;
+import org.apache.maven.tools.plugin.extractor.anno.annotations.MojoParameter;
+
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yoavl
+ */
+@SuppressWarnings({"UNUSED_SYMBOL"})
+public abstract class MojoSupport implements MojoIfc {
+ @MojoParameter(expression = "${project}", required = true, readonly = true,
+ description = "The Maven Project")
+ private MavenProject project;
+
+ /**
+ * project-helper instance, used to make addition of resources
+ * simpler.
+ */
+ @MojoComponent
+ private MavenProjectHelper projectHelper;
+
+}