database 运行单个 Maven 插件执行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3779369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run a single Maven plugin execution?
提问by HDave
I thought I was an experienced Maven user, but I am having a mental block on how to do this!
我以为我是一个经验丰富的 Maven 用户,但我对如何做到这一点有一个心理障碍!
I've been able to use the Maven sql plugin to drop, create, and install a schema in a database via plugin executions I've defined and bound to the pre-integration-test
phase.
我已经能够使用 Maven sql 插件通过我定义并绑定到pre-integration-test
阶段的插件执行在数据库中删除、创建和安装模式。
However, now I'd like to use that same sql plugin to insert some sample data whenever I want from the command line -- that is, not bound to any lifecycle goal. There are a few different sets of sample data, so I'd like to define a few different executions.
但是,现在我想使用相同的 sql 插件随时从命令行插入一些示例数据——也就是说,不绑定到任何生命周期目标。有几组不同的样本数据,所以我想定义一些不同的执行。
But is there a way to run one of these executions from the command line by using the execution ID perhaps?
但是有没有办法通过使用执行 ID 从命令行运行这些执行之一?
回答by Joe
As noted in How to execute maven plugin execution directly from command line?, this functionality has been implementedas MNG-5768, and is available in Maven 3.3.1.
如如何直接从命令行执行 Maven 插件执行中所述?,这个功能已经实现的MNG-5768,并且可在Maven的3.3.1。
The change will:
变化将:
extend direct plugin invocation syntax to allow optional @execution-id parameter, e.g., org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process@executionId.
扩展直接插件调用语法以允许可选的@execution-id 参数,例如 org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process@executionId。
So, as long as you give your execution an id:
所以,只要你给你的执行一个 id:
mvn sql:execute@specific-execution-id
uses the execution configured in your pom.
使用在你的 pom.xml 中配置的执行。
回答by Pascal Thivent
But is there a way to run one of these executions from the command line by using the execution ID perhaps?
但是有没有办法通过使用执行 ID 从命令行运行这些执行之一?
No, not possible. What is possible though is to define "a"configuration to be used when the plugin is invoked from the command line using the "special" default-cli
execution id:
不,不可能。但是,可以定义在使用“特殊”执行 ID从命令行调用插件时使用的“a”配置default-cli
:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.4</version>
...
<executions>
<execution>
<id>default-cli</id>
<configuration>
...
</configuration>
</execution>
...
</executions>
</plugin>
And simply call mvn sql:execute
.
只需调用mvn sql:execute
.
See below for the details (from the Maven 2.2.0 Release Notes):
有关详细信息,请参见下文(来自Maven 2.2.0 发行说明):
- MNG-3401- Starting in Maven 2.2.0, goals invoked directly from the command line can be configured in the POM separately from other plugin invocations using a special
executionId
calleddefault-cli
. Where previously, all configurations for command-line goals had to go in the plugin-level configuration, Maven 2.2.0 allows command-line-specific configurations to be separated into their own<execution>
. For more information, see the Guide to Default Execution IDs.
- MNG-3401-在Maven的2.2.0开始,目标通过命令行直接援引可以在POM从使用一种特殊的其他调用插件被配置分别
executionId
称为default-cli
。以前,命令行目标的所有配置都必须在插件级配置中进行,而 Maven 2.2.0 允许将特定于命令行的配置分离到它们自己的<execution>
. 有关更多信息,请参阅默认执行 ID 指南。