Whats the meaning of “with” in gradle

折月煮酒 提交于 2019-12-02 00:04:10

In your case you are calling the with()-method of the Jar class. (see the very bottom of the Jar DSL documentation and the Jar API documentation)

Adds the given specs as a child of this spec.

So, it's not the with()-method of Groovy.

With with in this case you seem to call the closure named jar:

jar {
    baseName filename
    manifest {
        attributes 'Main-Class': mainFile
    }
}

task gen (type: Jar) {
    //....
    with jar
}

in run-time (when the builder is called) it'll be converted to:

task gen (type: Jar) {
    //....

  jar {
    baseName filename
    manifest {
        attributes 'Main-Class': mainFile
    }
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!