Discussion:
How does the jar plugin produce a "*-tests.jar" when I don't specify that?
KARR, DAVID
2016-11-30 23:18:28 UTC
Permalink
I'm working with a user who is getting an error from a build that looks like this:
-------------------
Could not resolve dependencies for project <groupId>:<artifactId1>:bundle:2.0.0-SNAPSHOT: Could not find artifact <groupId>:<artifact2>:jar:tests
--------------

I elided the groupId and artifact ids, but the trailing part of the artifact reference was ":jar:tests". I need to understand this "tests" thing.

I'm building the same branch, and I don't see this error, so I need to understand what's going on here.

The POM for "artifact1" has two dependencies on "artifact2". One is the "default" artifact, and another is a jar artifact that is only used for unit tests.

The dependency elements in the POM for "artifact1" look like this:
-------------------
<dependency>
<groupId>...</groupId>
<artifactId>artifact2</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>...</groupId>
<artifactId>artifact2</artifactId>
<version>2.0.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
-------------------

In the POM for "artifact2", there is the following plugin definition:
-----------
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
-----------

Notice that the only place you see "tests" so far is in that error message (which my colleague gets, but I do not).

I then looked in the "target" directory for "artifact2", and I saw the following:
-----------------
artifact2-2.0.0-SNAPSHOT.jar
artifact2-2.0.0-SNAPSHOT-tests.jar
----------------

Ok, there's the "tests". The question is, how did I end up with "*-tests.jar"?

I'm also unsure of the proper way to generate an "auxiliary" jar like this. Perhaps this should be refined to be more robust?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@maven.apache.org
For additional commands, e-mail: users-***@maven.apache.org
Laird Nelson
2016-11-30 23:36:24 UTC
Permalink
Post by KARR, DAVID
The POM for "artifact1" has two dependencies on "artifact2". One is the
"default" artifact, and another is a jar artifact that is only used for
unit tests.

and that's the issue. See
https://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html; note
in particular the "classifier" property (
https://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html#classifier
).

Some other information is here:
https://maven.apache.org/guides/mini/guide-attached-tests.html

Best,
Laird
--
http://about.me/lairdnelson
KARR, DAVID
2016-11-30 23:41:01 UTC
Permalink
-----Original Message-----
Sent: Wednesday, November 30, 2016 3:36 PM
Subject: Re: How does the jar plugin produce a "*-tests.jar" when I
don't specify that?
Post by KARR, DAVID
The POM for "artifact1" has two dependencies on "artifact2". One is
the "default" artifact, and another is a jar artifact that is only
used for unit tests.
…and that's the issue. See
https://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html;
note in particular the "classifier" property (
https://maven.apache.org/plugins/maven-jar-plugin/test-jar-
mojo.html#classifier
).
https://maven.apache.org/guides/mini/guide-attached-tests.html
Ok, thanks. That explains why I get "*-tests.jar". I still need to understand why that other developer is not getting that jar generated. More debugging to do.

Т���������������������������������������������������������������������ХF�V�7V'67&�&R�R���âW6W'2�V�7V'67&�&T�fV��6�R��&pФf�"FF�F����6����G2�R��
Adrien Rivard
2016-12-01 15:29:46 UTC
Permalink
Is he using "-Dmaven.test.skip=true" when building? This property skips the
build of the tests jar , contrary do -DskipTests=true that skip the
execution of the tests.
Post by KARR, DAVID
-----Original Message-----
Sent: Wednesday, November 30, 2016 3:36 PM
Subject: Re: How does the jar plugin produce a "*-tests.jar" when I
don't specify that?
Post by KARR, DAVID
The POM for "artifact1" has two dependencies on "artifact2". One is
the "default" artifact, and another is a jar artifact that is only
used for unit tests.

and that's the issue. See
https://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html;
note in particular the "classifier" property (
https://maven.apache.org/plugins/maven-jar-plugin/test-jar-
mojo.html#classifier
).
https://maven.apache.org/guides/mini/guide-attached-tests.html
Ok, thanks. That explains why I get "*-tests.jar". I still need to
understand why that other developer is not getting that jar generated.
More debugging to do.
--
Adrien Rivard
Loading...