GithubHelp home page GithubHelp logo

rubentxu / gradle-plugin-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonathanhood/gradle-plugin-example

0.0 3.0 0.0 111 KB

An example of how to build and test a gradle plugin.

Groovy 100.00%

gradle-plugin-example's 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.

gradle-plugin-example's People

Contributors

jonathanhood avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.