Orb not working well for multi-module project
Closed this issue · 7 comments
Orb Version
1.0.0
Describe the bug
Fetching dependencies in commands/with_cache.yml will fail for multi-module maven project
because the maven goal dependency:go-offline
does not work well with modules.
With the attached project, the step Install dependenies will end with
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for parent 1.0-SNAPSHOT:
[INFO]
[INFO] parent ............................................. SUCCESS [ 1.207 s]
[INFO] world .............................................. SUCCESS [ 0.205 s]
[INFO] hello .............................................. FAILURE [ 0.262 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.000 s
[INFO] Finished at: 2020-02-04T10:51:01+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hello: Could not resolve dependencies for project example:hello:jar:1.0-SNAPSHOT: Could not find artifact example:world:jar:1.0-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :hello
To Reproduce
Use this job with project attached
jobs:
maven-orb-test:
executor:
name: maven/default
tag: '11.0.6'
steps:
- checkout
- maven/with_cache:
steps:
- run: mvn compile
And see the logs.
Expected behavior
There are several solutions for this, depending on your project priorities:
- let user choose what command will be executed to fetch dependencies
- use an unofficial maven plugin
de.qaware.maven:go-offline-maven-plugin:resolve-dependencies
, see https://github.com/qaware/go-offline-maven-plugin - prepend the
dependency:go-offline
withcompile
task. This may be a limitation for some builds - skip the
dependency:go-offline
completely because definedsteps
are executed beforesave_cache
and they will download dependencies anyway
Additional context
There is a possible workaround using maven_command: mvn compile
jobs:
maven-orb-test:
executor:
name: maven/default
tag: '11.0.6'
steps:
- checkout
- maven/with_cache:
maven_command: mvn compile
steps:
- run: mvn compile
Attachments
I am also running into this issue with our multi-module project. I don't want 'dependency:go-offline' to be forced with no way to turn it off.
Investigating
A PR has been opened to resolve this issue. Please feel free to leave a review.
@KyleTryon Thanks for looking into this issue.
I guess the proposal in #6 will let me use mentioned go-offline-maven-plugin
as they suggest in their example for Gitlab.
That is good enough for me.
any update on this?
How about autodetecting whether the (root) pom contains modules, and skip the whole offline approach?
The issue here is that maven does not correctly detect that some of the dependencies reference other modules that are part of the project.
Luckily, this issue has already been fixed in the Maven dependency plugin version 3.1.2.
CircleCI users keep running into this issue because the maven-dependency plugin defaults to version 2.8 since it is defined in the super pom.
To solve this, I propose using a fixed version of the maven dependency plugin in the maven orb. I have made the following PR for it: #17
As a temporary workaround, you can also put this in your pom to pin the plugin version:
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>