On 04/19/2011 11:11 PM, Rick Genter wrote:
> I'm building an archetype for generating Maven projects for our
> custom application framework. Everything is working but the generated
> project always has the same class names and annotations. I would like
> to be able to dynamically specify those names/annotations.
[...]
> but what I'd like to do is something like this:
>
> package ${packageName};
>
> // imports go here...
>
> @OurAnnotation(client="${client}", application="${clientApp}",
> version="${clientAppVersion}") public class ${clientApp} extends
> OurBaseClass { ... }
>
> I tried the above and using:
>
> mvn archetype:generate -DarchetypeGroupId=...
> -DarchetypeArtifactId=... -DarchetypeVersion=... -Dclient=Acme
> -DclientApp=HelloWorld6 -DclientAppVersion=1.0.0-SNAPSHOT
> -DgroupId=net.interactions.example -Dversion=0.0.1-SNAPSHOT
> -DartifactId=hello-world-6
>
> my generated ClientApp.java file had the correct package name
> (net.interactions.example), but none of the other substitutions were
> performed. Also, I'd need the generated file itself to have the
> correct name (${clientApp}.java). I'd have preferred that the
> generated file be named "HelloWorld6.java" and have the content:
Yes this is possible. Name the Java class in the archetype
__clientApp__.java and the archetype should fill in the proper variable
name. You need to specify the clientApp property in the
archetype-metadata.xml to enable the substitution.
-dirk
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]