You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jochen Kuhnle <jo...@kuhnle.net> on 2007/06/25 12:41:12 UTC

Using JDK 1.5+ annotations for mojos, another patch (MNG-2521)

Hi,

I'd like to put another patch up for discussion. I have attached [1] 
and [2] to the Jira issue. These patches provide (yet another :-) 
extension to use JDK 1.5+ annotations for Mojos. The consist of the 
annotations [1] and a new descriptor extractor [2] that uses QDOX 1.6.3.

The main features are:

1.  Multi-Mojo annotations. After writing a dozen plugins where I had 
to use subclassing to supply to Mojos of the same kind in two different 
configurations (like AbstractCompilerMojo, CompilerMojo and 
TestCompilerMojo), I extended the annotations to allow a class to be 
annotated with two different goals.

2. Mojo inheritance (rather: prototypes): With this, you can specify 
prototype Mojos from which your Mojos inherits decriptor and parameter 
properties. Now you can extend a Maven Mojo without duplicating all 
annotations. Mojo and parameter annotations can be overwritten, of 
course.

Regards,
Jochen

Examples:

Multi-Mojo-Annotation

@MojoClasses( {
    @MojoClass( goal = "compile", phase = "compile", 
dependencyResolutionRequired = Phase.COMPILE,
    @MojoClass( goal = "test-compile", phase = "test-compile", 
dependencyResolutionRequired = Phase.TEST} )

Prototypes:

@MojoClass( goal = "compile", phase = "compile", prototypes = 
"org.apache.maven.plugin:maven-compiler-plugin:compile" )

Parameter Override:

To overried prototype parameters, you can use the class-level 
annotations for parameters or components:

@MojoParameters( @MojoParameter(name = "verbose", defaultValue = Bool.TRUE )

Usage:

To use the patches, you should add the following to your pom.xml:

<plugin>
    <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-plugin-plugin</artifactId>
    <extensions>true</extensions>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-tools-java5</artifactId>
            <version>SNAPSHOT</version>
        </dependency>
    </dependencies>
</plugin>

You should also apply QDOX patches [3] and [4].

The patches were tested with Maven 2.0.5 and 2.0.7. They do not run 
with 2.0.6 yet.

[1] 
http://jira.codehaus.org/secure/attachment/28141/maven-plugin-tools-annotations.tar.gz
[2] 

http://jira.codehaus.org/secure/attachment/28142/maven-plugin-tools-java5.tar.gz
[3] 

http://jira.codehaus.org/browse/QDOX-123
[4] http://jira.codehaus.org/browse/QDOX-122



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Using JDK 1.5+ annotations for mojos, another patch (MNG-2521)

Posted by Jochen Kuhnle <jo...@kuhnle.net>.
On 2007-06-25 17:07:37 +0200, Jason van Zyl <ja...@maven.org> said:

> 
> On 25 Jun 07, at 3:41 AM 25 Jun 07, Jochen Kuhnle wrote:
> 
>> Hi,
>> 
>> I'd like to put another patch up for discussion. I have attached  [1] 
>> and [2] to the Jira issue. These patches provide (yet  another :-) 
>> extension to use JDK 1.5+ annotations for Mojos. The  consist of the 
>> annotations [1] and a new descriptor extractor [2]  that uses QDOX 
>> 1.6.3.
>> 
>> The main features are:
>> 
>> 1.  Multi-Mojo annotations. After writing a dozen plugins where I  had 
>> to use subclassing to supply to Mojos of the same kind in two  
>> different configurations (like AbstractCompilerMojo, CompilerMojo  and 
>> TestCompilerMojo), I extended the annotations to allow a class  to be 
>> annotated with two different goals.
>> 
>> 2. Mojo inheritance (rather: prototypes): With this, you can  specify 
>> prototype Mojos from which your Mojos inherits decriptor  and parameter 
>> properties. Now you can extend a Maven Mojo without  duplicating all 
>> annotations. Mojo and parameter annotations can be  overwritten, of 
>> course.
>> 
> 
> How is any of this different then what's in the branch? Look at the  
> dashboard for a description of the work. Eric and Kenney have worked  
> on something and it's in a branch I started trying to integrate so  
> work with them to integrate any difference.

It's prototypes and multi-mojo-annotations I wanted to put up for 
discussion (and demonstrate, since the code was there). If the concept 
is accepted, I will gladly supply a patch to integrate this into the 
the existing code.

Regards,
Jochen



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Using JDK 1.5+ annotations for mojos, another patch (MNG-2521)

Posted by Jason van Zyl <ja...@maven.org>.
On 25 Jun 07, at 3:41 AM 25 Jun 07, Jochen Kuhnle wrote:

> Hi,
>
> I'd like to put another patch up for discussion. I have attached  
> [1] and [2] to the Jira issue. These patches provide (yet  
> another :-) extension to use JDK 1.5+ annotations for Mojos. The  
> consist of the annotations [1] and a new descriptor extractor [2]  
> that uses QDOX 1.6.3.
>
> The main features are:
>
> 1.  Multi-Mojo annotations. After writing a dozen plugins where I  
> had to use subclassing to supply to Mojos of the same kind in two  
> different configurations (like AbstractCompilerMojo, CompilerMojo  
> and TestCompilerMojo), I extended the annotations to allow a class  
> to be annotated with two different goals.
>
> 2. Mojo inheritance (rather: prototypes): With this, you can  
> specify prototype Mojos from which your Mojos inherits decriptor  
> and parameter properties. Now you can extend a Maven Mojo without  
> duplicating all annotations. Mojo and parameter annotations can be  
> overwritten, of course.
>

How is any of this different then what's in the branch? Look at the  
dashboard for a description of the work. Eric and Kenney have worked  
on something and it's in a branch I started trying to integrate so  
work with them to integrate any difference.

http://docs.codehaus.org/display/MAVEN/Home

Specifically the "Java 5 Annotations for Plugins"

> Regards,
> Jochen
>
> Examples:
>
> Multi-Mojo-Annotation
>
> @MojoClasses( {
>    @MojoClass( goal = "compile", phase = "compile",  
> dependencyResolutionRequired = Phase.COMPILE,
>    @MojoClass( goal = "test-compile", phase = "test-compile",  
> dependencyResolutionRequired = Phase.TEST} )
>
> Prototypes:
>
> @MojoClass( goal = "compile", phase = "compile", prototypes =  
> "org.apache.maven.plugin:maven-compiler-plugin:compile" )
>
> Parameter Override:
>
> To overried prototype parameters, you can use the class-level  
> annotations for parameters or components:
>
> @MojoParameters( @MojoParameter(name = "verbose", defaultValue =  
> Bool.TRUE )
>
> Usage:
>
> To use the patches, you should add the following to your pom.xml:
>
> <plugin>
>    <inherited>true</inherited>
>    <groupId>org.apache.maven.plugins</groupId>
>    <artifactId>maven-plugin-plugin</artifactId>
>    <extensions>true</extensions>
>    <dependencies>
>        <dependency>
>            <groupId>org.apache.maven</groupId>
>            <artifactId>maven-plugin-tools-java5</artifactId>
>            <version>SNAPSHOT</version>
>        </dependency>
>    </dependencies>
> </plugin>
>
> You should also apply QDOX patches [3] and [4].
>
> The patches were tested with Maven 2.0.5 and 2.0.7. They do not run  
> with 2.0.6 yet.
>
> [1] http://jira.codehaus.org/secure/attachment/28141/maven-plugin- 
> tools-annotations.tar.gz
> [2]
> http://jira.codehaus.org/secure/attachment/28142/maven-plugin-tools- 
> java5.tar.gz
> [3]
> http://jira.codehaus.org/browse/QDOX-123
> [4] http://jira.codehaus.org/browse/QDOX-122
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder and PMC Chair, Apache Maven
jason at sonatype dot com
----------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Using JDK 1.5+ annotations for mojos, another patch (MNG-2521)

Posted by Jochen Kuhnle <jo...@kuhnle.net>.
On 2007-06-25 17:22:36 +0200, "Eric Redmond" <er...@gmail.com> said:

> 
> This was my first course of action - and still the preferred as it it
> pre-compilation. However, there are a couple problems using QDox - which I'd
> be interested to know about if you have overcome them:
> 
> 1) Referring to constants that exist in compiled dependencies
> 
> 2) Amalgamated values, such as:
> 
> @Goal( name = SomeObject.GOAL + "-" + ( 5 * 3 ) + "-" + OtherObject.SUFFIX )
> 
> The first is hackable, the latter is what made me shy away from continuing
> with QDox. Not impossible, but necessary.

Since both cases do not work with the current JavaDoc annotations, I 
chose to ignore them at first ;-) They are valid Java5 syntax, yes, but 
I don't think we need to support them immediatly

It's more the multi-mojo annotations and the prototypes I wanted to put 
up for discussion. And I, too, think that qdox pre-compilation would be 
better, most of all since the class file contains no mojo or parameter 
descriptions. And I think it's better to evolve qdox, since we might 
want to have general annotations processing without the sun jdk some 
day, too.

If the concept is accepted, I will gladly help to hack away at qdox. 
There sure is work to do there...

Regards,
Jochen

> 
> Eric
> 
> On 6/25/07, Jochen Kuhnle <jo...@kuhnle.net> wrote:
>> 
>> Hi,
>> 
>> I'd like to put another patch up for discussion. I have attached [1]
>> and [2] to the Jira issue. These patches provide (yet another :-)
>> extension to use JDK 1.5+ annotations for Mojos. The consist of the
>> annotations [1] and a new descriptor extractor [2] that uses QDOX 1.6.3.
>> 
>> The main features are:
>> 
>> 1.  Multi-Mojo annotations. After writing a dozen plugins where I had
>> to use subclassing to supply to Mojos of the same kind in two different
>> configurations (like AbstractCompilerMojo, CompilerMojo and
>> TestCompilerMojo), I extended the annotations to allow a class to be
>> annotated with two different goals.
>> 
>> 2. Mojo inheritance (rather: prototypes): With this, you can specify
>> prototype Mojos from which your Mojos inherits decriptor and parameter
>> properties. Now you can extend a Maven Mojo without duplicating all
>> annotations. Mojo and parameter annotations can be overwritten, of
>> course.
>> 
>> Regards,
>> Jochen
>> 
>> Examples:
>> 
>> Multi-Mojo-Annotation
>> 
>> @MojoClasses( {
>> @MojoClass( goal = "compile", phase = "compile",
>> dependencyResolutionRequired = Phase.COMPILE,
>> @MojoClass( goal = "test-compile", phase = "test-compile",
>> dependencyResolutionRequired = Phase.TEST} )
>> 
>> Prototypes:
>> 
>> @MojoClass( goal = "compile", phase = "compile", prototypes =
>> "org.apache.maven.plugin:maven-compiler-plugin:compile" )
>> 
>> Parameter Override:
>> 
>> To overried prototype parameters, you can use the class-level
>> annotations for parameters or components:
>> 
>> @MojoParameters( @MojoParameter(name = "verbose", defaultValue = Bool.TRUE)
>> 
>> Usage:
>> 
>> To use the patches, you should add the following to your pom.xml:
>> 
>> <plugin>
>> <inherited>true</inherited>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-plugin-plugin</artifactId>
>> <extensions>true</extensions>
>> <dependencies>
>> <dependency>
>> <groupId>org.apache.maven</groupId>
>> <artifactId>maven-plugin-tools-java5</artifactId>
>> <version>SNAPSHOT</version>
>> </dependency>
>> </dependencies>
>> </plugin>
>> 
>> You should also apply QDOX patches [3] and [4].
>> 
>> The patches were tested with Maven 2.0.5 and 2.0.7. They do not run
>> with 2.0.6 yet.
>> 
>> [1]
>> 
>> http://jira.codehaus.org/secure/attachment/28141/maven-plugin-tools-annotations.tar.gz
[2]


http://jira.codehaus.org/secure/attachment/28142/maven-plugin-tools-java5.tar.gz
[3]

http://jira.codehaus.org/browse/QDOX-123
[4] 
>> 
>> http://jira.codehaus.org/browse/QDOX-122
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Using JDK 1.5+ annotations for mojos, another patch (MNG-2521)

Posted by Eric Redmond <er...@gmail.com>.
This was my first course of action - and still the preferred as it it
pre-compilation. However, there are a couple problems using QDox - which I'd
be interested to know about if you have overcome them:

1) Referring to constants that exist in compiled dependencies

2) Amalgamated values, such as:

@Goal( name = SomeObject.GOAL + "-" + ( 5 * 3 ) + "-" + OtherObject.SUFFIX )

The first is hackable, the latter is what made me shy away from continuing
with QDox. Not impossible, but necessary.

Eric

On 6/25/07, Jochen Kuhnle <jo...@kuhnle.net> wrote:
>
> Hi,
>
> I'd like to put another patch up for discussion. I have attached [1]
> and [2] to the Jira issue. These patches provide (yet another :-)
> extension to use JDK 1.5+ annotations for Mojos. The consist of the
> annotations [1] and a new descriptor extractor [2] that uses QDOX 1.6.3.
>
> The main features are:
>
> 1.  Multi-Mojo annotations. After writing a dozen plugins where I had
> to use subclassing to supply to Mojos of the same kind in two different
> configurations (like AbstractCompilerMojo, CompilerMojo and
> TestCompilerMojo), I extended the annotations to allow a class to be
> annotated with two different goals.
>
> 2. Mojo inheritance (rather: prototypes): With this, you can specify
> prototype Mojos from which your Mojos inherits decriptor and parameter
> properties. Now you can extend a Maven Mojo without duplicating all
> annotations. Mojo and parameter annotations can be overwritten, of
> course.
>
> Regards,
> Jochen
>
> Examples:
>
> Multi-Mojo-Annotation
>
> @MojoClasses( {
>     @MojoClass( goal = "compile", phase = "compile",
> dependencyResolutionRequired = Phase.COMPILE,
>     @MojoClass( goal = "test-compile", phase = "test-compile",
> dependencyResolutionRequired = Phase.TEST} )
>
> Prototypes:
>
> @MojoClass( goal = "compile", phase = "compile", prototypes =
> "org.apache.maven.plugin:maven-compiler-plugin:compile" )
>
> Parameter Override:
>
> To overried prototype parameters, you can use the class-level
> annotations for parameters or components:
>
> @MojoParameters( @MojoParameter(name = "verbose", defaultValue = Bool.TRUE)
>
> Usage:
>
> To use the patches, you should add the following to your pom.xml:
>
> <plugin>
>     <inherited>true</inherited>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-plugin-plugin</artifactId>
>     <extensions>true</extensions>
>     <dependencies>
>         <dependency>
>             <groupId>org.apache.maven</groupId>
>             <artifactId>maven-plugin-tools-java5</artifactId>
>             <version>SNAPSHOT</version>
>         </dependency>
>     </dependencies>
> </plugin>
>
> You should also apply QDOX patches [3] and [4].
>
> The patches were tested with Maven 2.0.5 and 2.0.7. They do not run
> with 2.0.6 yet.
>
> [1]
>
> http://jira.codehaus.org/secure/attachment/28141/maven-plugin-tools-annotations.tar.gz
> [2]
>
>
> http://jira.codehaus.org/secure/attachment/28142/maven-plugin-tools-java5.tar.gz
> [3]
>
> http://jira.codehaus.org/browse/QDOX-123
> [4] http://jira.codehaus.org/browse/QDOX-122
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


-- 
Eric Redmond
http://www.sonatype.com