简体   繁体   English

Maven插件-插件在插件中可执行吗?

[英]Maven Plugin - are plugins executable within plugins?

Is it possible to execute a plugin from a plugin? 是否可以从插件执行插件? For instance, if I want to programmatically call another plugin from within a plugin, not via static XML. 例如,如果我想以编程方式从一个插件中调用另一个插件,而不是通过静态XML。

Is this possible, how would I do that? 这可能吗,我该怎么做?

Thanks, 谢谢,

Walter 沃尔特

There are several ways to do this: 做这件事有很多种方法:

  • Use MavenInvoker to fork a new maven process. 使用MavenInvoker派生一个新的Maven进程。

This has pros and cons, especially since you're building the project twice, but a common pattern is to modify the maven model, write it out to the file system as a temporary pom XML file, point the invoker to this pom. 这具有优缺点,特别是因为您要两次构建项目,但是一种常见的模式是修改maven模型,将其作为临时pom XML文件写到文件系统中,将调用者指向此pom。 Drawback: you're losing the original model and wasting resources. 缺点:您正在丢失原始模型并浪费资源。 Pro: you can do anything you want to the (new) maven model dynamically. 优点:您可以动态地对(新)maven模型进行任何操作。 This is very powerful 这很强大

  • Let your plugin either aggregate or extend the original plugin. 让您的插件聚合或扩展原始插件。

Extending is a lot simpler, configuration is automatically there (Google for maven extend plugin ). 扩展要简单得多,配置会自动存在(针对Maven扩展插件的Google)。 By Aggregation I mean calling the plugin programmatically which means you will probably have to access the plexus container to wire up the plugin configuration 通过聚合,我的意思是以编程方式调用插件,这意味着您可能必须访问plexus容器以连接插件配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Maven插件执行其他插件? - Maven plugin to execute other plugins? Maven 插件构建 Maven 插件 - Maven plugins to build Maven plugins 警告 org.apache.maven.plugins:maven-deploy-plugin 的“build.plugins.plugin.version”丢失 - WARNING 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing org.apache.maven.plugins:maven-surefire-plugin 的“build.plugins.plugin.version”丢失 - 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing 安装Maven和Maven插件 - Installing maven and maven plugins Maven中的pluginManagement范围和report.plugins.plugin.version缺少警告 - Scope of pluginManagement in Maven & reporting.plugins.plugin.version missing warning Maven Dependency Plugin go-offline不下载一些插件 - Maven Dependency Plugin go-offline not downloading some plugins maven-compiler-plugin声明应放在何处: <plugins> 要么 <pluginManagement> ? - Where should be placed maven-compiler-plugin declaration: in <plugins> or <pluginManagement>? Maven plugin wagon 不考虑我的插件参数和版本 - Maven plugin wagon do not consider my parameters and version of plugins Log4j2自定义插件 - 使用Maven Assembly Plugin进行注释处理 - Log4j2 custom plugins - annotation processing with Maven Assembly Plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM