On 2007-07-04 03:02:29 +0200, Brett Porter <[EMAIL PROTECTED]> said:

On 04/07/2007, at 5:21 AM, Eric Redmond wrote:

Post-compilation annotation extraction actually handles this case.

http://jira.codehaus.org/browse/MNG-2521

MNG-2521 takes care of it partially. Since at runtime, missing annotation properties are initialized with the default value, it is impossible to decide if a property was overwritten. To get around that, MNG-2521 would have specify special proeprty values for "inherit from SuperMojo".


That sounds much better than requiring additional annotations.

For the default case, you wouldn't need any. Currently we assume that there is only one Mojo descriptor per Mojo class, since the current extractors work this way. Another proposal I made adresses this, or I can write a descriptor manually. When there are two descriptors for a parent class, we need an additional annotation for the descriptor we want to use as prototype.

Regards,
Jochen



Eric

On 7/3/07, Jochen Kuhnle <[EMAIL PROTECTED] > wrote:

Hi,

here's the second one:

With the current Mojo descriptor extractor, it is possible to inherit
Mojo annotations from parent classes, but not across projects. With
this, it is e.g. not possible to subclass a "built-in" Maven mojo and
inherit the annotations, or to refactor common Mojo code into a
separate "Base Mojo" project, because the subclass lives in a  different
project. Since the annotation inheritance also only looks at parent
classes, it is not possible to have annotated Mojo interfaces,  e.g. for
a Compiler which has different implementations.

To allow this, it should be possible to specify a list of prototypes
for a Mojo. The descriptor extractor would then load the  descriptors of
these prototypes (from the plugin.xml) and merge them into a base
descriptor for the Mojo, allowing it to inherit the annotations.

Example with MNG-2521 annotations:

@Goal(goal = "clustered")
public interface ClusteredMojo {
        @MojoParameter
        private void setClusterController(String controller) {
                //...
        }
}

@Goal(goal = "compile", prototypes =
[EMAIL PROTECTED](groupId="org.apache.maven.plugin ",
artifactId="maven-compiler-plugin", goal="compile"),
@Prototype(goal="clustered")} )
public class MyCompilerMojo extends CompilerMojo implements  ClusteredMojo
{
        // ...
}

For convenience, the groupId and artifactId default to the current
project's values, and the goal to the current annotation's goal.

For this to work, the descriptor extractors should also create
descriptors for annotated interfaces and abstract classes. These  should
be written into the plugin.xml and filtered out by the
PluginDiscoverer, so they cannot be accessed normally.

Regards,
Jochen




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




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




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to