Discussion:
Missing dependency on attached tests when -Dmaven.test.skip=true
Andreas Sewe
2010-01-13 16:12:42 UTC
Permalink
Hi all,

I have three Maven projects example:A:1.0, example:B:1.0, and
example:C:1.0. The former aggregates the two latter projects.

Now project example:B:1.0 attaches a test-jar to is primary artifact (as
per <http://maven.apache.org/guides/mini/guide-attached-tests.html>).

Project C has a "test" scoped dependency on this attached artifact:
example:B:test-jar:tests:1.0. (again, per the mini guide.)

Now, if I use Maven to install the aggregator project A like so

mvn clean install -Dmaven.test.skip=true

and my local repository is initially void of
example:B:test-jar:tests:1.0, I get a build failure.

While this seems to be related to
<http://jira.codehaus.org/browse/MNG-2045>, I am not sure its the same
issue, as the following *does* work:

mvn clean install

This properly installs example:B:test-jar:tests:1.0 when building
project B, just in time before project C needs it.

So, is the behavior when -Dmaven.skip.test=true a bug? Or need
test-scoped dependencies still present even if nobody actually uses
them? (FWIW, the behavior occurs using both Maven 2.2.1 and the
3.0-SNAPSHOT embedded into M2Eclipse.)

Thoughts?

Andreas Sewe
Jörg Schaible
2010-01-14 07:37:18 UTC
Permalink
Hi Andreas,
Post by Andreas Sewe
Hi all,
I have three Maven projects example:A:1.0, example:B:1.0, and
example:C:1.0. The former aggregates the two latter projects.
Now project example:B:1.0 attaches a test-jar to is primary artifact (as
per <http://maven.apache.org/guides/mini/guide-attached-tests.html>).
example:B:test-jar:tests:1.0. (again, per the mini guide.)
Now, if I use Maven to install the aggregator project A like so
mvn clean install -Dmaven.test.skip=true
and my local repository is initially void of
example:B:test-jar:tests:1.0, I get a build failure.
While this seems to be related to
<http://jira.codehaus.org/browse/MNG-2045>, I am not sure its the same
mvn clean install
This properly installs example:B:test-jar:tests:1.0 when building
project B, just in time before project C needs it.
So, is the behavior when -Dmaven.skip.test=true a bug? Or need
test-scoped dependencies still present even if nobody actually uses
them? (FWIW, the behavior occurs using both Maven 2.2.1 and the
3.0-SNAPSHOT embedded into M2Eclipse.)
Thoughts?
This is expected. The flag tells Maven to skip the complete test stuff i.e.
also the compile phase and you will have an empty test jar. Therefore use
-Dmaven.skip.test.exec=true to compile the test code, but skip the test
execution.

- Jörg
Dan Tran
2010-01-14 07:46:18 UTC
Permalink
mvn install -DskipTests=true may work too
Post by Jörg Schaible
Hi Andreas,
Post by Andreas Sewe
Hi all,
I have three Maven projects example:A:1.0, example:B:1.0, and
example:C:1.0. The former aggregates the two latter projects.
Now project example:B:1.0 attaches a test-jar to is primary artifact (as
per <http://maven.apache.org/guides/mini/guide-attached-tests.html>).
example:B:test-jar:tests:1.0. (again, per the mini guide.)
Now, if I use Maven to install the aggregator project A like so
   mvn clean install -Dmaven.test.skip=true
and my local repository is initially void of
example:B:test-jar:tests:1.0, I get a build failure.
While this seems to be related to
<http://jira.codehaus.org/browse/MNG-2045>, I am not sure its the same
   mvn clean install
This properly installs example:B:test-jar:tests:1.0 when building
project B, just in time before project C needs it.
So, is the behavior when -Dmaven.skip.test=true a bug? Or need
test-scoped dependencies still present even if nobody actually uses
them? (FWIW, the behavior occurs using both Maven 2.2.1 and the
3.0-SNAPSHOT embedded into M2Eclipse.)
Thoughts?
This is expected. The flag tells Maven to skip the complete test stuff i.e.
also the compile phase and you will have an empty test jar. Therefore use
-Dmaven.skip.test.exec=true to compile the test code, but skip the test
execution.
- Jörg
---------------------------------------------------------------------
Andreas Sewe
2010-01-14 08:49:57 UTC
Permalink
Hi Jörg,
Post by Jörg Schaible
Post by Andreas Sewe
So, is the behavior when -Dmaven.skip.test=true a bug? Or need
test-scoped dependencies still present even if nobody actually uses
them? (FWIW, the behavior occurs using both Maven 2.2.1 and the
3.0-SNAPSHOT embedded into M2Eclipse.)
Thoughts?
This is expected. The flag tells Maven to skip the complete test stuff i.e.
also the compile phase and you will have an empty test jar. Therefore use
-Dmaven.skip.test.exec=true to compile the test code, but skip the test
execution.
thanks you for the explanation.

Just for the record: the property in question is called
"maven.test.skip.exec", not "maven.skip.test.exec". Once that is fixed
(or when using "skipTests", as Dan suggested) everything builds just
fine; the attached tests are installed and found as dependency (even if
they are never used).

The only unfortunate thing is that M2Eclipse's "Skip Tests" checkbox in
the "Run Configurations" dialog seems to map to "maven.skip.test", not
"maven.test.skip.exec" or "skipTests". Consequently, as soon as you have
attached tests the GUI is not all that helpful anymore. :-(

Best wishes,

Andreas

Loading...