thoredge
thoredge

Reputation: 12601

Problem with Gradle ear-plugin with ejb's dependencies

I'm trying to use the new ear-plugin (gradle-1.0-milestone-4-20110610162713+0200) with ejb's. I add the ejb-jar as a deploy dependency. However since the deploy dependencies are added intransitivily I don't get the dependencies of the ejb-jar. The only way I found was to also add the ejb-jar as earlib, but then the ejb-jar is added to ear lib directory.

Is there anyway to gracefully add this so that the ejb-jar is added to the root and its dependencies to lib?

Upvotes: 2

Views: 2386

Answers (3)

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)
        }
    }
}

Upvotes: 1

Tilo
Tilo

Reputation: 3325

Five years later GRADLE-1637 is still open... This is how I solved the problem with Gradle 2.13. Hope this helps someone.

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)
        }
    }
}

Upvotes: 0

thoredge
thoredge

Reputation: 12601

Creating ears that support ejbs and skinny wars will be implemented as a part of http://issues.gradle.org/browse/GRADLE-37 and/or http://issues.gradle.org/browse/GRADLE-1637.

Upvotes: 1

Related Questions