Daniil Iaitskov
Daniil Iaitskov

Reputation: 6039

How to invoke specific execution

I am trying to replace maven exec with MavenInvokerPlugin because of problems on Jenkins with forwarding the maven settings file.

So in bash it looks straight:

mvn dependency:copy-dependencies@resolve-maven-deps 

My translation to MavenInvokerPlugin configuration is

             <plugin>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <projectsDirectory>${project.basedir}/src/main/docker</projectsDirectory>
                    <localRepositoryPath>${project.build.mavenDependencies}</localRepositoryPath>
                    <goal>dependency:copy-dependencies@resolve-maven-deps</goal>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>                                 
                            <goal>run</goal>
                        </goals>
                        <phase>compile</phase>
                    </execution>
                </executions>
            </plugin> 

It looks like that execution id is completely ignored, because I tried random strings and mvn builds the project with success.

mvn dependency:copy-dependencies@asdfasdfa 

So I'd like to know whether this feature is supported at all and what I am doing wrong.

P.S. I know that calling maven out of maven is anti pattern, but here is exactly that rare case when there is no other way.

Upvotes: 0

Views: 151

Answers (1)

Daniil Iaitskov
Daniil Iaitskov

Reputation: 6039

After looking at projects using maven invoker I figured out the trick.

goal tag is not used, instead provide invokerPropertiesFile:

<pom>${project.basedir}/xxx/pom.xml</pom>    
<invokerPropertiesFile>${project.basedir}/invoker.properties</invokerPropertiesFile>

content of the file:

invoker.goals=compile -P resolve-maven-deps 

Upvotes: 0

Related Questions