Skip to content

Commit

Permalink
Add Gradle Binary Plugin Example (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
rivancic committed Sep 8, 2021
1 parent f208bd1 commit 0d4d1e0
Show file tree
Hide file tree
Showing 22 changed files with 597 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/modules/binary-plugin-example.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Below is the menu for easier navigation between sections. Every section contains
| ------------- |:-------------:| -------------:|
| **[task](task/)** | This directory contains assignments and examples with the focus on Gradle tasks. The task is sorting files. Those tasks will be the base for plugin development. | [Task Assignment](https://www.udemy.com/course/gradle-development/learn/practice/1322992/introduction#overview) |
| **[script-plugin](script-plugin/)** | Script plugin is the easiest possible way of extracting tasks and any additional build logic from original build.gradle file. | [Script Plugin Lectures](https://www.udemy.com/course/gradle-development/learn/lecture/25307352#overview) |
| **[binary-plugin](binary-plugin/)** | Binary plugin is the most powerful way of writing and packaging a plugin. You'll be able to share the plugin within your own private maven repository or through Gradle Plugin Portal. | [Binary Plugin Lectures](https://www.udemy.com/course/gradle-development/learn/lecture/...) |

For any changes or additional content check [release notes](https://github.com/rivancic/gradle/releases).

Expand Down
7 changes: 7 additions & 0 deletions binary-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Gradle Binary Plugin

This directory contains assignments and examples with the focus on standalone Gradle binary plugins.

| Module | Description | Resources |
| ------------- |:-------------:|-------------:|
| **[binary-plugin-example](binary-plugin-example)** | Example showing necessary components of binary plugin, utilities that `gradle-java-plugin` plugin offers to ease up plugin binary plugin compilation and packaging. Publishing of plugin to local, private remote Maven repository or Gradle Plugin Portal is also covered. | [Binary Plugin Lecture](https://www.udemy.com/course/gradle-development/learn/lecture/28264772#overview) |
8 changes: 8 additions & 0 deletions binary-plugin/binary-plugin-example/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions binary-plugin/binary-plugin-example/.idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions binary-plugin/binary-plugin-example/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions binary-plugin/binary-plugin-example/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions binary-plugin/binary-plugin-example/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions binary-plugin/binary-plugin-example/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions binary-plugin/binary-plugin-example/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions binary-plugin/binary-plugin-example/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions binary-plugin/binary-plugin-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Binary Plugin Example

This project serves as a template for Gradle binary plugin, it contains minimal content to compile it. It also contains
source code for following lecture [Gradle Plugin Development - Binary Plugin](https://www.udemy.com/course/gradle-development/learn/lecture/28264772#overview).

To successfully create a plugin you should:
- Import `java-gradle-plugin` core Gradle plugin
- Create class implementing `Plugin` interface and extending `apply()` method
- Define plugin descriptor in `build.gradle` script file

First of, this is a standalone project with the JVM structure.

## Plugin class

Inside of `src/main/java` directory there is [GreetingPlugin](src/main/java/com/rivancic/gradle/plugin/greeting/GreetingPlugin.java) class implementing Plugin interface.
In order to be able to refer to Gradle API components like Plugin interface you should apply plugin `java-gradle-plugin`
inside `build.gradle` file.

Plugin will print simple logging statement at the configuration time of the project,
to proof that the plugin is applied.

## Plugin descriptor

In order that plugin descriptor will be generated you have to specify plugins inside the
`gradlePlugin{}` block.


## Resources

[Gradle Plugin Development Plugin (Gradle Userguide)](https://docs.gradle.org/current/userguide/java_gradle_plugin.html)

[Developing Custom Gradle Plugins (Gradle Userguide)](https://docs.gradle.org/current/userguide/java_gradle_plugin.html)
26 changes: 26 additions & 0 deletions binary-plugin/binary-plugin-example/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Core <a href="https://docs.gradle.org/current/userguide/java_gradle_plugin.html">Java Gradle Plugin</a>. It simplifies
* compilation and publishing of Gradle binary plugins.
*
*/
plugins {
id 'java-gradle-plugin'
}

group 'com.rivancic'
version '0.1.0'

/**
* An extension for java-gradle-plugin in which we define all the plugins that this project will create.
* Each plugin should have name, id and an implementationClass defined.
* During the jar task it will be verified that plugin descriptor is correct. implementationClass has to be an existing
* class implementing Plugin interface.
*/
gradlePlugin {
plugins {
create("greetingPlugin") {
id = "com.rivancic.greeting-plugin"
implementationClass = "com.rivancic.gradle.plugin.greeting.GreetingPlugin"
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 0d4d1e0

Please sign in to comment.