我正在尝试使用gmaven覆盖maven中的以下属性:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>setproperty</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
pom.properties['main.build.directory']=project.parent.build.directory.absolutePath.replace('\\','/');
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>但是我得到了这个错误:;
[ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.5:execute (setproperty) on project my-project: startup failed, script139276
2592853.groovy: 1: expecting ''', found '<EOF>' @ line 1, column 84.
[ERROR] 1 error上面的groovy代码片段有什么问题?
发布于 2015-07-31 00:50:48
使用gmavenplus-plugin设置的属性值在使用插件访问时会正确显示。即使使用同一插件的不同实例访问它,它也会正确显示。当已经在插件外部初始化的属性的值被插件改变,并且在插件外部被访问时,就会出现问题。现在该属性的值不是由插件更新的值。更新的值现在被限定在插件的范围内。如果某个属性必须由插件更新并需要在插件范围之外访问,则作为解决此问题的变通方法:不要声明或初始化它,以防需要通过插件声明和初始化属性。
发布于 2014-02-22 06:19:22
我同意@khmarbaise的说法,这有点奇怪,但如果你一定要这样做……我不确定为什么它不能工作。这个插件已经不再需要维护了。我认为这应该行得通:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>setproperty</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script><![CDATA[project.properties['main.build.directory']=project.parent.build.directory.replace('\\','/')]]></script>
</scripts>
</configuration>
</execution>
</executions>
</plugin>有关这个魔术的更多信息,请查看http://groovy.github.io/GMavenPlus/execute-mojo.html。。但是,请注意,我相信这将在插件的范围内。
https://stackoverflow.com/questions/21867095
复制相似问题