The NetBeans Java EE support for Gradle does not support EAR. It is that
simple.
On 4/27/22 09:54, Terry wrote:
I have a very simple Gradle project called MyApp. MyApp is built as an
.ear file that contains a .war file with a test.jsp page. Gradle can
build it and the app will run in TomEE if I deploy the .ear file
manually to the /webapps folder.
Now I'm trying to run it from NetBeans 13 in TomEE using the debugger,
but the Run button is disabled, and there’s no Run section in the
project properties window.
But, this works: I set up my TomEE server in NetBeans. I made a new
"Java with Gradle" “Web Application” project in NetBeans 13 and choose
my TomEE server. I can click the Run button and it starts TomEE and
deploys the app. This “Java with Gradle” project has a Run section in
the project properties window. So, I think NetBeans and TomEE and the
rest of my environment is ok. One difference is that this builds a war
file and MyApp builds an ear file.
NetBeans 13 can open the MyApp folder and it finds the root Gradle
project and the MyApp-war sub project. NetBeans seems to recognize all
the Gradle pieces correctly, and running the gradle build task will
build the ear file correctly.
Why doesn't NetBeans let me run MyApp in TomEE? Is it because my root
project is an ear, and NetBeans simply can't run ear files?
-----------------------------
MyApp project file structure:
-----------------------------
MyApp
|-- gradle/*
|-- build.gradle
|-- gradlew
|-- gradlew.bat
|-- settings.gradle
|-- src
|-- main
|-- resources
|-- META-INF
|-- application.xml
|-- MyApp-war
|-- gradle/*
|-- build.gradle
|-- gradlew
|-- gradlew.bat
|-- src
|-- main
|-- webapp
|-- test.jsp
|-- WEB-INF
|-- web.xml
----------------------
MyApp settings.gradle:
----------------------
rootProject.name = "MyApp"
include 'MyApp-war'
-------------------
MyApp build.gradle:
-------------------
plugins {
id 'ear'
}
repositories {
mavenCentral()
}
dependencies {
deploy project(path: ':MyApp-war', configuration:'archives')
}
ear {
appDirectory = file('src/main/resources')
}
-----------------------
MyApp-war build.gradle:
-----------------------
plugins {
id 'java'
id 'war'
}
repositories {
mavenCentral()
}
dependencies {
}