• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

franzbecker/gradle-lombok: Gradle plugin for Lombok support

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

franzbecker/gradle-lombok

开源软件地址(OpenSource Url):

https://github.com/franzbecker/gradle-lombok

开源编程语言(OpenSource Language):

Groovy 93.2%

开源软件介绍(OpenSource Introduction):

gradle-lombok

License Build Status codecov.io

A Gradle plugin for project Lombok support.

Maintenance mode. Only critical bugs will be fixed and there won't be any more feature from my side. Please feel free to continue contributing and open PRs, I will still review them in a timely manner.

Usage

The plugin is included in the central plugin repository.

A minimal build.gradle looks like this:

plugins {
    id 'io.franzbecker.gradle-lombok' version '5.0.0'
    id 'java'
}

repositories {
    jcenter() // or Maven central, required for Lombok dependency
}

After applying the plugin, the Lombok annotations can be used directly in any Java code and the Lombok Eclipse installer can be called via gradlew installLombok. The Lombok version can be configured using the following syntax:

lombok { // optional: values below are the defaults
    version = "1.18.12"
    sha256 = "49381508ecb02b3c173368436ef71b24c0d4418ad260e6cc98becbcf4b345406"
}

If the verifcation of the integrity shall be skipped, the sha256 value needs to be set to null or an empty string:

lombok {
    sha256 = "" // skip verifyLombok task
}

Some examples can be found in the examples folder.

Motivation

When using Lombok in your Gradle project, you should consider using this plugin because

  • it adds the Lombok dependency to the classpath
  • it simplifies the Eclipse IDE installation
  • it offers support for delomboking

Adding the Lombok dependency

This plugin adds the Lombok dependency to compileOnly and testCompileOnly. Starting with Gradle 4.6 also annotationProcessor and testAnnotationProcessor. Note that for using Gradle prior to version 2.12 please use this plugin in version "1.11" which is the last version that supports Gradle < 2.12.

Simplifying Eclipse IDE installation

The project Lombok website states:

NOTE: You'll still need to download lombok, or doubleclick on the lombok.jar file downloaded by maven / ivy / gradle, to install lombok into your eclipse installation.

When using Lombok in teams with no automated Eclipse provisioning this is quite a pain. Every developer has to retrieve the JAR in the right version, verify its integrity (some won't) and call java -jar lombok.jar.

This plugin adds a task called installLombok to your Gradle build that uses the dependency that has already been added to the compile-only scope, verifies its integrity using SHA-256 and finally invokes the main class of the JAR. This greatly simplifies the installation process for each developer and makes sure that the same version is used across the team.

Delombok support

The plugin offers basic support for delomboking. The DelombokTask is a simple JavaExec task that calls delombok on Lombok's main class and simplifies the setup of such a task in the build process. It is not a ready to use task.

Examples can be found at:

examples/delombok-gradle-groovy/build.gradle and
examples/delombok-gradle-kotlin/build.gradle.kts




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap