Maven 1.x Test Plugin

1.8 version introduces bug in other plugins

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.8
  • Fix Version/s: 1.8.1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    1

Description

When maven-war-plugin is run with maven.test.skip=true, the sources are not compiled.
Latest version of test-plugin has removed prereqs on java:compile & java:jar-resources.
Assuming other plugins themself run the java:compile goal may have impact on lots of plugin and can break many application builds. I think the "test:test" goal may have a prereqs="java:compile,java:jar-resources", and the "test:compile" goal only prereqs="test:prepare-filesystem,test:test-resources"

Issue Links

Activity

Hide
nicolas de loof added a comment -

Patch to attach java:compile as a test:test prereqs

this patch also solves MPWAR-62

Show
nicolas de loof added a comment - Patch to attach java:compile as a test:test prereqs this patch also solves MPWAR-62
Hide
Lukas Theussl added a comment -

It seems more logical to fix this in the war plugin. There is a slight backwards compatibility problem, but it only affects the case when test.skip=true, which is not recommended anyway (certainly not in production builds!).

Show
Lukas Theussl added a comment - It seems more logical to fix this in the war plugin. There is a slight backwards compatibility problem, but it only affects the case when test.skip=true, which is not recommended anyway (certainly not in production builds!).
Hide
nicolas de loof added a comment -

Please reconsider this issue as not only the WAR plugin get's broken.

+ The JAR plugin will compile the java source two times (beacuse prereqs="java:compile,java:jar-resources,test:test")

+ The javaapp plugin (from maven-plugins@sourceforge.net) doesn't compile java if skip=true

+ maybe other external plugins expect test:test to compile sources, based on copy/paste of code from official maven plugins, so upgrading to maven-test-plugin 1.8 can break the build process.

Why not simply adding moving prerequs on java:compile to test:test ?

<goal name="test:test"
description="Test the application"
prereqs="java:compile,java:jar-resources">

Show
nicolas de loof added a comment - Please reconsider this issue as not only the WAR plugin get's broken. + The JAR plugin will compile the java source two times (beacuse prereqs="java:compile,java:jar-resources,test:test") + The javaapp plugin (from maven-plugins@sourceforge.net) doesn't compile java if skip=true + maybe other external plugins expect test:test to compile sources, based on copy/paste of code from official maven plugins, so upgrading to maven-test-plugin 1.8 can break the build process. Why not simply adding moving prerequs on java:compile to test:test ? <goal name="test:test" description="Test the application" prereqs="java:compile,java:jar-resources">
Hide
Shinobu Kawai added a comment -

This issue was intoduced from the fix of MPTEST-46.

Show
Shinobu Kawai added a comment - This issue was intoduced from the fix of MPTEST-46.
Hide
Shinobu Kawai added a comment -

I like nicolas' solution for backward compatability, but I'm not sure if it is "right" to assume that test:test will always compile and copy resources. If other plugins need the java:compile and java:jar-resouces to be run, I think it should explicitly state that, like the JAR plugin example given. (Having said that, I don't like the idea of compiling twice, either...)

Show
Shinobu Kawai added a comment - I like nicolas' solution for backward compatability, but I'm not sure if it is "right" to assume that test:test will always compile and copy resources. If other plugins need the java:compile and java:jar-resouces to be run, I think it should explicitly state that, like the JAR plugin example given. (Having said that, I don't like the idea of compiling twice, either...)
Hide
Shinobu Kawai added a comment -

Actually, it's going to compile twice anyways (unless we revert the whole MPTEST-46 fix) because test:compile is being attainGoal-ed, and that will call java:compile.

java:compile and java:jar-resources will do nothing on the second time, so the only impact would be if pre/postGoal's were set in maven.xml.

Show
Shinobu Kawai added a comment - Actually, it's going to compile twice anyways (unless we revert the whole MPTEST-46 fix) because test:compile is being attainGoal-ed, and that will call java:compile. java:compile and java:jar-resources will do nothing on the second time, so the only impact would be if pre/postGoal's were set in maven.xml.
Hide
nicolas de loof added a comment -

Lot's of code generation plugin are attached to java:compile as preGoals...

I can suggest two options :

1. keep previous behaviour and assume test:* allways depends on java:compile, even if this is not clean.

2. make ONLY the "test" goal (not the "test:test") depend on java:compile, so that a

  • "maven test" compiles project and run the tests, as any user may expect it
  • any plugin depending on test:test will NOT force a twice compilation.
    This 2d solution requires update to other plugins.

Any 3d solution would be welcome as both seems not very cool...

Show
nicolas de loof added a comment - Lot's of code generation plugin are attached to java:compile as preGoals... I can suggest two options : 1. keep previous behaviour and assume test:* allways depends on java:compile, even if this is not clean. 2. make ONLY the "test" goal (not the "test:test") depend on java:compile, so that a
  • "maven test" compiles project and run the tests, as any user may expect it
  • any plugin depending on test:test will NOT force a twice compilation. This 2d solution requires update to other plugins.
Any 3d solution would be welcome as both seems not very cool...
Hide
Shinobu Kawai added a comment -

Not clear how the whole prereqs stuff work, but I was wondering if adding an attribute to call attainGoal with the same werkz session would work.

Something like <attainGoal name="java:compile" useParentSession="true" />.

Show
Shinobu Kawai added a comment - Not clear how the whole prereqs stuff work, but I was wondering if adding an attribute to call attainGoal with the same werkz session would work. Something like <attainGoal name="java:compile" useParentSession="true" />.
Hide
Lukas Theussl added a comment -

We need to decide what to do about this issue for m11. Personally, I don't want to revert MPTEST-46 as the current way is the way it should be. Also, we have already adapted our other plugins to it (MPEJB-23, MPWAR-62, jar), so internally, we are clean. The only problem is with backward compatibility when using third-party plugins that rely on java:compile being called with test:test. For this case, there is a simple workaround, eg for the javaapp plugin, add the following in your maven.xml:

<preGoal name="javaapp:jar">
  <j:if test="${unitTestSourcesPresent != 'true' or context.getVariable('maven.test.skip') == 'true'}">
    <attainGoal name="java:compile"/>
    <attainGoal name="java:jar-resources"/>
  </j:if>
</preGoal>

Sources being compiled twice is not a real problem (and btw it was that way before already), as the second time only the goal will be called but the sources not actually compiled.

So my suggestion is to leave it as is and write a paragraph on the main plugin page to document the problem. Unless someone comes up with a new solution, as none of the alternatives above seem acceptable to me.

Show
Lukas Theussl added a comment - We need to decide what to do about this issue for m11. Personally, I don't want to revert MPTEST-46 as the current way is the way it should be. Also, we have already adapted our other plugins to it (MPEJB-23, MPWAR-62, jar), so internally, we are clean. The only problem is with backward compatibility when using third-party plugins that rely on java:compile being called with test:test. For this case, there is a simple workaround, eg for the javaapp plugin, add the following in your maven.xml:
<preGoal name="javaapp:jar">
  <j:if test="${unitTestSourcesPresent != 'true' or context.getVariable('maven.test.skip') == 'true'}">
    <attainGoal name="java:compile"/>
    <attainGoal name="java:jar-resources"/>
  </j:if>
</preGoal>
Sources being compiled twice is not a real problem (and btw it was that way before already), as the second time only the goal will be called but the sources not actually compiled. So my suggestion is to leave it as is and write a paragraph on the main plugin page to document the problem. Unless someone comes up with a new solution, as none of the alternatives above seem acceptable to me.
Hide
Lukas Theussl added a comment -

Documented the issue.

Show
Lukas Theussl added a comment - Documented the issue.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: