project.compileClasspathElements defaults between Maven 2 and 3
I inherited a Maven project/module that failed when I switched from Maven 2 to Maven 3. It hinges on the execution of an external program that depends on the contents of project/module/target/classpath.txt. This file is generated by a custom plugin that uses ${project.compileClasspathElements}.
In Maven 2 this contained:
projec开发者_开发技巧t/module/target/classes
[all my dependencies in my local repository]
But in Maven 3, the classpath.txt file only contains:
project/module/target/classes
In other words, the file is missing all the actual dependencies, save for the build directory. Was there a change between Maven 2 and Maven 3 regarding project.compileClasspathElements? How can I get all the dependencies back so that it will work like Maven 2?
[This question was edited to reflect the source of classpath.txt, which I only just discovered.]
Just encountered this issue when migrating a maven 2 plugin that executes during the package phase. Fixed by adding
@requiresDependencyResolution compile+runtime
to the Mojo, e.g.
/**
* blah blah blah
*
* @goal validate-security
* @phase package
* @requiresDependencyResolution compile+runtime
*/
public class SecurityValidationMojo extends AbstractMojo { ... }
From http://maven.apache.org/developers/mojo-api-specification.html
If this annotation is present but no scope is specified, the scope defaults to runtime. If the annotation is not present at all, the mojo must not make any assumptions about the artifacts associated with a Maven project.
精彩评论