I created an archetype where you can set the moduleName (or expect to) using a required property moduleName, here is the archetype metadata xml (reduced, which I also tried with similar results)
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="modules-archetype">
<requiredProperties>
<requiredProperty key="moduleName">
</requiredProperty>
</requiredProperties>
<modules>
<module id="modules-${moduleName}-api"
dir="modules-__moduleName__-api"
name="modules-${moduleName}-api">
<fileSets>
<fileSet encoding="UTF-8">
<directory>src/main/java</directory>
</fileSet>
</fileSets>
</module>
</modules>
</archetype-descriptor>
After installing and generating, the moduleName value is not used in the directory name or the artifactid, the resuting values are
For the directory: project/module-__moduleName__-api
For the pom/artifactId: module-${moduleName}-api
The value is replaced correctly on some other files of the project, so no spelling problems I guess.
I've seen a lot of similar things, but all of them using rootArtifactId, and in fact if I use rootArtifactId (as the starting part of the name) it works as expected.
Not able to find a similar problem around, any idea why is it not working, or how to make it work?
I found a reasonable work-around.
Seems the only place where you can only use the rootArtifactId is the
<module>
element in the archetype descriptor, but in every other
place you can use the moduleName property without any trouble.
What I did:
Use ${moduleName} in
(<module>module-${moduleName}</module>)
Use __moduleName__ in
In the artifact descriptor
Things to fix after the project is created
All of this in a ant script embedded in a postcreate-pom.xml to be run after project creation.
And it worked smoothly.
Hope its useful for someone.
thanks to everybody that just take the time to read my question, tonio.
archetype-metadata.xml and the pom.xml of the sub-module:
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="multi-module">
<modules>
<module name="${rootArtifactId}-ria" id="${rootArtifactId}-ria" dir="__rootArtifactId__-ria">
<fileSets>
<fileSet filtered="true" packaged="true">
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="true">
<include>pom.xml</include>
</fileSet>
</fileSets>
</module>
</modules>
</archetype-descriptor>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>${groupId}</groupId>
<artifactId>${rootArtifactId}</artifactId>
<version>${version}</version>
</parent>
<artifactId>${artifactId}</artifactId>
<packaging>war</packaging>
</project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With