Rems February 2016

Specify dependency version for Maven Archetype plugin

I am currently working with Maven 3.3.3, from which the mvn.bat file has been removed. The recommended and only way to run Maven is now through the mvn.cmd file.

I am using a custom archetype that calls the maven-invoker plugin for some operation. Note that the invoker plugin is a dependency of the Maven archetype plugin.

On archetype:generate, the invoker is called and throws an error :

Error configuring command-line. Reason: Maven executable not found at: <MAVEN_PATH>\bin\mvn.bat

This issue seems to have been fixed with the release 2.2 of the invoker, but the last version of maven-archetype-plugin still uses an old version of it.

How can I specify, in my archetype's POM, the version of the invoker plugin to use ?

For now, I've tried to configure the plugin by adding this code into the archetype's POM file, but it had no effect, and didn't fixed the error.

<plugin>
    <groupId>org.apache.maven.archetype</groupId>
    <artifactId>maven-archetype</artifactId>
    <version>2.4</version>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-invoker</artifactId>
            <version>2.2</version>
        </dependency>
    </dependencies>
</plugin>

EDIT 1 : Here's the filtered stack trace.

[INFO] Invoking post-archetype-generation goals: com.company.my-custom-maven-plugin:uuid-generator
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] -----------------------------------------------------------        

Answers


Tunaki February 2016

This is a bug of the Maven Archetype Plugin: the JIRA issue is ARCHETYPE-488. It affects all versions of the plugin <= 2.4 and is currently unresolved.

Quoting Jörg Hohwiller in the linked issue (dated 08-Jan-2016 13:47):

Is there a workaround for it?

Yep. Just create a copy of "mvn.cmd" that you call "mvn.bat" in MAVEN_HOME/bin.

So a possible work-around for now is just to make a copy of the mvn executable with the other name.

Post Status

Asked in February 2016
Viewed 3,642 times
Voted 5
Answered 1 times

Search




Leave an answer