= Vert.x Gradle Plugin
An opinionated Gradle plugin for Vert.x projects.
image:https://github.com/jponge/vertx-gradle-plugin/workflows/Java%20CI%20with%20Gradle/badge.svg[Java CI with Gradle] image:https://img.shields.io/github/tag/jponge/vertx-gradle-plugin.svg[tag, link=https://plugins.gradle.org/plugin/io.vertx.vertx-plugin] image:https://img.shields.io/github/license/jponge/vertx-gradle-plugin.svg[license, link=https://github.com/jponge/vertx-gradle-plugin/blob/master/LICENSE] image:https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/io/vertx/vertx-plugin/io.vertx.vertx-plugin.gradle.plugin/maven-metadata.xml.svg?label=gradlePluginPortal["Maven Central",link="https://plugins.gradle.org/plugin/io.vertx.vertx-plugin"]
== What the plugin does
This https://plugins.gradle.org/plugin/io.vertx.vertx-plugin[plugin] simplifies building and running Vert.x applications with Gradle.
It automatically applies the following plugins:
https://docs.gradle.org/current/userguide/java_plugin.html[java]
https://docs.gradle.org/current/userguide/application_plugin.html[application]
+ https://docs.gradle.org/current/userguide/distribution_plugin.html[distribution]
for packaging the app for the JVMhttps://github.com/johnrengelman/shadow[shadow]
to generate uber Jars with all dependencies bundledYou can omit versions from elements in the https://github.com/vert-x3/vertx-stack[the Vert.x stack as the plugin references the corresponding Maven BOM.
NOTE: From version 0.9.0
the plugin no longer sets the sourceCompatibility
to Java 8. You can set it manually like in other https://docs.gradle.org/current/userguide/building_java_projects.html#introduction[Java projects]
.
The plugin automatically adds io.vertx:vertx-core
as a compile
dependency, so you don't need to do it.
The plugin provides a vertxRun
task that can take advantage of the Vert.x auto-reloading capabilities, so you can just run it then have you code being automatically compiled and reloaded as you make changes.
NOTE: If you encounter issues with your application still being running in the background due to how the Gradle caching works, then you may try running the vertxRun
task with gradle --no-daemon vertxRun
.
The plugin provides a vertxDebug
task enabling to debug your code.
NOTE: Reloading is disabled while debugging. Moreover in order to prevent warnings while in debug mode, Vert.x options maxEventLoopExecuteTime
and maxWorkerExecuteTime
are set to java.lang.Long.MAX_VALUE
=== Minimal example
[source,groovy]
plugins { id 'io.vertx.vertx-plugin' version 'x.y.z' // <1> }
repositories { jcenter() }
image:https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/io/vertx/vertx-plugin/io.vertx.vertx-plugin.gradle.plugin/maven-metadata.xml.svg?label=gradlePluginPortal["Maven Central",link="https://plugins.gradle.org/plugin/io.vertx.vertx-plugin"]
Replace x.y.z
with a version available on the https://plugins.gradle.org/plugin/io.vertx.vertx-plugin[Gradle Plugin Portal]
Provided sample.App
is a Vert.x verticle, then:
gradle shadowJar
builds an executable Jar with all dependencies: java -jar build/libs/simple-project-all.jar
gradle vertxRun
starts the application and automatically recompiles (gradle classes
) and reloads the code when any file under src/
is being added, modified or deleted.=== A slightly more elaborated example
A project using vertx-web
and logback
would use a build.gradle
definition like the following one:
plugins { id 'io.vertx.vertx-plugin' version 'x.y.z' }
repositories { jcenter() }
dependencies { compile "io.vertx:vertx-web" // <1> compile "ch.qos.logback:logback-classic:1.2.3" // <2> }