Creating the Maven archetype: pom prototype

I am creating the maven archetype. In this case, I have a prototype project that is created for the user when the user calls the following command:

mvn archetype: generate-DarchetypeGroupId = xxx -DarchetypeArtifactId = archtype-yyyy -DarchetypeVersion = 1.1.0-S5-SNAPSHOT -DgroupId = zzz -DartifactId = proj11

In the pom prototype, I want to use the archetypeVersion property, which I specify in the command above. Like this:

<dependencies>
    <dependency>
        <groupId>mmmm</groupId>
        <artifactId>nte</artifactId>
        <version>${archetypeVersion}</version>
    </dependency>

This does not work for me. When a project is created, it still shows a fragment of dependencies in the generated pom in the same way as above. He does not replace him.

Is it possible? Does it allow you to do this? If so, how can I do this?

+3
source share
1 answer

, - maven-replacer-plugin. archetype/pom.xml:

<build>
    ...
    <plugins>
        <plugin>
            <groupId>com.google.code.maven-replacer-plugin</groupId>
            <artifactId>replacer</artifactId>
            <version>1.5.2</version>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals><goal>replace</goal></goals> 
                </execution>
            </executions>
            <configuration>
                <file>target/classes/archetype-resources/pom.xml</file>
                <replacements>
                    <replacement>
                        <token>\$\{archetypeVersion\}</token>
                        <value>${version}</value>
                    </replacement> 
                </replacements>
            </configuration>
        </plugin>
    </plugins>
    ...
<build>

.. ${archetypeVersion} . /src/main/resources/archetype -resources/pom.xml :

<dependency>
    <groupId>xxxx</groupId>
    <artifactId>yyyy</artifactId>
    <version>${archetypeVersion}</version>
</dependency>

"mvn install" "/target/classes/archetype-resources/pom.xml . :" mvn archetype: generate....

+2

All Articles