You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Im...@ubs.com on 2006/12/18 14:29:33 UTC
Accessing plugin properties within a Mojo source file?
I wonder if anyone else is struggling to understand the limitations of
the @parameter expression="..." default-value="..." construct.
I would like to create a generated-sources pathname in a Mojo plugin
that translates from a domain-specific language into Java. The
translator exists as a stand-alone at the moment. I understand that the
plugin should generate sources into
${project.build.directory}/generated-sources/${plugin.prefix} - but I
can't seem to find out what the plugin prefix is programmatically. For
the moment, I have hard-coded the default prefix value in the Mojo
itself, but this seems to go against the spirit of specifying things in
configurable ways.
I have tried using the following recipe to set the ${prefix} property in
the plugin's pom.xml file, as documented in
http://maven.apache.org/guides/introduction/introduction-to-plugin-prefi
x-mapping.html:
<build>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<configuration>
<goalPrefix>myplugin</goalPrefix>
</configuration>
</plugin>
</plugins>
</build>
...but specifying "${prefix}" as the value for @parameter expression
within the plugin's Mojo source results in the default value.
Even if I found out a way to set the prefix explicitly through the
project POM, it turns out that you still can't use it as a property in
another expression or default-value. I specified another private
variable as @parameter expression="${project.generated.directory}"
default-value="${project.build.directory}/generated-sources/${prefix}"
and got the result ".../target/generated-sources/null".
Surely both these behaviours go against the Don't Repeat Yourself (DRY)
principle. Any help would be much appreciated.
Immo Huneke.