我正在尝试使用gmavenplus-plugin定制maven构建过程。准确地说,我在gmaven-plugin中有一个工作脚本,我正在尝试在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我尝试使用的任何groovy语法都会失败。
更新 CDATA没有帮助。
<scripts>
<![CDATA[
println(project.version)
println([1, 2, 3])
]]>发布于 2019-05-30 08:18:34
根据实例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>https://stackoverflow.com/questions/56373674
复制相似问题