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.
Visit our website at http://www.ubs.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

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

Reply via email to