No signature of method: java.lang.String.div() is

2019-08-16 00:37发布

问题:

I am trying to create version numbers based git commits, but I keep getting the following error when I run gradle (this is in the build.gradle file)

ext {
    // Get version number and build number
    def gitNum = "git rev-list --count master".execute().text.trim()
    def version = (gitNum / 10)
    def build = (gitNum.toInterger % 10)
}

Error:

No signature of method: java.lang.String.div() is applicable for argument types:
   (java.lang.Integer) values: [10] Possible solutions:
   is(java.lang.Object), drop(int), wait(), trim(), dump(), any()

回答1:

I think this is what you want.

def gitNum = "git rev-list --count master".execute().text.trim().toInteger()