0

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.

Thufir
  • 8,216
  • 28
  • 125
  • 273
  • *Each attempt to resolve the dependency creates different errors*: then what are the attempts, and what are the errors? This dependency is resolved as any other dependency: it's an artifact, downloaded from a repo. – JB Nizet Aug 20 '17 at 10:38
  • 1
    @JBNizet I asked follow up questions to clarify: https://stackoverflow.com/q/45808956/262852 https://stackoverflow.com/q/45808971/262852 https://stackoverflow.com/q/45808984/262852 for the errors. – Thufir Aug 22 '17 at 04:41
  • @Thufir, `provided` is a configuration created on your own. You need to add `configurations { provided }` since gradle doesn't provide this configuration out-of-the-box. It's described in the article you linked: https://virgo47.wordpress.com/2015/05/13/why-gradle-doesnt-provide-provided/ – Opal Aug 22 '17 at 06:53

0 Answers0