我正在尝试使用gmavenplus-plugin
自定义Maven构建过程。
确切地说,我在gmaven-plugin
中有一个workig脚本,我正尝试在gmavenplus-plugin
中重新实现它(此广告是对GMaven的重写)
我正在运行的gmaven代码
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
println(project.version)
println([1, 2, 3])
</source>
</configuration>
</execution>
</executions>
</plugin>
我试图用gmavenplus重写它:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.7.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<scripts>
println(project.version)
println([1, 2, 3])
</scripts>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
哪个失败
[ERROR] Script1.groovy: 2: unexpected token: 1 @ line 2, column 34.
[ERROR] println([1
[ERROR] ^
[ERROR]
[ERROR] 1 error
我尝试使用的任何常规语法都会失败。
更新 CDATA没有帮助。
<scripts>
<![CDATA[
println(project.version)
println([1, 2, 3])
]]>
答案 0 :(得分:1)
根据示例https://github.com/groovy/GMavenPlus/wiki/Examples
在<script>
中应该有<scripts>
:
在以下示例mvn gplus:execute
中使用pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>test-gmavenplus</groupId>
<artifactId>test-gmavenplus</artifactId>
<packaging>pom</packaging>
<version>1.1.0-SNAPSHOT</version>
<name>test gmavenplus</name>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.7.0</version>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<scripts>
<script><![CDATA[
println "hello `${project.name}`"
]]></script>
</scripts>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.5.7</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>