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)
@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.
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:
In dev mode we should support classifiers when resolving dependencies for multi module projects.
The documentation for the
-pl module2 -amsyntax assumes a relative path approach, for this project layout,-pl ../module2 -amwould 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(-plfor short) here: https://maven.apache.org/guides/mini/guide-multiple-modules-4.html#inclusion-and-exclusion