如何修改 Maven 扩展中的默认属性
我想编写一个 Maven 插件(扩展),它实现 javascript 项目的生命周期,以便可以编译具有这样的 pom.xml 的项目:
<?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 JavaScript 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>
我已经成功创建了一个带有 components.xml
文件的插件,该文件定义了生命周期,以便我可以在各个阶段调用我自己的 Mojo。但在某些阶段,只要我可以更改一些默认值,默认的魔力就足够了。例如,我想为 Maven 资源插件指定一个自定义 outputDirectory
,以便将 JavaScript 资源复制到 target/classes/script-resources
而不是 target/classes< /代码>。可以在插件中完成此操作,而无需复制整个 ResourcesMojo 类并更改其中属性的默认值吗?
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 JavaScript 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Mojo:
pom.xml
Mojo:
pom.xml