Run jooby's Eclipse development environment on Gradle

Building the development environment of jooby with Eclipse Although it is related to, I would like to be able to build with Gradle.

Prerequisites

--Development environment is Windows --Java 8 is already installed on Windows --Eclipse has been set to work with Java 8 --Gradle is already installed in Eclipse

Building a build environment using Gradle

Creating a jooby project directory

[Here](http://qiita.com/kitaji0306/items/a8deddb194f845a4fbd6#maven%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7% E3% 82% AF% E3% 83% 88% E3% 83% 87% E3% 82% A3% E3% 83% AC% E3% 82% AF% E3% 83% 88% E3% 83% AA% E3% 81% AE% E4% BD% 9C% E6% 88% 90% E3% 81% 93% E3% 81% 93% E3% 81% BE% E3% 81% A7% E3% 81% A7% E3% 82% B5% E3% 83% BC% E3% 83% 90% E5% 86% 85% E3% 81% A7% E3% 81% AE% E4% BD% 9C% E6% A5% AD% E3% 81% AF% Create a project directory by referring to E7% B5% 82% E4% BA% 86). (Implemented to maven archetype)

Introduction of gradle

[vagrant@localhost ~]$ sudo mkdir /opt/gradle
[vagrant@localhost ~]$ sudo wget https://services.gradle.org/distributions/gradle-3.5.1-bin.zip -O /opt/gradle/gradle-3.5.1-bin.zip
--2017-07-18 09:21:40--  https://services.gradle.org/distributions/gradle-3.5.1-bin.zip
Resolving services.gradle.org (services.gradle.org)... 104.16.174.166, 104.16.175.166, 104.16.171.166, ...
Connecting to services.gradle.org (services.gradle.org)|104.16.174.166|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://downloads.gradle.org/distributions/gradle-3.5.1-bin.zip [following]
--2017-07-18 09:21:40--  https://downloads.gradle.org/distributions/gradle-3.5.1-bin.zip
Resolving downloads.gradle.org (downloads.gradle.org)... 104.16.171.166, 104.16.172.166, 104.16.173.166, ...
Connecting to downloads.gradle.org (downloads.gradle.org)|104.16.171.166|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 73302707 (70M) [application/zip]
Saving to: ‘/opt/gradle/gradle-3.5.1-bin.zip’

100%[====================================================================================>] 73,302,707  19.4MB/s   in 4.1s

2017-07-18 09:21:44 (17.2 MB/s) - ‘/opt/gradle/gradle-3.5.1-bin.zip’ saved [73302707/73302707]

[vagrant@localhost ~]$ sudo unzip -d /opt/gradle/ /opt/gradle/gradle-3.5.1-bin.zip
Archive:  /opt/gradle/gradle-3.5.1-bin.zip
   creating: /opt/gradle/gradle-3.5.1/
  inflating: /opt/gradle/gradle-3.5.1/LICENSE

~~~

Creating a gradle project from a maven project

[vagrant@localhost ~]$ cd /vagrant/my-app/
[vagrant@localhost my-app]$ /opt/gradle/gradle-3.5.1/bin/gradle init --type pom
Starting a Gradle Daemon (subsequent builds will be faster)
:wrapper
:init
Maven to Gradle conversion is an incubating feature.

BUILD SUCCESSFUL

Total time: 7.44 secs

Convert to a project for importing Eclipse (This is the end of the server side work)

Added ** apply plugin:'eclipse' ** to build.gradle

build.gradle


[vagrant@localhost my-app]$ cat build.gradle
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'

group = 'com.mycompany'
version = '1.0-SNAPSHOT'

description = """my-app"""

sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
}

configurations.all {
}

repositories {

     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.jooby', name: 'jooby-netty', version:'1.1.3'
    compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.7'
    testCompile group: 'junit', name: 'junit', version:'4.12'
    testCompile group: 'io.rest-assured', name: 'rest-assured', version:'3.0.1'

Perform conversion task

[vagrant@localhost my-app]$ /opt/gradle/gradle-3.5.1/bin/gradle eclipse
:eclipseClasspath
:eclipseJdt
:eclipseProject
:eclipse

BUILD SUCCESSFUL

Total time: 1.68 secs

Import Gradle project from Eclipse

Import by specifying the root directory of the project

クリップボード01.jpg

Added settings for jooby

Refer to jooby's official website and add the necessary settings.

--buildscript block

buildscript {

  repositories {
    mavenCentral()
  }

  dependencies {
    /** joobyRun */
    classpath group: 'org.jooby', name: 'jooby-gradle-plugin', version: '1.1.3'
  }
}

apply plugin: 'java'
apply plugin: 'jooby'

group = 'com.mycompany'
version = '1.0-SNAPSHOT'

description = """my-app"""

sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
	options.encoding = 'UTF-8'
}

configurations.all {
}

repositories {

     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.jooby', name: 'jooby-netty', version:'1.1.3'
    compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.7'
    testCompile group: 'junit', name: 'junit', version:'4.12'
    testCompile group: 'io.rest-assured', name: 'rest-assured', version:'3.0.1'
}

joobyRun {
  mainClassName = 'com.mycompany.App'
}

** joobyRun ** task execution

クリップボード02.jpg

[2017-07-18 09:50:08,097]-[HotSwap] INFO  com.mycompany.App - [dev@netty]: Server started in 1292ms

  GET /    [*/*]     [*/*]    (/anonymous)

listening on:
  http://localhost:8080/

I tried to check the operation

Access ** http: // localhost: 8080 / ** with your browser

Hello World!

It seems to be working properly.

Modify App.java and confirm that Hot Reload is done

It was not reloaded. If you look closely, you will see the following display on the console.

>>> jooby:run[info|Daemon worker]: Hotswap available on: [C:\work\tmp\pleiades\eclipse]

Apparently, the installation path of Eclipse itself has become the base directory. After investigating the source, it seems that the reference directory can be set with a system variable called ** user.dir **. Therefore, define the above variables in the joobyRun task. (Is the path of gradle's root project safe?)

build.gradle


~~~

joobyRun {
  mainClassName = 'com.mycompany.App'
  System.setProperty("user.dir", rootDir.path)
}

Access ** http: // localhost: 8080 / ** in your browser after restarting the jobbyRun task again

Hello World!

Modify App.java and confirm that Hot Reload is done

It seems that it is reloaded automatically.

[2017-07-18 12:13:26,477]-[HotswapScanner] INFO  com.mycompany.App - Stopped

~~~

[2017-07-18 12:13:27,693]-[HotSwap] INFO  com.mycompany.App - [dev@netty]: Server started in 1102ms

  GET /    [*/*]     [*/*]    (/anonymous)

listening on:
  http://localhost:8080/

Access ** http: // localhost: 8080 / ** with your browser

Hello World!

that? It was reloaded, but the correction result is not reflected.

Change the location directory of compiled class files, etc.

As shown below, reloading is detected because the class files viewed by each are different, but the actual reloading result is not reflected. It seems that it was in a situation.

--Eclipse default compilation directory: my-app / bin --Compilation directory normally used by Gradle: build / classes / main --It doesn't matter this time, but the directory that maven normally uses: target / classes

Manually specify the Eclipse compilation directory individually as shown below. クリップボード03.jpg

Access ** http: // localhost: 8080 / ** in your browser after restarting the jobbyRun task again

Hello World!

Modify the source and access again

Hello World!!!!!!!!!!!!!!!!!!!

It was reflected. With this, it seems that you can run the development environment with gradle and proceed with the development work.

Finally

I have manually changed the classpath settings in Eclipse, so I don't think it's the best way to do it, but is it still acceptable for the first time? (Maybe you can set it well when creating a gradle project with the Eclipse plugin)

Recommended Posts

Run jooby's Eclipse development environment on Gradle
Java development environment (Mac, Eclipse)
Run Eclipse CDT on Ubuntu
Run kuromoji on Win10 + Eclipse + Java environment (January 2020 version)
[Eclipse Java] Development environment setting memo
Build jooby development environment with Eclipse
Build Unity development environment on docker
Install Java development environment on Mac
[ev3 × Java] leJOS development environment construction (Eclipse on Mac OSX / bluetooth)
Create Spring Boot development environment on Vagrant
Building a Lambda development environment in Eclipse
Java development environment construction memo on Mac
[Ruby] Building a Ruby development environment on Ubuntu
Build a Java development environment on Mac
Build Java 8 development environment on AWS Cloud9
Build an Ultra96v2 development environment on Docker 1
[Java] Build Java development environment on Ubuntu & check execution
Build Apache / Tomcat development environment on Cent OS 7
Allow development in Eclipse environment using iPLAss SDK
Ruby on Rails development environment construction on M1 Mac
Run Mecab on Win10 + Eclipse + Java + cmecab-java (January 2020)
GitLab development environment setup (GDK) on macOS (September 2020)
Java development environment construction (Mac + Pleiades All in One Eclipse 4.7 + Spring Boot + Gradle (Buildship))
Create a Java development environment using jenv on Mac
Build Java development environment with VS Code on Mac
Build a Ruby on Rails development environment on AWS Cloud9
Java development environment construction on Mac-JDK Install (2020 preservation version)
Docker the development environment of Ruby on Rails project
[Mac] VS Code development environment construction (Java, Gradle, Node.js)
Let's create a gcloud development environment on a centos8 container
Until building Spring-Boot using Eclipse on Mac (Gradle version)
How to run Java EE Tutial on github on Eclipse
[Environment construction] Eclipse installation
Run STS4 on Mac
Java development environment memo
Test run on rails
Run PostgreSQL on Java
java development environment construction
Run Processing on Ant
Run tiscamera on Ubuntu 18.04
Run phpunit on Docker
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
[Environment construction] Get the Ruby on Rails 6 development environment within 1 hour
What I did when I stumbled on IntelliJ gradle 2.2 → 2.6 environment migration
Run the sample "Introduction to TensorFlow Development" on Jetson nano
Create a Java and JavaScript team development environment (gradle environment construction)
[Java development environment construction] Install OpenJDK 11 (Java 11) on macOS with Homebrew.