具有不同配置的相同插件
问题描述:
我正在使用Maven 3.3.9。 对于具有不同配置的相同插件,是否可以有相同的目标? 我的意思是这样具有不同配置的相同插件
<build>
...
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>test1</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>dir</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>test2</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>cd</executable>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
如果我把<execution>
内<configuration>
标签,它只是被忽略。
加上标签<goalPrefix>
不工作,所以我不知道如何别名目标来区分他们...
编辑
我需要执行两个不同的脚本,我做了,但只是作为一个cli目标......脚本在代码上运行一些测试,但测试是可选的,只有程序员明确要运行它们时才必须执行它们。
我想在Maven来将那些脚本嵌入的原因是因为我想用${project.build.directory}
变量
答
是的,它是。但是,您通常会将它们全部包含在同一个插件定义中。我们这样做是为了实现树震动,提前编译和缩小我们的项目中的angular2 UI。我们的配置如下所示:
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>npm run typescript compiler</id>
<phase>compile</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run compile_ts_ngc</arguments>
</configuration>
</execution>
<execution>
<id>rollup</id>
<phase>compile</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run rollup</arguments>
</configuration>
</execution>
<execution>
<id>gulp build</id>
<phase>compile</phase>
<goals>
<goal>gulp</goal>
</goals>
<configuration>
<arguments>aot</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
正如您所看到的,我们在编译阶段运行了两个不同的npm命令。它们按照从上到下的顺序运行。
我不完全确定你正在试图与他们区分它们吗?这是为了订购目的还是一些条件执行?通常我们会将需要在特定条件下运行的单独任务放入配置文件中,以便您可以轻松指定何时运行它们。
你会用它做什么?一世 – Jens