Eclipse doesn't deploy Gradle project properly

2019-02-19 13:03发布

问题:

So I have a gradle project that apparently has some problems fully integrating with eclipse. When I build the whole thing with "gradle build" command and deploy the EAR file on glassfish4 server, everything appears to work perfectly fine, but when I try to run "gradle eclipse" "gradle eclipseWtp" import the project to eclipse and press "run on server" only the part of the app actually gets deployed... I mean, when you go to admin panel, you can actually see the app there, but the application still doesn't work and when I go to glassfish_home/domains/domain1/applications the directory is empty...

here are my gradle files: gradle.build (root)

subprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse'

    repositories {
       mavenCentral()
    }

    dependencies {
        testCompile 'junit:junit:4.11'
    }

    version = '1.0'

    jar {
        manifest.attributes provider: 'gradle'
    }
}

settings.gradle (root)

include ":ejb", ":common", ":web", ":ejb-integration-tests", ":ear"

build.gradle (web)

apply plugin: 'war'
apply plugin: 'eclipse-wtp'

jar {
    manifest {
        attributes 'Implementation-Title': 'WorldFighter-WEB', 'Implementation-Version': version
    }
}

war {
    archiveName 'WorldFighter.war'
    from 'src/webapp/'
    webInf { from 'src/additionalWebInf' }
}

springVersion = '3.2.2.RELEASE'
sl4jVersion = '1.7.2'

dependencies {

    runtime 'javax.servlet:servlet-api:2.5'

    compile project(':common')

    compile(
        [group: 'org.springframework', name: 'spring-orm', version: springVersion],
        [group: 'org.springframework', name: 'spring-tx', version: springVersion],
        [group: 'org.springframework', name: 'spring-core', version: springVersion],
        [group: 'org.springframework', name: 'spring-web', version: springVersion],
        [group: 'org.springframework', name: 'spring-webmvc', version: springVersion],
        [group: 'org.springframework', name: 'spring-context', version: springVersion],
        [group: 'org.springframework', name: 'spring-context-support', version: springVersion]
    )

    compile(
        [group: 'org.slf4j', name: 'slf4j-jcl', version: sl4jVersion],
        [group: 'org.slf4j', name: 'slf4j-api', version: sl4jVersion]
    )

    compile("org.apache.tiles:tiles-extras:3.0.1") {
        exclude module: 'org.slf4j:jcl-over-slf4j'
        exclude module: 'org.slf4j:slf4j-jdk14'
    }

    compile 'taglibs:standard:1.1.2',
            'javax.transaction:jta:1.1',
            'log4j:log4j:1.2.14',
            'commons-lang:commons-lang:2.6',
            'commons-validator:commons-validator:1.4.0'

}

build.gradle (ejb)

jar {
    manifest {
        attributes 'Implementation-Title': 'WorldFighter-EJB', 'Implementation-Version': version
    }
}

dependencies {
    compile project(':common')
}

build.gradle (ear)

apply plugin: 'ear'
apply plugin: 'eclipse-wtp'

jar {
    manifest {
        attributes 'Implementation-Title': 'WorldFighter-EAR', 'Implementation-Version': version
    }
}

dependencies {
    deploy project(path: ':web', configuration: 'archives')
    deploy project(':ejb')
    deploy project(':common')

    earlib 'org.glassfish.extras:glassfish-embedded-all:3.0'
}

ear {

    deploymentDescriptor {
        applicationName = "WorldFighter"
        displayName = "WorldFighter"
        description = "WorldFighter EAR containing EJBs and Web App"    
    }
}

回答1:

Looks like all dependent projects also should be having eclipse-wtp plugin. Following works for me.

allprojects {
    apply plugin: 'eclipse-wtp'
}

I found this here



回答2:

WTP support in Buildship plugin is yet to come.