我正在尝试使用新的ear-plugin(gradle-1.0-milestone-4-20110610162713 + 0200)和ejb。我将ejb-jar添加为部署依赖项。但是,由于部署依赖项是无意中添加的,因此我没有得到ejb-jar的依赖项。我找到的唯一方法是将ejb-jar添加为earlib,但随后将ejb-jar添加到ear lib目录中。
无论如何都要优雅地添加它,以便将ejb-jar添加到root及其依赖项到lib?
答案 0 :(得分:1)
创建支持ejbs和瘦战的耳朵将作为http://issues.gradle.org/browse/GRADLE-37和/或http://issues.gradle.org/browse/GRADLE-1637的一部分实现。
答案 1 :(得分:1)
This code works for me:
task doEarlib(dependsOn: 'ear') {
def earibConfig = configurations.deploy.copy()
earibConfig.transitive = true
earibConfig.resolvedConfiguration.firstLevelModuleDependencies.each {
dependency ->
dependency.children.each {
transitiveDependency ->
dependencies.add('earlib', transitiveDependency.name)
}
}
}
答案 2 :(得分:0)
五年后GRADLE-1637仍然开放......这就是我用Gradle 2.13解决问题的方法。希望这有助于某人。
apply plugin: 'ear'
def deployedModules = [ 'projectA', 'projectB', 'projectC' ]
deployedModules.forEach {
def projectPath = ":${it}"
evaluationDependsOn(projectPath)
dependencies.add('deploy', dependencies.project(path: projectPath,
configuration: 'archives'))
findProject(projectPath).configurations.runtime.allDependencies.forEach {
boolean isEarModule = it instanceof ProjectDependency &&
(it as ProjectDependency).dependencyProject.name in deployedModules
if (!isEarModule) {
dependencies.add('earlib', it)
}
}
}