We have a parent project with about dozen child projects. Most of the child projects have tests, and so they depend on JUnit. I thought it would make sense to pull this out to the parent pom as a managed dependency:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
In one of my child projects - still working on cleaning up this one - I need JUnit during build. So in that pom I now have:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
This works fine. The part where things fall apart, is that this project also needs to be built as a jar with dependencies, using:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>TestIntegration</finalName>
</configuration>
</plugin>
The jar-with-dependencies is missing JUnit. Note that if I remove JUnit as a managed dependency, and specify it as a normal dependency in that project, then everything builds fine.
How do I get jar, as a managed dependency scoped for test, into a jar-with-dependencies?