Certainly not a complete answer -- because I have the same question!
In an empty directory run gradle init --type java-library
. Not sure whether there's a better command more geared towards java-ee.
From Netbeans, create a new project with existing source code.
For the dependencies, that's where it gets a bit hazy. Here's my build.gradle
:
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'
providedCompile 'javax:javaee-api:7.0'
}
Not that I'm quite sure how to import java-ee
dependencies with gradle, but that should get you started in the right direction.
Note the ear
plugin in the first few lines. You might want war
instead.
I'm not too clear on how libs and uber JAR
's fit into EAR
and WAR
builds with Gradle.
When you get a complete or better answer please post.