From a6874bc1ff14c8879a9632d5f6a54a3d5ab04b37 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Mon, 25 Jun 2012 18:48:43 +0200 Subject: [PATCH] initial import --- pom.xml | 308 ++++++++++++ src/.svn/all-wcprops | 5 + src/.svn/entries | 34 ++ src/main/.svn/all-wcprops | 5 + src/main/.svn/entries | 34 ++ src/main/java/.svn/all-wcprops | 5 + src/main/java/.svn/entries | 31 ++ src/main/java/org/.svn/all-wcprops | 5 + src/main/java/org/.svn/entries | 31 ++ src/main/java/org/bsc/.svn/all-wcprops | 5 + src/main/java/org/bsc/.svn/entries | 31 ++ src/main/java/org/bsc/maven/.svn/all-wcprops | 5 + src/main/java/org/bsc/maven/.svn/entries | 31 ++ .../org/bsc/maven/plugin/.svn/all-wcprops | 5 + .../java/org/bsc/maven/plugin/.svn/entries | 31 ++ .../maven/plugin/processor/.svn/all-wcprops | 29 ++ .../bsc/maven/plugin/processor/.svn/entries | 164 +++++++ ...tractAnnotationProcessorMojo.java.svn-base | 5 + .../.svn/prop-base/Debug.java.svn-base | 5 + .../TestAnnotationProcessorMojo.java.svn-base | 5 + ...tractAnnotationProcessorMojo.java.svn-base | 440 ++++++++++++++++++ .../.svn/text-base/Debug.java.svn-base | 91 ++++ .../MainAnnotationProcessorMojo.java.svn-base | 116 +++++ .../TestAnnotationProcessorMojo.java.svn-base | 118 +++++ .../AbstractAnnotationProcessorMojo.java.tmp | 247 ++++++++++ .../tmp/MainAnnotationProcessorMojo.java.tmp | 78 ++++ .../tmp/TestAnnotationProcessorMojo.java.tmp | 80 ++++ .../AbstractAnnotationProcessorMojo.java | 440 ++++++++++++++++++ .../org/bsc/maven/plugin/processor/Debug.java | 91 ++++ .../MainAnnotationProcessorMojo.java | 116 +++++ .../TestAnnotationProcessorMojo.java | 118 +++++ src/main/resources/.svn/all-wcprops | 11 + src/main/resources/.svn/entries | 62 +++ .../.svn/text-base/COPYING.LESSER.svn-base | 165 +++++++ src/main/resources/COPYING.LESSER | 165 +++++++ src/site/.svn/all-wcprops | 11 + src/site/.svn/entries | 72 +++ src/site/.svn/prop-base/site.xml.svn-base | 5 + src/site/.svn/text-base/site.xml.svn-base | 42 ++ src/site/apt/.svn/all-wcprops | 11 + src/site/apt/.svn/entries | 69 +++ .../apt/.svn/text-base/usage.apt.svn-base | 225 +++++++++ src/site/apt/usage.apt | 225 +++++++++ src/site/site.xml | 42 ++ 44 files changed, 3814 insertions(+) create mode 100644 pom.xml create mode 100644 src/.svn/all-wcprops create mode 100644 src/.svn/entries create mode 100644 src/main/.svn/all-wcprops create mode 100644 src/main/.svn/entries create mode 100644 src/main/java/.svn/all-wcprops create mode 100644 src/main/java/.svn/entries create mode 100644 src/main/java/org/.svn/all-wcprops create mode 100644 src/main/java/org/.svn/entries create mode 100644 src/main/java/org/bsc/.svn/all-wcprops create mode 100644 src/main/java/org/bsc/.svn/entries create mode 100644 src/main/java/org/bsc/maven/.svn/all-wcprops create mode 100644 src/main/java/org/bsc/maven/.svn/entries create mode 100644 src/main/java/org/bsc/maven/plugin/.svn/all-wcprops create mode 100644 src/main/java/org/bsc/maven/plugin/.svn/entries create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/all-wcprops create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/entries create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/AbstractAnnotationProcessorMojo.java.svn-base create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/Debug.java.svn-base create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/TestAnnotationProcessorMojo.java.svn-base create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/AbstractAnnotationProcessorMojo.java.svn-base create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/Debug.java.svn-base create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/MainAnnotationProcessorMojo.java.svn-base create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/TestAnnotationProcessorMojo.java.svn-base create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/AbstractAnnotationProcessorMojo.java.tmp create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/MainAnnotationProcessorMojo.java.tmp create mode 100644 src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/TestAnnotationProcessorMojo.java.tmp create mode 100644 src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java create mode 100644 src/main/java/org/bsc/maven/plugin/processor/Debug.java create mode 100644 src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java create mode 100644 src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java create mode 100644 src/main/resources/.svn/all-wcprops create mode 100644 src/main/resources/.svn/entries create mode 100644 src/main/resources/.svn/text-base/COPYING.LESSER.svn-base create mode 100644 src/main/resources/COPYING.LESSER create mode 100644 src/site/.svn/all-wcprops create mode 100644 src/site/.svn/entries create mode 100644 src/site/.svn/prop-base/site.xml.svn-base create mode 100644 src/site/.svn/text-base/site.xml.svn-base create mode 100644 src/site/apt/.svn/all-wcprops create mode 100644 src/site/apt/.svn/entries create mode 100644 src/site/apt/.svn/text-base/usage.apt.svn-base create mode 100644 src/site/apt/usage.apt create mode 100644 src/site/site.xml diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d9c7b92 --- /dev/null +++ b/pom.xml @@ -0,0 +1,308 @@ + + 4.0.0 + org.bsc.maven + maven-processor-plugin + maven-plugin + 2.0.6-SNAPSHOT + maven-processor-plugin Maven Mojo + A maven plugin to process annotation for jdk6 at compile time + +This plugin helps to use from maven the new annotation processing provided by JDK6 integrated in java compiler + +This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.codehaus.org/apt-maven-plugin/ + http://code.google.com/p/maven-annotation-plugin/ + + + + org.apache.maven.plugins + maven-plugin-plugin + 2.5.1 + + + + + + + ${release.repo.id} + ${release.repo.url} + + + ${snapshot.repo.id} + ${snapshot.repo.url} + false + + + ${release.site.id} + ${release.site.url} + + + + + + sonatype-repo + https://oss.sonatype.org/content/repositories/snapshots + sonatype-repo + https://oss.sonatype.org/service/local/staging/deploy/maven2 + + + + svn:https://maven-annotation-plugin.googlecode.com/svn/docs + google-project + 1.3.1 + + + + +scm:svn:https://maven-annotation-plugin.googlecode.com/svn/trunk/processor +scm:svn:https://maven-annotation-plugin.googlecode.com/svn/trunk/processor +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor + + +2009 + + + + bartolomeo.sorrentino@gmail.com + Bartolomeo Sorrentino + GMT+1 + + Owner + + + + igor.vay...@gmail.com + Igor Vaynberg + + Committer + + + + + + GNU LESSER GENERAL PUBLIC LICENSE + http://www.gnu.org/licenses/lgpl.html + + + + + + org.apache.maven + maven-plugin-api + 3.0.1 + + + org.apache.maven + maven-core + 3.0.1 + + + + + + + junit + junit + 4.8.2 + test + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.5 + 1.5 + + + + + maven-plugin-plugin + 2.6 + + + + + + + + + + + + + + + org.jvnet.wagon-svn + wagon-svn + 1.8 + + + + + + + + + + + release + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.3 + + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + twitter + + + + + com.vineetmanohar + maven-twitter-plugin + 0.1 + + + + + + + New release ${project.version} of maven-annotation-plugin is available - http://code.google.com/p/maven-annotation-plugin + + deploy + deploy + + tweet + + + + + + + + + + confluence + + + + + org.apache.maven.plugins + maven-site-plugin + 3.0 + + + + + + + org.bsc.maven + maven-confluence-reporting-plugin + 3.1.4-SNAPSHOT + + + confluence + + http://localhost:8090/rpc/xmlrpc + ds + Tutorial + admin + + + plugin-confluence-summary + + + + + + + + + + + + + + diff --git a/src/.svn/all-wcprops b/src/.svn/all-wcprops new file mode 100644 index 0000000..bfbce7f --- /dev/null +++ b/src/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 37 +/svn/!svn/ver/402/trunk/processor/src +END diff --git a/src/.svn/entries b/src/.svn/entries new file mode 100644 index 0000000..3afefc7 --- /dev/null +++ b/src/.svn/entries @@ -0,0 +1,34 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +main +dir + +site +dir + diff --git a/src/main/.svn/all-wcprops b/src/main/.svn/all-wcprops new file mode 100644 index 0000000..9e750b3 --- /dev/null +++ b/src/main/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 42 +/svn/!svn/ver/402/trunk/processor/src/main +END diff --git a/src/main/.svn/entries b/src/main/.svn/entries new file mode 100644 index 0000000..815da46 --- /dev/null +++ b/src/main/.svn/entries @@ -0,0 +1,34 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/main +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +java +dir + +resources +dir + diff --git a/src/main/java/.svn/all-wcprops b/src/main/java/.svn/all-wcprops new file mode 100644 index 0000000..e866506 --- /dev/null +++ b/src/main/java/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 47 +/svn/!svn/ver/402/trunk/processor/src/main/java +END diff --git a/src/main/java/.svn/entries b/src/main/java/.svn/entries new file mode 100644 index 0000000..0b553fe --- /dev/null +++ b/src/main/java/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/main/java +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +org +dir + diff --git a/src/main/java/org/.svn/all-wcprops b/src/main/java/org/.svn/all-wcprops new file mode 100644 index 0000000..544f342 --- /dev/null +++ b/src/main/java/org/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 51 +/svn/!svn/ver/402/trunk/processor/src/main/java/org +END diff --git a/src/main/java/org/.svn/entries b/src/main/java/org/.svn/entries new file mode 100644 index 0000000..cf4349f --- /dev/null +++ b/src/main/java/org/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/main/java/org +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +bsc +dir + diff --git a/src/main/java/org/bsc/.svn/all-wcprops b/src/main/java/org/bsc/.svn/all-wcprops new file mode 100644 index 0000000..40d3768 --- /dev/null +++ b/src/main/java/org/bsc/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 55 +/svn/!svn/ver/402/trunk/processor/src/main/java/org/bsc +END diff --git a/src/main/java/org/bsc/.svn/entries b/src/main/java/org/bsc/.svn/entries new file mode 100644 index 0000000..f890705 --- /dev/null +++ b/src/main/java/org/bsc/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/main/java/org/bsc +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +maven +dir + diff --git a/src/main/java/org/bsc/maven/.svn/all-wcprops b/src/main/java/org/bsc/maven/.svn/all-wcprops new file mode 100644 index 0000000..96776e7 --- /dev/null +++ b/src/main/java/org/bsc/maven/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/!svn/ver/402/trunk/processor/src/main/java/org/bsc/maven +END diff --git a/src/main/java/org/bsc/maven/.svn/entries b/src/main/java/org/bsc/maven/.svn/entries new file mode 100644 index 0000000..32e1b16 --- /dev/null +++ b/src/main/java/org/bsc/maven/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/main/java/org/bsc/maven +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +plugin +dir + diff --git a/src/main/java/org/bsc/maven/plugin/.svn/all-wcprops b/src/main/java/org/bsc/maven/plugin/.svn/all-wcprops new file mode 100644 index 0000000..1252bb4 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 68 +/svn/!svn/ver/402/trunk/processor/src/main/java/org/bsc/maven/plugin +END diff --git a/src/main/java/org/bsc/maven/plugin/.svn/entries b/src/main/java/org/bsc/maven/plugin/.svn/entries new file mode 100644 index 0000000..1edd650 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/main/java/org/bsc/maven/plugin +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +processor +dir + diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/all-wcprops b/src/main/java/org/bsc/maven/plugin/processor/.svn/all-wcprops new file mode 100644 index 0000000..f9e8c58 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/all-wcprops @@ -0,0 +1,29 @@ +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/!svn/ver/402/trunk/processor/src/main/java/org/bsc/maven/plugin/processor +END +TestAnnotationProcessorMojo.java +K 25 +svn:wc:ra_dav:version-url +V 111 +/svn/!svn/ver/402/trunk/processor/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java +END +AbstractAnnotationProcessorMojo.java +K 25 +svn:wc:ra_dav:version-url +V 115 +/svn/!svn/ver/400/trunk/processor/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java +END +MainAnnotationProcessorMojo.java +K 25 +svn:wc:ra_dav:version-url +V 111 +/svn/!svn/ver/400/trunk/processor/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java +END +Debug.java +K 25 +svn:wc:ra_dav:version-url +V 89 +/svn/!svn/ver/400/trunk/processor/src/main/java/org/bsc/maven/plugin/processor/Debug.java +END diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/entries b/src/main/java/org/bsc/maven/plugin/processor/.svn/entries new file mode 100644 index 0000000..737e5be --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/entries @@ -0,0 +1,164 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/main/java/org/bsc/maven/plugin/processor +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +TestAnnotationProcessorMojo.java +file + + + + +2012-01-07T12:22:19.000000Z +dd2159e66aca9edf8c3874da2cd7bf16 +2011-12-05T09:41:48.030113Z +402 +bartolomeo.sorrentino@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +3500 + +AbstractAnnotationProcessorMojo.java +file + + + + +2012-01-07T12:22:19.000000Z +4ab70f8dfb89d22f12caaa3f7728231e +2011-12-05T09:38:58.244534Z +400 +bartolomeo.sorrentino@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +14367 + +MainAnnotationProcessorMojo.java +file + + + + +2012-01-07T12:22:19.000000Z +78f4f5777c29d5ad4bcba0bde1fb2dab +2011-12-05T09:38:58.244534Z +400 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + + + + + + + + +3495 + +Debug.java +file + + + + +2012-01-07T12:22:19.000000Z +9d88072cf00c54ad07b2ee397f14c492 +2011-12-05T09:38:58.244534Z +400 +bartolomeo.sorrentino@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +3218 + diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/AbstractAnnotationProcessorMojo.java.svn-base b/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/AbstractAnnotationProcessorMojo.java.svn-base new file mode 100644 index 0000000..138f983 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/AbstractAnnotationProcessorMojo.java.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 10 +text/plain +END diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/Debug.java.svn-base b/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/Debug.java.svn-base new file mode 100644 index 0000000..138f983 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/Debug.java.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 10 +text/plain +END diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/TestAnnotationProcessorMojo.java.svn-base b/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/TestAnnotationProcessorMojo.java.svn-base new file mode 100644 index 0000000..138f983 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/prop-base/TestAnnotationProcessorMojo.java.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 10 +text/plain +END diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/AbstractAnnotationProcessorMojo.java.svn-base b/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/AbstractAnnotationProcessorMojo.java.svn-base new file mode 100644 index 0000000..4fbf25e --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/AbstractAnnotationProcessorMojo.java.svn-base @@ -0,0 +1,440 @@ +/* + * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino + * + * This file is part of maven-annotation-plugin. + * + * maven-annotation-plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * maven-annotation-plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with maven-annotation-plugin. If not, see . + */ + +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; + +import javax.tools.Diagnostic; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.StringUtils; + + +/** + * + * @author bsorrentino + * + * @threadSafe + */ +public abstract class AbstractAnnotationProcessorMojo extends AbstractMojo +{ + + /** + * @parameter expression = "${project}" + * @readonly + * @required + */ + //@MojoParameter(expression = "${project}", readonly = true, required = true) + protected MavenProject project; + + /** + * @parameter expression="${plugin.artifacts}" + * @readonly + */ + //@MojoParameter(expression="${plugin.artifacts}", readonly = true ) + private java.util.List pluginArtifacts; + + /** + * Specify the directory where to place generated source files (same behaviour of -s option) + * @parameter + * + */ + //@MojoParameter(required = false, description = "Specify the directory where to place generated source files (same behaviour of -s option)") + private File outputDirectory; + + /** + * Annotation Processor FQN (Full Qualified Name) - when processors are not specified, the default discovery mechanism will be used + * @parameter + * + */ + //@MojoParameter(required = false, description = "Annotation Processor FQN (Full Qualified Name) - when processors are not specified, the default discovery mechanism will be used") + private String[] processors; + + /** + * Additional compiler arguments + * @parameter + * + */ + //@MojoParameter(required = false, description = "Additional compiler arguments") + private String compilerArguments; + + /** + * Additional processor options (see javax.annotation.processing.ProcessingEnvironment#getOptions() + * @parameter alias="options" + * + */ + private java.util.Map optionMap; + + /** + * Controls whether or not the output directory is added to compilation + */ + //@MojoParameter(required = false, description = "Controls whether or not the output directory is added to compilation") + private Boolean addOutputDirectoryToCompilationSources; + + /** + * Indicates whether the build will continue even if there are compilation errors; defaults to true. + * @parameter default-value="true" expression = "${annotation.failOnError}" + * @required + */ + //@MojoParameter(required = true, defaultValue = "true", expression = "${annotation.failOnError}", description = "Indicates whether the build will continue even if there are compilation errors; defaults to true.") + private Boolean failOnError = true; + + /** + * Indicates whether the compiler output should be visible, defaults to true. + * + * @parameter expression = "${annotation.outputDiagnostics}" default-value="true" + * @required + */ + //@MojoParameter(required = true, defaultValue = "true", expression = "${annotation.outputDiagnostics}", description = "Indicates whether the compiler output should be visible, defaults to true.") + private boolean outputDiagnostics = true; + + /** + * System properties set before processor invocation. + * @parameter + * + */ + //@MojoParameter(required = false, description = "System properties set before processor invocation.") + private java.util.Map systemProperties; + + /** + * includes pattern + * @parameter + */ + //@MojoParameter( description="includes pattern") + private String[] includes; + + /** + * excludes pattern + * @parameter + */ + //@MojoParameter( description="excludes pattern") + private String[] excludes; + + + private ReentrantLock compileLock = new ReentrantLock(); + + protected abstract File getSourceDirectory(); + protected abstract File getOutputClassDirectory(); + + private String buildProcessor() + { + if (processors == null || processors.length == 0) + { + return null; + } + + StringBuilder result = new StringBuilder(); + + int i = 0; + + for (i = 0; i < processors.length - 1; ++i) + { + result.append(processors[i]).append(','); + } + + result.append(processors[i]); + + return result.toString(); + } + + protected abstract java.util.Set getClasspathElements( java.util.Set result ); + + private String buildCompileClasspath() + { + + java.util.Set pathElements = new java.util.LinkedHashSet(); + + if( pluginArtifacts!=null ) { + + for( Artifact a : pluginArtifacts ) { + + if( "compile".equalsIgnoreCase(a.getScope()) || "runtime".equalsIgnoreCase(a.getScope()) ) { + + java.io.File f = a.getFile(); + + if( f!=null ) pathElements.add( a.getFile().getAbsolutePath() ); + } + + } + } + + getClasspathElements(pathElements); + + StringBuilder result = new StringBuilder(); + + for( String elem : pathElements ) { + result.append(elem).append(File.pathSeparator); + } + return result.toString(); + } + + + /** + * + */ + public void execute() throws MojoExecutionException + { + if ("pom".equalsIgnoreCase(project.getPackaging())) // Issue 17 + { + return; + } + + try + { + executeWithExceptionsHandled(); + } + catch (Exception e1) + { + super.getLog().error("error on execute: " + e1.getMessage()); + if (failOnError) + { + throw new MojoExecutionException("Error executing", e1); + } + } + + } + + @SuppressWarnings("unchecked") + private void executeWithExceptionsHandled() throws Exception + { + if (outputDirectory == null) + { + outputDirectory = getDefaultOutputDirectory(); + } + + ensureOutputDirectoryExists(); + addOutputToSourcesIfNeeded(); + + // new Debug(project).printDebugInfo(); + + java.io.File sourceDir = getSourceDirectory(); + if( sourceDir==null ) { + getLog().warn( "source directory cannot be read (null returned)! Processor task will be skipped"); + return; + } + if( !sourceDir.exists() ) { + getLog().warn( "source directory doesn't exist! Processor task will be skipped"); + return; + } + if( !sourceDir.isDirectory() ) { + getLog().warn( "source directory is invalid! Processor task will be skipped"); + return; + } + + final String includesString = ( includes==null || includes.length==0) ? "**/*.java" : StringUtils.join(includes, ","); + final String excludesString = ( excludes==null || excludes.length==0) ? null : StringUtils.join(excludes, ","); + + List files = FileUtils.getFiles(getSourceDirectory(), includesString, excludesString); + + Iterable< ? extends JavaFileObject> compilationUnits1 = null; + + + + String compileClassPath = buildCompileClasspath(); + + String processor = buildProcessor(); + + List options = new ArrayList(10); + + options.add("-cp"); + options.add(compileClassPath); + options.add("-proc:only"); + + addCompilerArguments(options); + + if (processor != null) + { + options.add("-processor"); + options.add(processor); + } + else + { + getLog().info("No processors specified. Using default discovery mechanism."); + } + options.add("-d"); + options.add(getOutputClassDirectory().getPath()); + + options.add("-s"); + options.add(outputDirectory.getPath()); + + + for (String option : options) + { + getLog().info("javac option: " + option); + } + + DiagnosticListener dl = null; + if (outputDiagnostics) + { + dl = new DiagnosticListener() + { + + public void report(Diagnostic< ? extends JavaFileObject> diagnostic) + { + getLog().info("diagnostic " + diagnostic); + + } + + }; + } + else + { + dl = new DiagnosticListener() + { + + public void report(Diagnostic< ? extends JavaFileObject> diagnostic) + { + } + + }; + } + + if (systemProperties != null) + { + java.util.Set< Map.Entry> pSet = systemProperties.entrySet(); + + for ( Map.Entry e : pSet ) + { + getLog().info( String.format("set system property : [%s] = [%s]", e.getKey(), e.getValue() )); + System.setProperty(e.getKey(), e.getValue()); + } + + } + + compileLock.lock(); + try { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + + if( compiler==null ) { + getLog().error("JVM is not suitable for processing annotation! ToolProvider.getSystemJavaCompiler() is null."); + return; + } + + StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); + + if( files!=null && !files.isEmpty() ) { + compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(files); + + } + else { + getLog().warn( "no source file(s) detected! Processor task will be skipped"); + return; + } + + + CompilationTask task = compiler.getTask( + new PrintWriter(System.out), + fileManager, + dl, + options, + null, + compilationUnits1); + + /* + * //Create a list to hold annotation processors LinkedList processors = new + * LinkedList(); + * + * //Add an annotation processor to the list processors.add(p); + * + * //Set the annotation processor to the compiler task task.setProcessors(processors); + */ + + // Perform the compilation task. + if (!task.call()) + { + + throw new Exception("error during compilation"); + } + } + finally { + compileLock.unlock(); + } + + } + + private void addCompilerArguments(List options) + { + if (!StringUtils.isEmpty(compilerArguments)) + { + for (String arg : compilerArguments.split(" ")) + { + if (!StringUtils.isEmpty(arg)) + { + arg = arg.trim(); + getLog().info("Adding compiler arg: " + arg); + options.add(arg); + } + } + } + if( optionMap!=null && !optionMap.isEmpty() ) { + for( java.util.Map.Entry e : optionMap.entrySet() ) { + + if( !StringUtils.isEmpty(e.getKey()) && e.getValue()!=null ) { + String opt = String.format("-A%s=%s", e.getKey().trim(), e.getValue().toString().trim()); + options.add( opt ); + getLog().info("Adding compiler arg: " + opt); + } + } + + } + } + + private void addOutputToSourcesIfNeeded() + { + final Boolean add = addOutputDirectoryToCompilationSources; + if (add == null || add.booleanValue()) + { + getLog().info("Source directory: " + outputDirectory + " added"); + addCompileSourceRoot(project, outputDirectory.getAbsolutePath()); + } + } + + protected abstract void addCompileSourceRoot(MavenProject project, String dir); + public abstract File getDefaultOutputDirectory(); + + private void ensureOutputDirectoryExists() + { + final File f = outputDirectory; + if (!f.exists()) + { + f.mkdirs(); + } + if( !getOutputClassDirectory().exists()) { + getOutputClassDirectory().mkdirs(); + } + } + + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/Debug.java.svn-base b/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/Debug.java.svn-base new file mode 100644 index 0000000..0f91c6b --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/Debug.java.svn-base @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino + * + * This file is part of maven-annotation-plugin. + * + * maven-annotation-plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * maven-annotation-plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with maven-annotation-plugin. If not, see . + */ +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.util.Collection; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.project.MavenProject; + +/** + * Debug helpers + */ +class Debug +{ + private final MavenProject project; + + public Debug(MavenProject project) + { + if (project == null) + { + throw new IllegalArgumentException("Argument 'project' cannot be null"); + } + this.project = project; + } + + public void println(String name, Collection e) + { + System.out.println(name); + if (null == e) + { + return; + } + + for (T a : e) + { + System.out.printf("\t[%s] %s\n", a.getClass().getName(), a.toString()); + } + + } + + public void printDeps(String name, Collection dependencies) + { + System.out.println(name); + for (org.apache.maven.model.Dependency d : dependencies) + { + + System.out.printf("dependency [%s]\n", d.toString()); + + String versionlessKey = ArtifactUtils.versionlessKey(d.getGroupId(), d.getArtifactId()); + + Artifact artifact = (Artifact)project.getArtifactMap().get(versionlessKey); + + if (null != artifact) + { + File file = artifact.getFile(); + System.out.printf("artifact [%s]\n", file.getPath()); + } + } + } + + public void printDebugInfo() throws Exception //DependencyResolutionRequiredException + { + //println("project.getCompileClasspathElements", project.getCompileClasspathElements()); + println("project.getCompileArtifacts", project.getCompileArtifacts()); + println("project.getCompileDependencies", project.getCompileDependencies()); + println("project.getDependencyArtifacts", project.getDependencyArtifacts()); + println("project.getArtifactMap", project.getArtifactMap().keySet()); + println("project.getArtifacts", project.getArtifacts()); + printDeps("project.getRuntimeDependencies", project.getRuntimeDependencies()); + printDeps("project.getDependencies", project.getDependencies()); + } + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/MainAnnotationProcessorMojo.java.svn-base b/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/MainAnnotationProcessorMojo.java.svn-base new file mode 100644 index 0000000..e8cb807 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/MainAnnotationProcessorMojo.java.svn-base @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino + * + * This file is part of maven-annotation-plugin. + * + * maven-annotation-plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * maven-annotation-plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with maven-annotation-plugin. If not, see . + */ +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.util.List; + +import org.apache.maven.model.Resource; +import org.apache.maven.project.MavenProject; + +/** + * + * @author bsorrentino + * + * @goal process + * @requiresDependencyResolution compile + * @phase generate-sources + */ +//@MojoGoal("process") +//@MojoRequiresDependencyResolution(value = "compile") +//@MojoPhase("generate-sources") +public class MainAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo +{ + /** + * project classpath + * + * @parameter expression = "${project.compileClasspathElements}" + * @required + * @readonly + */ + @SuppressWarnings("rawtypes") + //@MojoParameter(expression = "${project.compileClasspathElements}", required = true, readonly = true) + private List classpathElements; + + /** + * project sourceDirectory + * + * @parameter expression = "${project.build.sourceDirectory}" + * @required + */ + //@MojoParameter(expression = "${project.build.sourceDirectory}", required = true) + private File sourceDirectory; + + /** + * @parameter expression = "${project.build.directory}/generated-sources/apt" + * @required + */ + //@MojoParameter(expression = "${project.build.directory}/generated-sources/apt", required = true) + private File defaultOutputDirectory; + + /** + * Set the destination directory for class files (same behaviour of -d option) + * + * @parameter expression="${project.build.outputDirectory}" + */ + //@MojoParameter(required = false, expression="${project.build.outputDirectory}", description = "Set the destination directory for class files (same behaviour of -d option)") + private File outputClassDirectory; + + @Override + public File getSourceDirectory() + { + return sourceDirectory; + } + + @Override + protected File getOutputClassDirectory() + { + return outputClassDirectory; + } + + protected void addCompileSourceRoot(MavenProject project, String dir) + { + project.addCompileSourceRoot(dir); + } + + @Override + public File getDefaultOutputDirectory() + { + return defaultOutputDirectory; + } + + @Override + @SuppressWarnings("unchecked") + protected java.util.Set getClasspathElements( java.util.Set result) + { + List resources = project.getResources(); + + if( resources!=null ) { + for( Resource r : resources ) { + result.add(r.getDirectory()); + } + } + + result.addAll( classpathElements ); + + return result; + } + + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/TestAnnotationProcessorMojo.java.svn-base b/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/TestAnnotationProcessorMojo.java.svn-base new file mode 100644 index 0000000..e00535d --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/text-base/TestAnnotationProcessorMojo.java.svn-base @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino + * + * This file is part of maven-annotation-plugin. + * + * maven-annotation-plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * maven-annotation-plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with maven-annotation-plugin. If not, see . + */ +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.util.List; + +import org.apache.maven.model.Resource; +import org.apache.maven.project.MavenProject; + +/** + * + * @author bsorrentino + * + * @goal process-test + * @requiresDependencyResolution test + * @phase generate-test-sources + */ +//@MojoGoal("process-test") +//@MojoRequiresDependencyResolution(value = "test") +//@MojoPhase("generate-test-sources") +public class TestAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo +{ + + /** + * project classpath + * + * @parameter expression = "${project.testClasspathElements}" + * @required + * @readonly + */ + @SuppressWarnings("rawtypes") + //@MojoParameter(expression = "${project.testClasspathElements}", required = true, readonly = true) + private List classpathElements; + + + /** + * + * @parameter expression = "${project.build.testSourceDirectory}" + * @required + */ + //@MojoParameter(expression = "${project.build.testSourceDirectory}", required = true) + private File sourceDirectory; + + /** + * @parameter expression = "${project.build.directory}/generated-sources/apt-test" + * @required + */ + //@MojoParameter(expression = "${project.build.directory}/generated-sources/apt-test", required = true) + private File defaultOutputDirectory; + + /** + * Set the destination directory for class files (same behaviour of -d option) + * + * @parameter expression="${project.build.testOutputDirectory}" + */ + //@MojoParameter(required = false, expression="${project.build.testOutputDirectory}", description = "Set the destination directory for class files (same behaviour of -d option)") + private File outputClassDirectory; + + @Override + public File getSourceDirectory() + { + return sourceDirectory; + } + + protected void addCompileSourceRoot(MavenProject project, String dir) + { + project.addTestCompileSourceRoot(dir); + } + + @Override + public File getDefaultOutputDirectory() + { + return defaultOutputDirectory; + } + + @Override + protected File getOutputClassDirectory() + { + return outputClassDirectory; + } + + + @SuppressWarnings("unchecked") + @Override + protected java.util.Set getClasspathElements( java.util.Set result ) + { + List resources = project.getTestResources(); + + if( resources!=null ) { + for( Resource r : resources ) { + result.add(r.getDirectory()); + } + } + + result.addAll( classpathElements ); + + return result; + } + + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/AbstractAnnotationProcessorMojo.java.tmp b/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/AbstractAnnotationProcessorMojo.java.tmp new file mode 100644 index 0000000..21b19c5 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/AbstractAnnotationProcessorMojo.java.tmp @@ -0,0 +1,247 @@ +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; + +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; +import javax.tools.JavaCompiler.CompilationTask; + +import org.apache.maven.artifact.DependencyResolutionRequiredException; +import org.apache.maven.model.Resource; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.StringUtils; +import org.jfrog.maven.annomojo.annotations.MojoParameter; + +public abstract class AbstractAnnotationProcessorMojo extends AbstractMojo +{ + + @MojoParameter(expression = "${project}", readonly = true, required = true) + protected MavenProject project; + + @MojoParameter(required = false, defaultValue="${project.build.outputDirectory}") + private File outputDirectory; + + @MojoParameter(required = false, description = "Annotation Processor FQN (Full Qualified Name) - when processors are not specified, the default discovery mechanism will be used") + private String[] processors; + + @MojoParameter(required = false, description = "Additional compiler arguments") + private String compilerArguments; + + @MojoParameter(required = false, description = "Controls whether or not the output directory is added to compilation") + private Boolean addOutputDirectoryToCompilationSources; + + protected abstract File getSourceDirectory(); + + private String buildProcessor() + { + if (processors == null || processors.length == 0) + { + return null; + } + + StringBuilder result = new StringBuilder(); + + int i = 0; + + for (i = 0; i < processors.length - 1; ++i) + { + result.append(processors[i]).append(','); + } + + result.append(processors[i]); + + return result.toString(); + } + +<<<<<<< .mine + protected abstract List getResourceForClasspath(); + +======= + protected abstract List getClasspathElements(); + +>>>>>>> .r130 + @SuppressWarnings("unchecked") + private String buildCompileClasspath( ) + { +<<<<<<< .mine + + List pathElements = null; + try + { + pathElements = project.getCompileClasspathElements(); + } + catch (DependencyResolutionRequiredException e) + { + + super.getLog().warn("exception calling getCompileClasspathElements", e); + + return null; + } + + if (pathElements.isEmpty()) + { + return null; + } + +======= + List pathElements = getClasspathElements(); + +>>>>>>> .r130 + StringBuilder result = new StringBuilder(); + + int i = 0; + + List resourceList = getResourceForClasspath(); + + if( resourceList!=null ) { + for( Resource r : resourceList ) { + result.append(r.getDirectory()).append(File.pathSeparator); + } + } + + for (i = 0; i < pathElements.size() - 1; ++i) + { + result.append(pathElements.get(i)).append(File.pathSeparator); + } + + result.append(pathElements.get(i)); + + return result.toString(); + } + + + /** + * + */ + public void execute() throws MojoExecutionException + { + try + { + executeWithExceptionsHandled(); + } + catch (Exception e1) + { + super.getLog().error("execute error", e1); + throw new MojoExecutionException(e1.getMessage()); + } + + } + + private void executeWithExceptionsHandled() throws Exception + { + if (outputDirectory == null) + { + outputDirectory = getDefaultOutputDirectory(); + } + + ensureOutputDirectoryExists(); + addOutputToSourcesIfNeeded(); + + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); + + // new Debug(project).printDebugInfo(); + + List files = FileUtils.getFiles(getSourceDirectory(), "**/*.java", null); + + Iterable< ? extends JavaFileObject> compilationUnits1 = fileManager + .getJavaFileObjectsFromFiles(files); + + + String compileClassPath = buildCompileClasspath(); + + String processor = buildProcessor(); + + List options = new ArrayList(10); + + options.add("-cp"); + options.add(compileClassPath); + options.add("-proc:only"); + + addCompilerArguments(options); + + if (processor != null) + { + options.add("-processor"); + options.add(processor); + } + else + { + getLog().info("No processors specified. Using default discovery mechanism."); + } + + options.add("-s"); + options.add(outputDirectory.getPath()); + + + for (String option : options) + { + getLog().info("javac option: " + option); + } + + + CompilationTask task = compiler.getTask(new PrintWriter(System.out), fileManager, null, + options, null, compilationUnits1); + + /* + * //Create a list to hold annotation processors LinkedList processors = new + * LinkedList(); + * + * //Add an annotation processor to the list processors.add(p); + * + * //Set the annotation processor to the compiler task task.setProcessors(processors); + */ + + // Perform the compilation task. + task.call(); + } + + private void addCompilerArguments(List options) + { + if (!StringUtils.isEmpty(compilerArguments)) + { + for (String arg : compilerArguments.split(" ")) + { + if (!StringUtils.isEmpty(arg)) + { + arg = arg.trim(); + getLog().info("Adding compiler arg: " + arg); + options.add(arg); + } + } + } + } + + private void addOutputToSourcesIfNeeded() + { + final Boolean add = addOutputDirectoryToCompilationSources; + if (add == null || add.booleanValue()) + { + getLog().info("Source directory: " + outputDirectory + " added"); + addCompileSourceRoot(project, outputDirectory.getAbsolutePath()); + } + } + + protected abstract void addCompileSourceRoot(MavenProject project, String dir); + + private void ensureOutputDirectoryExists() + { + final File f = outputDirectory; + if (!f.exists()) + { + f.mkdirs(); + } + } + + + public abstract File getDefaultOutputDirectory(); + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/MainAnnotationProcessorMojo.java.tmp b/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/MainAnnotationProcessorMojo.java.tmp new file mode 100644 index 0000000..83c7809 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/MainAnnotationProcessorMojo.java.tmp @@ -0,0 +1,78 @@ +package org.bsc.maven.plugin.processor; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File; +<<<<<<< .mine +import java.util.List; +import org.apache.maven.model.Resource; +======= +import java.util.List; +>>>>>>> .r131 + +import org.apache.maven.project.MavenProject; +import org.jfrog.maven.annomojo.annotations.MojoGoal; +import org.jfrog.maven.annomojo.annotations.MojoParameter; +import org.jfrog.maven.annomojo.annotations.MojoPhase; +import org.jfrog.maven.annomojo.annotations.MojoRequiresDependencyResolution; + +@MojoGoal("process") +@MojoRequiresDependencyResolution(value = "compile") +@MojoPhase("generate-sources") +public class MainAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo +{ + /** project classpath */ + @MojoParameter(expression = "${project.compileClasspathElements}", required = true, readonly = true) + private List classpathElements; + + @MojoParameter(expression = "${project.build.sourceDirectory}", required = true) + private File sourceDirectory; + + @MojoParameter(expression = "${project.build.directory}/generated-sources/apt/main/java", required = true) + private File defaultOutputDirectory; + + public File getSourceDirectory() + { + return sourceDirectory; + } + + protected void addCompileSourceRoot(MavenProject project, String dir) + { + project.addCompileSourceRoot(dir); + } + + @Override + public File getDefaultOutputDirectory() + { + return defaultOutputDirectory; + } + +<<<<<<< .mine + @Override + protected List getResourceForClasspath() { + return project.getResources(); + } +======= + @Override + protected List getClasspathElements() + { + return classpathElements; + } +>>>>>>> .r131 + + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/TestAnnotationProcessorMojo.java.tmp b/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/TestAnnotationProcessorMojo.java.tmp new file mode 100644 index 0000000..04527c3 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/.svn/tmp/TestAnnotationProcessorMojo.java.tmp @@ -0,0 +1,80 @@ +package org.bsc.maven.plugin.processor; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File; +<<<<<<< .mine +import java.util.List; +import org.apache.maven.model.Resource; +======= +import java.util.List; +>>>>>>> .r131 + +import org.apache.maven.project.MavenProject; +import org.jfrog.maven.annomojo.annotations.MojoGoal; +import org.jfrog.maven.annomojo.annotations.MojoParameter; +import org.jfrog.maven.annomojo.annotations.MojoPhase; +import org.jfrog.maven.annomojo.annotations.MojoRequiresDependencyResolution; + +@MojoGoal("process-test") +@MojoRequiresDependencyResolution(value = "test") +@MojoPhase("generate-test-sources") +public class TestAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo +{ + + /** project classpath */ + @MojoParameter(expression = "${project.testClasspathElements}", required = true, readonly = true) + private List classpathElements; + + + @MojoParameter(expression = "${project.build.testSourceDirectory}", required = true) + private File sourceDirectory; + + @MojoParameter(expression = "${project.build.directory}/generated-sources/apt/test/java", required = true) + private File defaultOutputDirectory; + + public File getSourceDirectory() + { + return sourceDirectory; + } + + protected void addCompileSourceRoot(MavenProject project, String dir) + { + project.addTestCompileSourceRoot(dir); + } + + @Override + public File getDefaultOutputDirectory() + { + return defaultOutputDirectory; + } + +<<<<<<< .mine + @Override + protected List getResourceForClasspath() { + return project.getTestResources(); + } +======= + @Override + protected List getClasspathElements() + { + return classpathElements; + } +>>>>>>> .r131 + + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java new file mode 100644 index 0000000..4fbf25e --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java @@ -0,0 +1,440 @@ +/* + * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino + * + * This file is part of maven-annotation-plugin. + * + * maven-annotation-plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * maven-annotation-plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with maven-annotation-plugin. If not, see . + */ + +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; + +import javax.tools.Diagnostic; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.StringUtils; + + +/** + * + * @author bsorrentino + * + * @threadSafe + */ +public abstract class AbstractAnnotationProcessorMojo extends AbstractMojo +{ + + /** + * @parameter expression = "${project}" + * @readonly + * @required + */ + //@MojoParameter(expression = "${project}", readonly = true, required = true) + protected MavenProject project; + + /** + * @parameter expression="${plugin.artifacts}" + * @readonly + */ + //@MojoParameter(expression="${plugin.artifacts}", readonly = true ) + private java.util.List pluginArtifacts; + + /** + * Specify the directory where to place generated source files (same behaviour of -s option) + * @parameter + * + */ + //@MojoParameter(required = false, description = "Specify the directory where to place generated source files (same behaviour of -s option)") + private File outputDirectory; + + /** + * Annotation Processor FQN (Full Qualified Name) - when processors are not specified, the default discovery mechanism will be used + * @parameter + * + */ + //@MojoParameter(required = false, description = "Annotation Processor FQN (Full Qualified Name) - when processors are not specified, the default discovery mechanism will be used") + private String[] processors; + + /** + * Additional compiler arguments + * @parameter + * + */ + //@MojoParameter(required = false, description = "Additional compiler arguments") + private String compilerArguments; + + /** + * Additional processor options (see javax.annotation.processing.ProcessingEnvironment#getOptions() + * @parameter alias="options" + * + */ + private java.util.Map optionMap; + + /** + * Controls whether or not the output directory is added to compilation + */ + //@MojoParameter(required = false, description = "Controls whether or not the output directory is added to compilation") + private Boolean addOutputDirectoryToCompilationSources; + + /** + * Indicates whether the build will continue even if there are compilation errors; defaults to true. + * @parameter default-value="true" expression = "${annotation.failOnError}" + * @required + */ + //@MojoParameter(required = true, defaultValue = "true", expression = "${annotation.failOnError}", description = "Indicates whether the build will continue even if there are compilation errors; defaults to true.") + private Boolean failOnError = true; + + /** + * Indicates whether the compiler output should be visible, defaults to true. + * + * @parameter expression = "${annotation.outputDiagnostics}" default-value="true" + * @required + */ + //@MojoParameter(required = true, defaultValue = "true", expression = "${annotation.outputDiagnostics}", description = "Indicates whether the compiler output should be visible, defaults to true.") + private boolean outputDiagnostics = true; + + /** + * System properties set before processor invocation. + * @parameter + * + */ + //@MojoParameter(required = false, description = "System properties set before processor invocation.") + private java.util.Map systemProperties; + + /** + * includes pattern + * @parameter + */ + //@MojoParameter( description="includes pattern") + private String[] includes; + + /** + * excludes pattern + * @parameter + */ + //@MojoParameter( description="excludes pattern") + private String[] excludes; + + + private ReentrantLock compileLock = new ReentrantLock(); + + protected abstract File getSourceDirectory(); + protected abstract File getOutputClassDirectory(); + + private String buildProcessor() + { + if (processors == null || processors.length == 0) + { + return null; + } + + StringBuilder result = new StringBuilder(); + + int i = 0; + + for (i = 0; i < processors.length - 1; ++i) + { + result.append(processors[i]).append(','); + } + + result.append(processors[i]); + + return result.toString(); + } + + protected abstract java.util.Set getClasspathElements( java.util.Set result ); + + private String buildCompileClasspath() + { + + java.util.Set pathElements = new java.util.LinkedHashSet(); + + if( pluginArtifacts!=null ) { + + for( Artifact a : pluginArtifacts ) { + + if( "compile".equalsIgnoreCase(a.getScope()) || "runtime".equalsIgnoreCase(a.getScope()) ) { + + java.io.File f = a.getFile(); + + if( f!=null ) pathElements.add( a.getFile().getAbsolutePath() ); + } + + } + } + + getClasspathElements(pathElements); + + StringBuilder result = new StringBuilder(); + + for( String elem : pathElements ) { + result.append(elem).append(File.pathSeparator); + } + return result.toString(); + } + + + /** + * + */ + public void execute() throws MojoExecutionException + { + if ("pom".equalsIgnoreCase(project.getPackaging())) // Issue 17 + { + return; + } + + try + { + executeWithExceptionsHandled(); + } + catch (Exception e1) + { + super.getLog().error("error on execute: " + e1.getMessage()); + if (failOnError) + { + throw new MojoExecutionException("Error executing", e1); + } + } + + } + + @SuppressWarnings("unchecked") + private void executeWithExceptionsHandled() throws Exception + { + if (outputDirectory == null) + { + outputDirectory = getDefaultOutputDirectory(); + } + + ensureOutputDirectoryExists(); + addOutputToSourcesIfNeeded(); + + // new Debug(project).printDebugInfo(); + + java.io.File sourceDir = getSourceDirectory(); + if( sourceDir==null ) { + getLog().warn( "source directory cannot be read (null returned)! Processor task will be skipped"); + return; + } + if( !sourceDir.exists() ) { + getLog().warn( "source directory doesn't exist! Processor task will be skipped"); + return; + } + if( !sourceDir.isDirectory() ) { + getLog().warn( "source directory is invalid! Processor task will be skipped"); + return; + } + + final String includesString = ( includes==null || includes.length==0) ? "**/*.java" : StringUtils.join(includes, ","); + final String excludesString = ( excludes==null || excludes.length==0) ? null : StringUtils.join(excludes, ","); + + List files = FileUtils.getFiles(getSourceDirectory(), includesString, excludesString); + + Iterable< ? extends JavaFileObject> compilationUnits1 = null; + + + + String compileClassPath = buildCompileClasspath(); + + String processor = buildProcessor(); + + List options = new ArrayList(10); + + options.add("-cp"); + options.add(compileClassPath); + options.add("-proc:only"); + + addCompilerArguments(options); + + if (processor != null) + { + options.add("-processor"); + options.add(processor); + } + else + { + getLog().info("No processors specified. Using default discovery mechanism."); + } + options.add("-d"); + options.add(getOutputClassDirectory().getPath()); + + options.add("-s"); + options.add(outputDirectory.getPath()); + + + for (String option : options) + { + getLog().info("javac option: " + option); + } + + DiagnosticListener dl = null; + if (outputDiagnostics) + { + dl = new DiagnosticListener() + { + + public void report(Diagnostic< ? extends JavaFileObject> diagnostic) + { + getLog().info("diagnostic " + diagnostic); + + } + + }; + } + else + { + dl = new DiagnosticListener() + { + + public void report(Diagnostic< ? extends JavaFileObject> diagnostic) + { + } + + }; + } + + if (systemProperties != null) + { + java.util.Set< Map.Entry> pSet = systemProperties.entrySet(); + + for ( Map.Entry e : pSet ) + { + getLog().info( String.format("set system property : [%s] = [%s]", e.getKey(), e.getValue() )); + System.setProperty(e.getKey(), e.getValue()); + } + + } + + compileLock.lock(); + try { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + + if( compiler==null ) { + getLog().error("JVM is not suitable for processing annotation! ToolProvider.getSystemJavaCompiler() is null."); + return; + } + + StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); + + if( files!=null && !files.isEmpty() ) { + compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(files); + + } + else { + getLog().warn( "no source file(s) detected! Processor task will be skipped"); + return; + } + + + CompilationTask task = compiler.getTask( + new PrintWriter(System.out), + fileManager, + dl, + options, + null, + compilationUnits1); + + /* + * //Create a list to hold annotation processors LinkedList processors = new + * LinkedList(); + * + * //Add an annotation processor to the list processors.add(p); + * + * //Set the annotation processor to the compiler task task.setProcessors(processors); + */ + + // Perform the compilation task. + if (!task.call()) + { + + throw new Exception("error during compilation"); + } + } + finally { + compileLock.unlock(); + } + + } + + private void addCompilerArguments(List options) + { + if (!StringUtils.isEmpty(compilerArguments)) + { + for (String arg : compilerArguments.split(" ")) + { + if (!StringUtils.isEmpty(arg)) + { + arg = arg.trim(); + getLog().info("Adding compiler arg: " + arg); + options.add(arg); + } + } + } + if( optionMap!=null && !optionMap.isEmpty() ) { + for( java.util.Map.Entry e : optionMap.entrySet() ) { + + if( !StringUtils.isEmpty(e.getKey()) && e.getValue()!=null ) { + String opt = String.format("-A%s=%s", e.getKey().trim(), e.getValue().toString().trim()); + options.add( opt ); + getLog().info("Adding compiler arg: " + opt); + } + } + + } + } + + private void addOutputToSourcesIfNeeded() + { + final Boolean add = addOutputDirectoryToCompilationSources; + if (add == null || add.booleanValue()) + { + getLog().info("Source directory: " + outputDirectory + " added"); + addCompileSourceRoot(project, outputDirectory.getAbsolutePath()); + } + } + + protected abstract void addCompileSourceRoot(MavenProject project, String dir); + public abstract File getDefaultOutputDirectory(); + + private void ensureOutputDirectoryExists() + { + final File f = outputDirectory; + if (!f.exists()) + { + f.mkdirs(); + } + if( !getOutputClassDirectory().exists()) { + getOutputClassDirectory().mkdirs(); + } + } + + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/Debug.java b/src/main/java/org/bsc/maven/plugin/processor/Debug.java new file mode 100644 index 0000000..0f91c6b --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/Debug.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino + * + * This file is part of maven-annotation-plugin. + * + * maven-annotation-plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * maven-annotation-plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with maven-annotation-plugin. If not, see . + */ +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.util.Collection; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.project.MavenProject; + +/** + * Debug helpers + */ +class Debug +{ + private final MavenProject project; + + public Debug(MavenProject project) + { + if (project == null) + { + throw new IllegalArgumentException("Argument 'project' cannot be null"); + } + this.project = project; + } + + public void println(String name, Collection e) + { + System.out.println(name); + if (null == e) + { + return; + } + + for (T a : e) + { + System.out.printf("\t[%s] %s\n", a.getClass().getName(), a.toString()); + } + + } + + public void printDeps(String name, Collection dependencies) + { + System.out.println(name); + for (org.apache.maven.model.Dependency d : dependencies) + { + + System.out.printf("dependency [%s]\n", d.toString()); + + String versionlessKey = ArtifactUtils.versionlessKey(d.getGroupId(), d.getArtifactId()); + + Artifact artifact = (Artifact)project.getArtifactMap().get(versionlessKey); + + if (null != artifact) + { + File file = artifact.getFile(); + System.out.printf("artifact [%s]\n", file.getPath()); + } + } + } + + public void printDebugInfo() throws Exception //DependencyResolutionRequiredException + { + //println("project.getCompileClasspathElements", project.getCompileClasspathElements()); + println("project.getCompileArtifacts", project.getCompileArtifacts()); + println("project.getCompileDependencies", project.getCompileDependencies()); + println("project.getDependencyArtifacts", project.getDependencyArtifacts()); + println("project.getArtifactMap", project.getArtifactMap().keySet()); + println("project.getArtifacts", project.getArtifacts()); + printDeps("project.getRuntimeDependencies", project.getRuntimeDependencies()); + printDeps("project.getDependencies", project.getDependencies()); + } + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java new file mode 100644 index 0000000..e8cb807 --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino + * + * This file is part of maven-annotation-plugin. + * + * maven-annotation-plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * maven-annotation-plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with maven-annotation-plugin. If not, see . + */ +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.util.List; + +import org.apache.maven.model.Resource; +import org.apache.maven.project.MavenProject; + +/** + * + * @author bsorrentino + * + * @goal process + * @requiresDependencyResolution compile + * @phase generate-sources + */ +//@MojoGoal("process") +//@MojoRequiresDependencyResolution(value = "compile") +//@MojoPhase("generate-sources") +public class MainAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo +{ + /** + * project classpath + * + * @parameter expression = "${project.compileClasspathElements}" + * @required + * @readonly + */ + @SuppressWarnings("rawtypes") + //@MojoParameter(expression = "${project.compileClasspathElements}", required = true, readonly = true) + private List classpathElements; + + /** + * project sourceDirectory + * + * @parameter expression = "${project.build.sourceDirectory}" + * @required + */ + //@MojoParameter(expression = "${project.build.sourceDirectory}", required = true) + private File sourceDirectory; + + /** + * @parameter expression = "${project.build.directory}/generated-sources/apt" + * @required + */ + //@MojoParameter(expression = "${project.build.directory}/generated-sources/apt", required = true) + private File defaultOutputDirectory; + + /** + * Set the destination directory for class files (same behaviour of -d option) + * + * @parameter expression="${project.build.outputDirectory}" + */ + //@MojoParameter(required = false, expression="${project.build.outputDirectory}", description = "Set the destination directory for class files (same behaviour of -d option)") + private File outputClassDirectory; + + @Override + public File getSourceDirectory() + { + return sourceDirectory; + } + + @Override + protected File getOutputClassDirectory() + { + return outputClassDirectory; + } + + protected void addCompileSourceRoot(MavenProject project, String dir) + { + project.addCompileSourceRoot(dir); + } + + @Override + public File getDefaultOutputDirectory() + { + return defaultOutputDirectory; + } + + @Override + @SuppressWarnings("unchecked") + protected java.util.Set getClasspathElements( java.util.Set result) + { + List resources = project.getResources(); + + if( resources!=null ) { + for( Resource r : resources ) { + result.add(r.getDirectory()); + } + } + + result.addAll( classpathElements ); + + return result; + } + + +} diff --git a/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java new file mode 100644 index 0000000..e00535d --- /dev/null +++ b/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino + * + * This file is part of maven-annotation-plugin. + * + * maven-annotation-plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * maven-annotation-plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with maven-annotation-plugin. If not, see . + */ +package org.bsc.maven.plugin.processor; + +import java.io.File; +import java.util.List; + +import org.apache.maven.model.Resource; +import org.apache.maven.project.MavenProject; + +/** + * + * @author bsorrentino + * + * @goal process-test + * @requiresDependencyResolution test + * @phase generate-test-sources + */ +//@MojoGoal("process-test") +//@MojoRequiresDependencyResolution(value = "test") +//@MojoPhase("generate-test-sources") +public class TestAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo +{ + + /** + * project classpath + * + * @parameter expression = "${project.testClasspathElements}" + * @required + * @readonly + */ + @SuppressWarnings("rawtypes") + //@MojoParameter(expression = "${project.testClasspathElements}", required = true, readonly = true) + private List classpathElements; + + + /** + * + * @parameter expression = "${project.build.testSourceDirectory}" + * @required + */ + //@MojoParameter(expression = "${project.build.testSourceDirectory}", required = true) + private File sourceDirectory; + + /** + * @parameter expression = "${project.build.directory}/generated-sources/apt-test" + * @required + */ + //@MojoParameter(expression = "${project.build.directory}/generated-sources/apt-test", required = true) + private File defaultOutputDirectory; + + /** + * Set the destination directory for class files (same behaviour of -d option) + * + * @parameter expression="${project.build.testOutputDirectory}" + */ + //@MojoParameter(required = false, expression="${project.build.testOutputDirectory}", description = "Set the destination directory for class files (same behaviour of -d option)") + private File outputClassDirectory; + + @Override + public File getSourceDirectory() + { + return sourceDirectory; + } + + protected void addCompileSourceRoot(MavenProject project, String dir) + { + project.addTestCompileSourceRoot(dir); + } + + @Override + public File getDefaultOutputDirectory() + { + return defaultOutputDirectory; + } + + @Override + protected File getOutputClassDirectory() + { + return outputClassDirectory; + } + + + @SuppressWarnings("unchecked") + @Override + protected java.util.Set getClasspathElements( java.util.Set result ) + { + List resources = project.getTestResources(); + + if( resources!=null ) { + for( Resource r : resources ) { + result.add(r.getDirectory()); + } + } + + result.addAll( classpathElements ); + + return result; + } + + +} diff --git a/src/main/resources/.svn/all-wcprops b/src/main/resources/.svn/all-wcprops new file mode 100644 index 0000000..1e98719 --- /dev/null +++ b/src/main/resources/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 52 +/svn/!svn/ver/401/trunk/processor/src/main/resources +END +COPYING.LESSER +K 25 +svn:wc:ra_dav:version-url +V 67 +/svn/!svn/ver/401/trunk/processor/src/main/resources/COPYING.LESSER +END diff --git a/src/main/resources/.svn/entries b/src/main/resources/.svn/entries new file mode 100644 index 0000000..4652445 --- /dev/null +++ b/src/main/resources/.svn/entries @@ -0,0 +1,62 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/main/resources +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-12-05T09:40:22.524105Z +401 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + +COPYING.LESSER +file + + + + +2012-01-07T12:22:20.000000Z +e6a600fd5e1d9cbde2d983680233ad02 +2011-12-05T09:40:22.524105Z +401 +bartolomeo.sorrentino@gmail.com + + + + + + + + + + + + + + + + + + + + + +7651 + diff --git a/src/main/resources/.svn/text-base/COPYING.LESSER.svn-base b/src/main/resources/.svn/text-base/COPYING.LESSER.svn-base new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/src/main/resources/.svn/text-base/COPYING.LESSER.svn-base @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/src/main/resources/COPYING.LESSER b/src/main/resources/COPYING.LESSER new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/src/main/resources/COPYING.LESSER @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/src/site/.svn/all-wcprops b/src/site/.svn/all-wcprops new file mode 100644 index 0000000..1fd3282 --- /dev/null +++ b/src/site/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 42 +/svn/!svn/ver/390/trunk/processor/src/site +END +site.xml +K 25 +svn:wc:ra_dav:version-url +V 50 +/svn/!svn/ver/39/trunk/processor/src/site/site.xml +END diff --git a/src/site/.svn/entries b/src/site/.svn/entries new file mode 100644 index 0000000..5e13355 --- /dev/null +++ b/src/site/.svn/entries @@ -0,0 +1,72 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/site +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-08-21T11:51:58.138981Z +390 +bartolomeo.sorrentino + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + + + + + + +0 + +site.xml +file + + + + +2009-11-08T15:54:34.000000Z +dfc6e20c76c99870ff2807707a84f043 +2009-11-08T16:11:18.355901Z +39 +bartolomeo.sorrentino@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +1485 + +apt +dir + diff --git a/src/site/.svn/prop-base/site.xml.svn-base b/src/site/.svn/prop-base/site.xml.svn-base new file mode 100644 index 0000000..138f983 --- /dev/null +++ b/src/site/.svn/prop-base/site.xml.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 10 +text/plain +END diff --git a/src/site/.svn/text-base/site.xml.svn-base b/src/site/.svn/text-base/site.xml.svn-base new file mode 100644 index 0000000..369c710 --- /dev/null +++ b/src/site/.svn/text-base/site.xml.svn-base @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/site/apt/.svn/all-wcprops b/src/site/apt/.svn/all-wcprops new file mode 100644 index 0000000..737dd35 --- /dev/null +++ b/src/site/apt/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 46 +/svn/!svn/ver/390/trunk/processor/src/site/apt +END +usage.apt +K 25 +svn:wc:ra_dav:version-url +V 56 +/svn/!svn/ver/390/trunk/processor/src/site/apt/usage.apt +END diff --git a/src/site/apt/.svn/entries b/src/site/apt/.svn/entries new file mode 100644 index 0000000..389d2b4 --- /dev/null +++ b/src/site/apt/.svn/entries @@ -0,0 +1,69 @@ +10 + +dir +402 +https://maven-annotation-plugin.googlecode.com/svn/trunk/processor/src/site/apt +https://maven-annotation-plugin.googlecode.com/svn + + + +2011-08-21T11:51:58.138981Z +390 +bartolomeo.sorrentino + + + + + + + + + + + + + + +f19866a6-d851-11dd-a412-a1792178251d + + + + + + +0 + +usage.apt +file + + + + +2011-08-21T11:56:20.000000Z +db647e98a52bb44a68b4fffdb9a86425 +2011-08-21T11:51:58.138981Z +390 +bartolomeo.sorrentino + + + + + + + + + + + + + + + + + + + + + +5479 + diff --git a/src/site/apt/.svn/text-base/usage.apt.svn-base b/src/site/apt/.svn/text-base/usage.apt.svn-base new file mode 100644 index 0000000..3db60a5 --- /dev/null +++ b/src/site/apt/.svn/text-base/usage.apt.svn-base @@ -0,0 +1,225 @@ + + +Repository + + To use this plugin you have to include the following repository declaration in your POM + ++-------------------------------------------+ + + + + + + + + + sonatype-repo + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + + + + ++-------------------------------------------+ + +Usage + + <> + + Sources will be generated into target/generated-sources/apt/main/java + Test sources into target/generated-sources/apt/test/java + Both directories will be added to the compilation path + ++-------------------------------------------+ + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + + + + org.bsc.maven + maven-processor-plugin + + + process-test + + process-test + + generate-test-sources + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + -proc:none + + + + + + ++-------------------------------------------+ + + <> + + Generating sources into src/main/generated directory. This strategy is good if you wish to check in your generated sources into your SCM. + Run mvn generate-sources to generate the sources. + ++-------------------------------------------+ + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + src/main/generated + + + + + + + ++-------------------------------------------+ + + <> + + Running specific annotation processors only. + ++-------------------------------------------+ + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + + + org.bsc.apt.BeanInfoAnnotationProcessor + + + + + + + + + ++-------------------------------------------+ + + <> + + Passing options to processors + ++-------------------------------------------+ + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + -Amyoption=TRUE + + + + TRUE + + + + + + + + + ++-------------------------------------------+ + + <> + + Set System Properties + ++-------------------------------------------+ + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + + true + + + + + + + + + ++-------------------------------------------+ + diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt new file mode 100644 index 0000000..3db60a5 --- /dev/null +++ b/src/site/apt/usage.apt @@ -0,0 +1,225 @@ + + +Repository + + To use this plugin you have to include the following repository declaration in your POM + ++-------------------------------------------+ + + + + + + + + + sonatype-repo + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + + + + ++-------------------------------------------+ + +Usage + + <> + + Sources will be generated into target/generated-sources/apt/main/java + Test sources into target/generated-sources/apt/test/java + Both directories will be added to the compilation path + ++-------------------------------------------+ + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + + + + org.bsc.maven + maven-processor-plugin + + + process-test + + process-test + + generate-test-sources + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + -proc:none + + + + + + ++-------------------------------------------+ + + <> + + Generating sources into src/main/generated directory. This strategy is good if you wish to check in your generated sources into your SCM. + Run mvn generate-sources to generate the sources. + ++-------------------------------------------+ + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + src/main/generated + + + + + + + ++-------------------------------------------+ + + <> + + Running specific annotation processors only. + ++-------------------------------------------+ + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + + + org.bsc.apt.BeanInfoAnnotationProcessor + + + + + + + + + ++-------------------------------------------+ + + <> + + Passing options to processors + ++-------------------------------------------+ + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + -Amyoption=TRUE + + + + TRUE + + + + + + + + + ++-------------------------------------------+ + + <> + + Set System Properties + ++-------------------------------------------+ + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + + true + + + + + + + + + ++-------------------------------------------+ + diff --git a/src/site/site.xml b/src/site/site.xml new file mode 100644 index 0000000..369c710 --- /dev/null +++ b/src/site/site.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +