4

I want to setup a simple Java EE 7 application in eclipse that gets built with gradle. My current tool stack is:

  • Eclipse Java EE 4.5 with Buildship
  • Gradle 2.5
  • Websphere Liberty Profile

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

  1. mvn archetype:generate -DarchetypeGroupId=com.airhacks -DarchetypeArtifactId=javaee7-essentials-archetype -DarchetypeVersion=1.2
  2. Create index.xhtml (facelet) in src/main/webapp
  3. Add faces-config.xml to src/main/webapp/WEB-INF
  4. In eclipse: Configure application server (wildfly)
  5. In eclipse: Import existing Maven project into workspace
  6. In eclipse: Deploy new application to server

How can I do the same using gradle?

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
baumato
  • 358
  • 3
  • 13

2 Answers2

4

Following steps allow to create a Java EE application in eclipse with buildship that can be build with gradle and that can be locally deployed to Websphere Liberty Profile (WLP).

Prerequisites:

  1. Gradle properly installed and GRADLE_HOME is set.
  2. Eclipse Java EE with buildship and WebSphere Developer Tools installed.
  3. WebSphere Liberty Application Server properly configured (Server view)

Steps:

  1. Create gradle project with the Gradle project wizard.
  2. In build.gradle apply plugins war and eclipse-wtp.

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

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

  5. Add src/main/webapp as source folder in projects 'Java Build Path' settings.
  6. In Gradle task view: Refresh the view and run eclipseWtp and war task
  7. Open properties of project and open Project Facets preference page: Set Version of Dynamic Web Module to 3.1.
  8. Deploy locally to WLP and have fun.
Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
baumato
  • 358
  • 3
  • 13
  • 1
    I'm not sure about running eclipseWtp and using buildship. Running eclipseWtp should create eclipse project files for you, including writing all the dependencies into .classpath. However, buildship should manage your dependencies for you, dynamically updating dependencies without having to run a build target. – Azquelt Aug 04 '15 at 16:28
  • Yes, Azquelt, you are right. Seems to be unnecessary. More important is to adjust the project facets manually. – baumato Aug 05 '15 at 07:22
2

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

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

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61