Monday, August 24, 2015

Vertxio One: Getting a Vertxio and Gradle up and running.

These the artifacts to get Vertxio3 up and running as a Gradle project.
I'm using Eclipse for the posting but you can use any environment you would like.
This will be an ongoing blog.

Vertxio One: Getting a Vertxio and Gradle up and running.
Vertxio Two: JMeter First Blush

1) You will need JAVA 8 and Vertxio 3.

2) Create a Gradle Project.

3) Edit gradle.build - copy and paste.  Then add your class under the NOTE comment
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '1.2.2'
}
dependencies {
compile 'io.vertx:vertx-core:3.0.0'
}
repositories {
mavenCentral()
}
//NOTE: Add your class here
def mainVerticleDemo = "groovy:vertxio.demo.MyDemo"
mainClassName = "io.vertx.core.Starter"
run {
args = ["run", mainVerticleDemo]
}
jar {
manifest {
attributes 'Main-Verticle': mainVerticleDemo
}
}
shadowJar {
classifier = 'fat'
mergeServiceFiles {
include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
}
dependencies {
exclude(dependency('io.vertx:codegen'))
exclude(dependency('junit:junit'))
exclude(dependency('org.mvel:mvel2'))
exclude(dependency('log4j:log4j'))
}
}
view raw gistfile1.txt hosted with ❤ by GitHub


4) Update dependencies


5) Create class that extends AbstractVerticle.
package vertxio.demo;
import io.vertx.core.AbstractVerticle;
public class MyDemo extends AbstractVerticle{
public void start(){
vertx.createHttpServer()
.requestHandler(req -> {
req.response().putHeader("content-type", "text/html")
.end("<html><body><h1>Hello from vert.x!</h1></body></html>");
}).listen(8080);
}
}
view raw MyDemo.java hosted with ❤ by GitHub

No comments:

Post a Comment