I have made my own maven plugin, to be run in process-classes phase. The Mojo
is supposed to instantiate a class that manipulates the .class files
generated during compile phase, but for some reason the class files in
${basedir}/target/classes cannot be found, i.e. a ClassNotFoundException is
thrown. If I
add a dependency to the jar (of _this_ project) no exception is thrown, but
then the classes in the jar file (and not the classes in target/classes) are
manipulated and will hence be overwritten in the package phase...
So my question is: how do I add ${basedir}/target/classes to the classpath
from within my mojo?
[snap of pom using the plugin]
<project>
...
<artifactId>engine</artifactId>
<version>1.0-SNAPSHOT</version>
...
<plugin>
<groupId>com.mycompany.maven</groupId>
<artifactId>maven-aop-weaver-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals><goal>run</goal></goals>
</execution>
</executions>
<configuration>
<transformer>com.mycompany.classtransform.PlatformClassTransformer</transformer>
...
</configuration>
<dependencies>
<!-- if I uncomment this dependency no exception is thrown -->
<!--dependency>
<groupId>com.mycompany.tablegame</groupId>
<artifactId>engine</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency-->
</dependencies>
</plugin>
[snap of my mojo]
/**
* @goal run
* @phase process-classes
*/
public class WeaverMojo extends AbstractMojo {
/**
* @parameter
* @required
*/
private String transformer;
...
public void execute() throws MojoExecutionException,
MojoFailureException {
ClassTransformer transformer = new ClassTransformer();
transformer.setTransformers(transformers);
...
transformer.doTheStuff();
}
}
--
View this message in context:
http://www.nabble.com/ClassNotFoundException-when-running-my-first-Mojo-tp18169955p18169955.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]