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

jonathanhood/gradle-plugin-example: An example of how to build and test a gradle ...

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

开源软件名称(OpenSource Name):

jonathanhood/gradle-plugin-example

开源软件地址(OpenSource Url):

https://github.com/jonathanhood/gradle-plugin-example

开源编程语言(OpenSource Language):

Groovy 100.0%

开源软件介绍(OpenSource Introduction):

Gradle Plugin Example and Tutorial

The Tutorial

  1. Your First Gradle Plugin
  2. Your First Plugin Test
  3. Declaring Tasks the Right Way
  4. Making Unit Testable Plugins
  5. Making Configurable Plugins

What is a Gradle Plugin?

Most fundamentally, a gradle plugin is library of code that, when loaded by Gradle build script, adds new functionality and capabilities to the build system.

Gradle ships with a lot of built in plugins. Most users are probably aware of the java for instance.

A typical build.gradle for java projects using the built in plugins might look like:

apply plugin: "java"

repositories {
	mavenCentral()
}

dependencies {
	testCompile "junit:junit:4.+"
}

In this case the java plugin adds some capabilities such as :

  • Compiling of java source code.
  • Running of java unit tests with junit.
  • Packaging of a java library in a JAR file.

Why would I want to write a Gradle plugin?

Custom gradle plugins are useful to add functionality to the build system in general. Rather than writing custom additions in your build.gradle you distribute your functionality as a plugin. This has a variety of benefits:

  • Organizations can capture common practices (configuration, application packaging, code standards, etc) in a plugin that is shared among many projects.
  • Plugins can be unit and integration tested seperately from a project. This increase the confidence of making build system changes.
  • Plugins are versioned, which allows projects to control change to their build system while still sharing functionality between projects.
  • Plugins allow you to add new functionality to the build system. Custom packaging formats, new ways of running tests, etc.

In my workplace we use a gradle plugin to accomplish all of the above. Our project build.gradle files are typically only declare dependencies, but still enable a wide variety of functionality for code analysis, packaging, integration testing, and other items. This funcionality is shared among a great many projects.




鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
alenkacz/gradle-scalafmt: Gradle plugin for scalafmt发布时间:2022-06-22
下一篇:
palantir/gradle-jacoco-coverage发布时间:2022-06-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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