ci.maven: Multi-module liberty dev mode fails when there exists a test-jar dependency

I have an existing multi-module web application and I want to use liberty dev mode with it.

One of the modules has some test utilities which are used in the tests of the other modules. Maven supports that through the use of a build plugin configuration like this:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Then, in the modules that depend on it, we declare the dependency with a type of test-jar (or, equivalently, with a classifier of tests)

This builds fine with a command like mvn clean install -f parent. However, if one of those modules has our liberty config and we try using mvn liberty:dev -f parent then we end up with an error like the following:

Could not resolve dependencies for project io.openliberty.guides:module2:war:1.0-SNAPSHOT: Could not find artifact io.openliberty.guides:module1:jar:tests:1.0-SNAPSHOT

Attached is a minimal reproducer that adapts the OpenLiberty getting started example to demonstrate the issue. multimodule-testjar-reproducer.zip After unzipping, run the following to see the error:

mvn liberty:dev -f parent

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (14 by maintainers)

Most upvoted comments

@lmsurpre Scott is on vacation for the next week. I will go ahead and open a separate issue for the “FOLLOW-UP ISSUE”. Nothing has been done to resolve it yet, and it wasn’t on our current radar of things to address in the near term. I will tag Scott in the new issue and have him follow up when he gets back. Thanks for reaching out.

Happy to try this and report back whenever it gets released…is there any rough timeframe on that (e.g. days vs weeks vs months?)

We are planning for a release the third week of September as of right now.

Thanks @lmsurpre, I am able to reproduce this issue.

Looks as though dev mode is unable to resolve the module1 dependency in this case because of the tests classifier:

        <dependency>
            <groupId>io.openliberty.guides</groupId>
            <artifactId>module1</artifactId>
            <version>1.0-SNAPSHOT</version>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>

In dev mode we should support classifiers when resolving dependencies for multi module projects.

I’ll also note that the documented mvn liberty:dev -f parent -pl module2 -am syntax didn’t work for me at all. That one produces an error like this:

[ERROR] [ERROR] Could not find the selected project in the reactor: module2 @ 
[ERROR] Could not find the selected project in the reactor: module2 -> [Help 1]

However, using the “reactor” syntax (prefixing the module name with a : to indicate that module2 is an artifactId), I got back to the same issue described above).

I opened https://github.com/OpenLiberty/ci.maven/pull/1562/files to update the docs accordingly, but let me know if you’d like me to open a separate issue for that.

The documentation for the -pl module2 -am syntax assumes a relative path approach, for this project layout, -pl ../module2 -am would work. However, I think to be more robust documenting to always prefix the module name with a : to indicate artifactId is a good idea rather than the relative path approach.

More details on --projects (-pl for short) here: https://maven.apache.org/guides/mini/guide-multiple-modules-4.html#inclusion-and-exclusion