无法将String变量添加到我的清单中

时间:2014-07-20 15:03:20

标签: gradle

我有一个build.gradle文件,我想在我的清单中插入一些变量。这就是我所拥有的

def dateformat = new java.text.SimpleDateFormat("yyyy.MM.dd")
version = dateformat.format(new Date());
int userlimit = System.properties['user.limit'] == null ? 1 : System.properties['user.limit'] as int
def owner = System.properties['owner'] == null ? 'Demo version' : System.properties['owner']

task release(dependsOn: [jar, libs, obfuscate]) {
  doLast {
      def classesDir = new File('expanded-libs')
      classesDir.mkdir()

      configurations.embed.each { 
        println "Unzipping $it to expanded-libs.."
        ant.unzip(src: it, dest: 'expanded-libs')
      }

      task combinedJar(type: Jar) {
        from zipTree('build/foo-bar-pg-' + version + '.jar')
        from configurations.embed.collect { println "Adding $it to the fat jar"; zipTree(it) }
        archiveName "../foo-bar-${version}${outputFileNameSuffix}.jar";
        exclude 'META-INF/*'
        duplicatesStrategy 'EXCLUDE'
        manifest {
          attributes 'Implementation-Title': 'Foo Bar Module', 'Implementation-Version': version, 'User-Limit': userlimit, 'Licensed-To': owner
        }
      }
      combinedJar.execute()
  }
}

现在有趣的是它在没有'Licensed-To': owner片段的情况下工作,但不知怎的,我无法在清单中使用该变量。对于整数,它可以工作,但所有者是一个字符串。

如果我运行gradle release -Downer="foo" -Duserlimit=20

,这是我收到的错误消息
* What went wrong:
   Execution failed for task ':release'.
   > Could not find method task() for arguments [{type=class org.gradle.api.tasks.bundling.Jar}, combinedJar, build_36jmpdf
2mspiolilq5o7ipbd86$_run_closure14_closure27_closure29@547a8dfd] on task ':release'.

任何人都可以帮助我如何将String类型的JVM参数放入我的清单中?

1 个答案:

答案 0 :(得分:0)

你在清单属性之后错过了一个结束}。