How can I create a Java EE 7 application using eclipse and gradle?

I want to configure a simple Java EE 7 application in eclipse that is created using gradle. My current tool stack:

  • Eclipse Java EE 4.5 with a design
  • Gradle 2.5
  • Websphere Liberty's Profile

Using Maven and Wildfly before, I basically did the following steps:

  • mvn archetype: generate-DarchetypeGroupId = com.airhacks -DarchetypeArtifactId = javaee7-essentials-archetype -DarchetypeVersion = 1.2
  • Create index.xhtml (facelet) in src / main / webapp
  • Add faces-config.xml to src / main / webapp / WEB-INF
  • In eclipse: setting up an application server (wildfly)
  • In eclipse: imports an existing Maven project into a workspace
  • In eclipse: deploying a new application to a server

How can I do the same with gradle?

+4
source share
2 answers

The following steps allow you to create a Java EE application in eclipse with buildship , which can be created using gradle and can be deployed locally to a Websphere Liberty Profile (WLP) .

Prerequisites:

  • Gradle is correctly installed and GRADLE_HOME installed.
  • Eclipse Java EE with built-in buildship and WebSphere tools installed.
  • WebSphere Liberty Application Server configuration (server view)

Steps:

  • Create a gradle project using the gradle project wizard.
  • Build.gradle uses war and eclipse-wtp plugins.

    <s>apply plugin: 'eclipse-wtp'</s> apply plugin: 'war' 
  • In build.gradle add the dependency to Java EE 7.

     compile 'javax:javaee-api:7.0' 
  • Create beans.xml file in src / main / webapp / WEB-INF

  • Add src / main / webapp as the source folder in the Java Build Path project settings.
  • In the gradle task view: update the view and run eclipseWtp and the military task.
  • Open the project properties and open the Project Facets preferences page: set the version of the dynamic web module to 3.1.
  • Deploy locally in WLP and have fun.
+4
source

If you want to integrate eclipse, download WebSphere Developer Tools (WDT) from the wasdev file . This will allow you to complete steps 2,3,4 and 6.

If you haven’t done so already, check out the wasdev github repository for gradle integration here: https://github.com/WASdev/ci.gradle . You will want to clone this repo and then run gradlew build from the root directory of the repository.

+2
source

All Articles