[ 
http://jira.codehaus.org/browse/MEXEC-91?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Steven Bethard updated MEXEC-91:
--------------------------------

    Attachment: mvn-compile-bug.tgz

Looks like this problem is bigger than just the exec plugin. Here's an even 
simpler setup that provokes the error:

/pom.xml
/module-with-test-jar/pom.xml
/module-needing-test-jar/pom.xml

If you use maven 3 to run:
{code}
mvn compile
{code}

You'll get the error:

[ERROR] Failed to execute goal on project module-needing-test-jar: Could not 
resolve dependencies for project 
bug:module-needing-test-jar:jar:0.0.1-SNAPSHOT: Could not find artifact 
bug:module-with-test-jar:jar:tests:0.0.1-SNAPSHOT

Which is wrong because you're in the compile phase and maven should not be 
looking for test scoped dependencies.

The key points are that the parent has two modules:
{code:xml}
<modules>
  <module>module-with-test-jar</module>
  <module>module-needing-test-jar</module>
</modules>
{code}

The first module supplies the test jar:
{code:xml}
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <executions>
        <execution>
          <goals>
            <goal>test-jar</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
{code}
And the second module both depends on the test jar, and adds something to the 
compile phase (or earlier) using an {{<execution>}}:
{code:xml}
<dependencies>
  <dependency>
    <groupId>bug</groupId>
    <artifactId>module-with-test-jar</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>test-jar</type>
    <scope>test</scope>
  </dependency>
</dependencies>
<build>
  <plugins>
    <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <executions>
        <execution>
          <phase>compile</phase>
          <goals>
            <goal>test</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
{code}
Here I'm using {{maven-surefire-plugin}} to prove that it's not just the 
{{maven-exec-plugin}} that has this problem. In the attached code there's also 
a commented out section using the {{maven-exec-plugin}} that will provoke 
exactly the same bug.

Again, a workaround is to run {{mvn compile test-compile}}.

> exec:java causes mvn compile to look for test-jar dependencies
> --------------------------------------------------------------
>
>                 Key: MEXEC-91
>                 URL: http://jira.codehaus.org/browse/MEXEC-91
>             Project: Maven 2.x Exec Plugin
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.2
>         Environment: Mac OS X, maven 2 and 3
>            Reporter: Steven Bethard
>         Attachments: mvn-compile-bug.tgz, mvn-compile-bug.tgz
>
>
> There is a bad interaction between the exec:java plugin and test-jar 
> dependencies in a multi-module project. In short, if you attach exec:java to 
> an execution phase, "mvn compile" then looks for "test-jar" dependencies even 
> though it should only be looking for compile time dependencies.
> Here is the setup:
> /pom.xml
> /cleartk-token/pom.xml
> /cleartk-token/src/main/java/Token.java
> /cleartk-token/src/test/java/TokenTest.java
> /cleartk-named-entity/pom.xml
> The cleartk-token module uses the "maven-jar-plugin" to package a "test-jar" 
> dependency.
> The cleartk-named-entity module depends on the cleartk-token "jar" dependency 
> at compile time and (additionally) the cleartk-token "test-jar" dependency at 
> test-compile time.
> The cleartk-named-entity module uses exec:java to generate some code in the 
> process-resources phase. (It doesn't actually call any main class in the 
> attached file, but that doesn't seem to be necessary to provoke the bug.)
> Given this setup, if you run "mvn compile" from the top level, with maven 2 
> you'll get the error:
> [INFO] 
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Failed to resolve artifact.
> Missing:
> ----------
> 1) org.cleartk:cleartk-token:test-jar:tests:0.7.0-SNAPSHOT
> And with maven 3 you'll get the error:
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO] 
> ------------------------------------------------------------------------
> ...
> [ERROR] Failed to execute goal on project cleartk-named-entity: Could not 
> resolve dependencies for project 
> org.cleartk:cleartk-named-entity:jar:0.1.0-SNAPSHOT: Could not find artifact 
> org.cleartk:cleartk-token:jar:tests:0.7.0-SNAPSHOT
> Now this seems wrong in both cases - at compile time, maven shouldn't be 
> looking for test jars.
> I believe this is an exec:java bug (or at least exec:java revealing a 
> compiler plugin bug) because if I comment out the <executions> element for 
> the "maven-exec-plugin", then everything compiles fine.
> My current workaround is to use "mvn compile package" which I guess makes the 
> "test-jar" dependency visible at compile time. But since the "test-jar" 
> dependency is a test-compile time dependency, I think this shouldn't be 
> necessary.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to