Reputation: 21326
I've discovered the wonderful test-jar
facility in Maven: https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html
But it may so happen that one project needs to use the test-jar of another project. From https://stackoverflow.com/a/6469256/421049 and experimentation, it would seem that using mvn install
does not install the test-jar to the local ~/.m2/repository
. So how does one project on my machine use the test jars of another project not in the same aggregate POM?
Yet it would seem from Maven deploy not to upload test jar that deployment of a project to Maven Central does in fact deploy the test-jar? So I can deploy it to Nexus but not install it locally? And if I deploy it to Nexus, will my local project using a dependency of <type>test-jar</type>
go find it on Maven Central?
Upvotes: 1
Views: 2003
Reputation: 1861
In my case, I was setting maven.test.skip
for a particular build profile. That property actually causes tests to not be compiled/installed, thus also preventing their deploy. The solution was to set the skipTests
property instead.
Upvotes: 4
Reputation: 21326
It turns out that maven-jar-plugin
does in fact install the test-jar (e.g. foo-1.2.3-tests.jar
) in the local Maven repository ~/.m2/repository/...
. Wonderful!
My problem is that I had inadvertently configured the maven-jar-plugin
to be in a separate profile named release
. (I had copied and pasted to the wrong location in my POM.) That's why the test-jar didn't show up in my local repository after a mvn install
, and that's why it suddenly showed up later (after I used -P release
once in testing), and I thought I had just missed it when I looked the first time.
I move the maven-jar-plugin
to the <build>
section and everything is working fine: the test-jar gets put into the local maven repository using mvn install
.
Upvotes: 1