Incorrect build dependencies when maven module attaches multiple jars
Answered
Hi all,
I have a maven module A that deploys multiple jars using the maven build-helper plugin:
<execution>
<id>attach-jar1</id>
<phase>process-resources</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.outputDirectory}/myJar1.jar</file>
<type>jar</type>
<classifier>jar1</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
... same execution for myJar2
<execution>
Another module B defines a maven dependency on the attached jars:
<dependency>
<groupId>myGroup</groupId>
<artifactId>myJar1</artifactId>
<version>${project.version}</version>
<classifier>jar1</classifier>
</dependency>
... same with jar2
The project fails to build in IntelliJ (the maven build works fine) the compiler debugging shows that IntelliJ is using this classpath:
/Users/xxx/repos/bpmn/A/target/test-classes
/Users/xxx/repos/bpmn/A/target/classes
/Users/xxx/repos/bpmn/X/target/classes/myJar1.jar
There is no entry for myJar2 or any additional attached jar.
Franck
Please sign in to leave a comment.
Hello,
Could you please share sample proejct example for investigation?
There you are. The maven build works fine, the IntelliJ build doesn't.
https://www.dropbox.com/s/y8zrrb4pi3xpiav/dependency-defect.zip?dl=0
Franck
BTW looking at those ATTACHED-JAR libraries in Project Structure -> Project Settings -> Libraries shows that they have the wrong jar files listed (the first jar file is listed twice for each library).
Fixing that solves the problem, but only until the next POM update / Maven import.
Franck
As a workarounf you could put adding under the same <execution>:
```
Nice, that works indeed... thanks!
You are welcome!