gradle custom war task webAppDirName

让人想犯罪 __ 提交于 2019-12-05 20:56:31

There is just one webAppDirName property per project, and the War plugin automatically adds a corresponding from to each War task. So the main problem is how to undo that from. I think the following should work:

apply plugin: "war"

webAppDirName = "non/existing/dir"

task myWarTask(type: War) {
    from "src/anotherfolder/webapp"
    ...
}

An alternative is to only use the War task type, but not the War plugin. You'll have to configure a few more task properties then, and will lose a few features, mostly related to provided configurations and publishing of the War. Of course you can make up for this with explicit configuration (if necessary). If you are interested in the details, have a look at the source code for the War plugin.

PS: webAppDirName is not an extra property (ext.), but a convention property added by the War plugin. Extra properties are only meant for ad-hoc use in build scripts. You'd use ext. when writing an extra property, but omit it when reading the property.

task myWarTask(type: War) {
    from 'src/anotherfolder/webapp'
    version ""
    destinationDir = file("$buildDir/libs")
    baseName = 'myWarName'
    classpath = configurations.myWarConfiguration
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!