Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
583 views
in Technique[技术] by (71.8m points)

jakarta ee - How does Gradle resolve the javaee-api dependency to build an EAR?

I see that there's an EAR plugin for Gradle. How is it used to build an EAR? Yes, there's an ear task. To build an EAR with an EJB module there's a dependency on java-ee.

How is that dependency resolved?

https://virgo47.wordpress.com/2015/05/13/why-gradle-doesnt-provide-provided/

http://www.lordofthejars.com/2015/10/gradle-and-java-ee.html

http://www.adam-bien.com/roller/abien/entry/the_only_one_dependency_you

I don't mind reading the fine manual -- just please specify a chapter at least rather than RTFM because the fine manual states:

51.4. Dependency management

The Ear plugin adds two dependency configurations: deploy and earlib. All dependencies in the deploy configuration are placed in the root of the EAR archive, and are not transitive. All dependencies in the earlib configuration are placed in the 'lib' directory in the EAR archive and are transitive.

To my reading that doesn't explain in a concrete fashion how the java-ee dependency itself is resolved.

project (rough):

gradleEAR/
├── build.gradle
├── gradle
│?? └── wrapper
│??     ├── gradle-wrapper.jar
│??     └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
    ├── main
    │?? ├── java
    │?? │?? └── net
    │?? │??     └── bounceme
    │?? │??         └── doge
    │?? │??             ├── ejb
    │?? │??             │?? ├── NewSessionBean.java
    │?? │??             │?? └── NewSessionBeanRemote.java
    │?? │??             └── json
    │?? │??                 ├── JsonReaderClient.java
    │?? │??                 ├── JsonReader.java
    │?? │??                 ├── Main.java
    │?? │??                 ├── Marshaller.java
    │?? │??                 ├── MarshallJSON.java
    │?? │??                 ├── ObjectA.java
    │?? │??                 └── PropertiesReader.java
    │?? └── resources
    │??     ├── foo.json
    │??     ├── json.json
    │??     └── properties.properties
    └── test
        └── java

13 directories, 18 files

build file (broken dependencies):

plugins {
    id 'com.gradle.build-scan' version '1.8' 
    id 'java'
    id 'application'
    id 'ear'
}

mainClassName = 'net.bounceme.doge.json.Main'

buildScan {
    licenseAgreementUrl = 'https://gradle.com/terms-of-service'
    licenseAgree = 'yes'
}

repositories {
    jcenter()
}

jar {
    manifest {
        attributes 'Main-Class': 'net.bounceme.doge.json.Main'
    }
}

task fatJar(type: Jar) {
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': '3.4.0'
        attributes 'Main-Class': 'net.bounceme.doge.json.Main'
    }
}

dependencies {
    compile group: 'javax.json', name: 'javax.json-api', version: '1.1'
    compile group: 'org.glassfish', name: 'javax.json', version: '1.1'
/*
    provided group: 'javax', name: 'javaee-api', version: '7.0'
    provided 'javax:javaee-api:7.0'
    providedCompile 'javax:javaee-api:7.0'
*/
}

Each attempt to resolve the dependency creates different errors.

What's the correct syntax to resolve the javaee-api dependency? Please do refer me to the manual.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...