Let me know if there is an easier way.. :)

As the velocity templates are first copied from src/main/resources to
target/classes - I ended up combining it with Maven Resource filtering

http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

And then I could actually do

<taverna.language.version>${taverna.language.version}</taverna.language.version>
<taverna.engine.version>${project.parent.version}</taverna.engine.version>

And use them as

<version>\${taverna.osgi.version}</version>




As there are then 3-4 systems all using $variables I had to use
\-escaping of the Velocity templates to prevent Maven Resources from
injecting too much, e.g.

\${groupId}

so that the velocity template in target/classes contains ${groupId}
and finally after running the archetype contains the user-provided
groupId.

On 16 May 2016 at 11:37, Stian Soiland-Reyes <[email protected]> wrote:
> Hi,
>
> We have a sub-module that is a Maven Archetype.
>
> Within the generated pom.xml I want to set some <properties> for versions:
>
> https://github.com/apache/incubator-taverna-engine/blob/master/taverna-activity-archetype/src/main/resources/archetype-resources/pom.xml#L32
>
>
> However I don't want to have to hard-code the versions within the
> template pom.xml, but would rather want it to be inherited from the
> <properties> in the parent of the archetype - that is so it running
> the archetype would generate <properties> with actual version numbers
> - but in the template pom.xml it would be something like
>
> <taverna.language.version>${taverna.language.version}</taverna.language.version>
>
>
> This is particularly important for our property taverna.engine.version
> which must stay in -SNAPSHOT during development to make the test work:
> https://github.com/apache/incubator-taverna-engine/tree/master/taverna-activity-archetype/src/test/resources/projects/dummyActivity
>
> ..but should change to a release version once releasing.
>
>
> How can I achieve this?
>
> I tried adding to META-INF/maven/archetype-metadata.xml
>
>                 <requiredProperty key="tavernaEngineVersion">
>                         <defaultValue>${project.parent.version}</defaultValue>
>                 </requiredProperty>
>
> but then the test fails:
>
> [INFO] 
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-archetype-plugin:2.4:integration-test
> (default-integration-test) on project taverna-activity-archetype:
> [ERROR] Archetype IT 'dummyActivity' failed: Missing required
> properties in archetype.properties: tavernaEngineVersion
>
>
> obviously I can't just hard-code the version number in
> archetypes.properties - as that would just
> move the problem.
>
>
> Any ideas?
>
> --
> Stian Soiland-Reyes
> Apache Taverna (incubating), Apache Commons RDF (incubating)
> http://orcid.org/0000-0001-9842-9718



-- 
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons RDF (incubating)
http://orcid.org/0000-0001-9842-9718

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to