2

I'm using Netbeans 8.2. The plugins "Gradle Support" and "Gradle Java EE Support" are both installed and activated. I can create and use simple (non JavaEE) projects in netbeans with Gradle support. This works like a charme :-)

But how can I create a Java EE project with gradle support? If I click "File - New Project... - Gradle" ther are only "Gradle Root Project", "Single Gradle Project" and "Gradle Subprojet". Also in the "Java EE" category I cannot see any new gradle project items...

Anybody knows how can I create a Java EE Project with gradle support in Netbeans?

Thufir
  • 8,216
  • 28
  • 125
  • 273
Steffen
  • 2,500
  • 4
  • 31
  • 47
  • Which *kind* of `java-ee` project, and packaged how? – Thufir Aug 19 '17 at 10:48
  • I have a EAR project with a WAR subproject, a EJB (JAR) project and several other jar's inside. So I have the EAR project, the WAR project and the EJB project which I will integrate into netbeans as gradle projects. – Steffen Aug 25 '17 at 12:09

1 Answers1

0

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.

Thufir
  • 8,216
  • 28
  • 125
  • 273