How to modify default properties in Maven extension
I want to write a maven plugin (extension) which implements lifecycles for javascript projects so projects with a pom.xml like this can be compiled:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org
<modelVersion>4.0.0</modelVersion>
<groupId>de.ailis.maven.javascript</groupId>
<artifactId>demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Maven Jav开发者_如何学编程aScript Demo Project</name>
<packaging>javascript</packaging>
<build>
<plugins>
<plugin>
<groupId>de.ailis.maven.plugins</groupId>
<artifactId>maven-javascript-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
I already successfully created a plugin with a components.xml
file which defines the lifecycles so I can call my own Mojos during the various phases. But there are some phases for which the default mojos are adequate as long as I can change some default values. For example I want to specify a custom outputDirectory
to the Maven Resources Plugin so JavaScript resources are copied to target/classes/script-resources
instead of target/classes
. Can this be done in the plugin without copying the whole ResourcesMojo class and changing the default value of the property there?
Mojo:
public class MyMojo extends AbstractMojo
{
private String foo; //filePath
public void execute()
throws MojoExecutionException
{
...
writeFile(foo)
...
}
}
pom.xml
<plugin>
<groupId>de.ailis.maven.plugins</groupId>
<artifactId>maven-javascript-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<configuration>
<foo>script-resources</foo>
</configuration>
</plugin>
精彩评论