Is it possible/sensible to use the gradle war and ear plugin in the same project?

*爱你&永不变心* 提交于 2019-12-07 14:09:12

问题


I found that the ear plugin overrides the war plugin and prevents the war task being called. I got around it by calling it directly.

Is this remotely sensible or should I give up and move to a multi-project setup in eclipse and gradle?

ear {
    doFirst {
        println " - force build war..."
        tasks.war.execute()
    }

    from("$destinationDir") {
        exclude('nz')
        rename ('TrialApp(.*)(.war)', 'TrialApp.war')
        include 'TrialApp*.war'
        into('')
    }
    deploymentDescriptor {  
                applicationName = "trialapp"
                initializeInOrder = true
                displayName = "Trial App"  
                description = "Trial App EAR for Gradle documentation"
                libraryDirectory = "WEB-INF/lib"  
                webModule("TrialApp.war", "TrialApp")  
    }
}

回答1:


The Ear plugin doesn't override the War plugin, it simply doesn't execute the war task by default. Anyway, what you are trying to do is certainly possible. Instead of adding a dependency to a separate war project (as is described in the documentation you can simply depend on the war task itself.

apply plugin: 'war'
apply plugin: 'ear'

dependencies {
    deploy files(war)
}   


来源:https://stackoverflow.com/questions/26644564/is-it-possible-sensible-to-use-the-gradle-war-and-ear-plugin-in-the-same-project

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