我想编写一个Gradle函数,该函数创建一个pom.xml
文件,并将数据(groupId,artifactId,version)作为参数传递。
我创建了以下脚本:
apply plugin: 'maven'
apply plugin: 'java'
def createMainPom(mainDir, groupId, artifactId, version)
{
pom
{
project
{
groupId '$groupId' // Error
artifactId '$artifactId'
version '$version'
packaging 'pom'
name 'New app'
modules
{
module
{
name 'app'
}
module
{
name 'integration-tests'
}
}
}
}.writeTo('$mainDir/pom.xml');
}
[...]
运行它时,在上面用
// Error
标记的位置出现错误:> No signature of method: java.lang.String.call() is applicable for argument typ
es: (java.lang.String) values: [a]
Possible solutions: wait(), any(), wait(long), split(java.lang.String), find(jav
a.lang.String), count(java.lang.String)
我怎样才能解决这个问题?
最佳答案
Note:
groupId
,artifactId
,version
, andpackaging
should always be set directly on thepom
object.
将这些属性从
project
上移到某个级别是否会有所不同?
关于java - 如何使用变量使用Gradle创建pom.xml文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19132104/