使用Gradle构建Vert.x项目

我们目前在多个内部和外部项目中使用Vert.x。 在最近的项目之前,我们一直在使用Maven构建Vert.x模块。

Gradle是我们选择的构建工具,但是Vert.x网站上描述的默认方法导致了几个问题:

  • 克隆,清理和配置模板项目的任务容易出错。
  • 模板项目不支持最新的Gradle版本> = 2.x;
  • 此方法与IntelliJ IDEA中的Gradle支持不兼容。

在开始我们最近的项目时,我们研究了再次使用Gradle的可能性。 而不是使用Vert.x网站上描述的方法,而是使用Daryl Teo提供的出色的Vert.x Gradle插件

使用以下Gradle构建文件,我们能够从Gradle构建并运行我们的项目,并将其成功导入IntelliJ IDEA:

build.gradle

// Configure the dependencies for our build script
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        // Specify our dependency on the marvelous plugin from Daryl Teo
        classpath 'com.darylteo.vertx:vertx-gradle-plugin:0.1.3'
    }
}
// Apply the Groovy plugin to compile our Groovy code
apply plugin: 'groovy'

// Apply the Vertx plugin
apply plugin: 'vertx'

repositories {
    jcenter()
}

// Specify the project dependencies
dependencies {
    compile "org.codehaus.groovy:groovy-all:2.3.3"
}

// Configure Vertx
vertx {
    platform {
        // Specify Vert.x version
        version '2.1.5'
        // Language used
        lang 'groovy'
    }

    // Configuration of the module using Vert.x fields using camelcased names
    // See: http://vertx.io/mods_manual.html#module-descriptor-file-modjson
    config {
        main 'groovy:com.jdriven.demo.MainVerticle'
    }

    // Specify the config file to pass to Vert.x using -conf when executing the runMod task
    deployments {
        mod {
            platform {
                conf 'config/vertx/dev.json'
            }
        }
    }
}

使用此配置将公开以下与Vert.x相关的Gradle任务:

  • modZip:创建模块zip
  • debugMod:运行模块,包括远程调试
  • runMod:运行模块

有关此奇妙的Gradle Vert.x插件的更多信息,请访问: https : //github.com/darylteo/vertx-gradle-plugin

请注意,Vert.x Gradle插件的功劳完全归于Daryl Teo。 这篇文章仅是为了提高人们对插件存在的认识,并补充他的出色工作。

翻译自: https://www.javacodegeeks.com/2015/03/building-vert-x-projects-using-gradle.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值