2

According to the docs, maven-invoker-plugin is "thread-safe and supports parallel builds." However, when I build by multi-module project with -T 1C, I get an error like the following:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-invoker-plugin:1.10:install (integration-test) on project my-archetype: Failed to install project dependencies: MavenProject: com.tavianator:my-archetype:1.6-SNAPSHOT @ /home/tavianator/code/Project/my-archetype/pom.xml: Failed to install project artifacts: MavenProject: com.tavianator:my-project:1.6-SNAPSHOT @ /home/tavianator/code/Project/my-project/pom.xml: Failed to install artifact: com.tavianator:my-project:jar:1.6-SNAPSHOT: Artifact is not fully assembled: /home/tavianator/code/Project/my-project/target/classes -> [Help 1]

The project layout is like this:

Root
|--Project 1
|--Project 2
|--Archetype (depends on Project 1, scope=test)

The archetype integration tests use the maven-invoker-plugin to install the relevant dependencies (Root and Project 1) to a local repository, then runs the normal archetype integration tests. In parallel builds, Archetype and Project 2 run at the same time. When the maven-invoker-plugin runs, it tries to install Project 2 to the local repo, but Project 2 isn't built yet, hence the error.

But since Project 2 isn't even needed for the tests, I should be able to work around the problem by explicitly installing only the needed dependencies. I don't see how to get the invoker plugin to do that, but is there another plugin I can use?

I reported the maven-invoker-plugin bug here. I have an example project that demonstrates the error here.

Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
  • I'm a little bit confused. Are you trying to do integration tests for archetypes? Can you show the full pom files? Apart from that where have you defined maven-invoker-plugin? – khmarbaise Jun 05 '15 at 18:00
  • Yeah I'm trying to do an integration tests for an archetype. But the generated project has a dependency on "Project 1", so I have to install it in a local repo or it won't be found. I'll try to make a self-contained reproducer and post it. – Tavian Barnes Jun 05 '15 at 18:03
  • Or attach it to the jira you have created... – khmarbaise Jun 05 '15 at 18:12
  • @khmarbaise Did both :) – Tavian Barnes Jun 05 '15 at 18:50

1 Answers1

0

I ran into this problem as well, in addition to other problems with the setup suggested in Fast Build Configuration (such as some artifacts being downloaded by the invoked project in every run), and implemented my own solution. Instead of the invoker:install goal, you would use the following:

<plugin>
    <groupId>com.github.veithen.invoker</groupId>
    <artifactId>resolver-proxy-maven-plugin</artifactId>
    <version>0.1</version>
    <executions>
        <execution>
            <goals>
                <goal>start</goal>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Note that there is no need to explicitly configure settings.xml or a dedicated local repository. This is done automatically.

Currently the code in the plugin is experimental. If it turns out to be robust enough, I will submit a patch integrating it into maven-invoker-plugin. More information here.

Andreas Veithen
  • 8,868
  • 3
  • 25
  • 28
  • This will actually install the artifact to my local m2 repository though right? Definitely not something I want if I didn't explicitly specify `mvn install` – Tavian Barnes Jan 04 '18 at 20:16
  • Note that this is also what `maven-invoker-plugin` does, unless you set `localRepositoryPath`. – Andreas Veithen Jan 05 '18 at 10:22
  • Right, I [do that](https://github.com/tavianator/MINVOKER-191/blob/master/project-3/pom.xml#L31) in the example project. The other thing is I guess this has to be attached to the module being installed instead of the one that needs it for tests. It would be nice to avoid installing (even to a separate repo) if I just build project-1. – Tavian Barnes Jan 08 '18 at 17:09
  • I've replaced my answer with a better solution to the problem. – Andreas Veithen Feb 09 '18 at 22:12