How does Gradle resolve the javaee-api dependency

2019-01-27 11:28发布

问题:

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.