Skip to content

Commit

Permalink
Local Maven Publishing (#10)
Browse files Browse the repository at this point in the history
* Publishing to local Maven repository
  • Loading branch information
rivancic committed Oct 22, 2021
1 parent 0d4d1e0 commit 7a2fb86
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 5 deletions.
70 changes: 70 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

4 changes: 2 additions & 2 deletions binary-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

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

| Module | Description | Resources |
| Module | Description | Lectures |
| ------------- |:-------------:|-------------:|
| **[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) |
| **[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](https://www.udemy.com/course/gradle-development/learn/lecture/28264772#overview) <br> <br> [Local Maven Publish](https://www.udemy.com/course/gradle-development/learn/lecture/28264772#overview)|
17 changes: 16 additions & 1 deletion binary-plugin/binary-plugin-example/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# 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).
source code for following lectures:
- [Gradle Plugin Development - Binary Plugin](https://www.udemy.com/course/gradle-development/learn/lecture/28264772#overview)
- [Gradle Plugin Development - Publishing - Local Maven Repository](https://www.udemy.com/course/gradle-development/learn/lecture/29080272#overview)

To successfully create a plugin you should:
- Import `java-gradle-plugin` core Gradle plugin
Expand All @@ -24,6 +26,19 @@ to proof that the plugin is applied.
In order that plugin descriptor will be generated you have to specify plugins inside the
`gradlePlugin{}` block.

## Publishing

To be able to publish plugin to a Maven repository you have to apply `maven-publish` plugin, which will give you ability
of artifact publication.

### Local Maven Publishing

To publish compiled plugin to Local Maven repository you have to run task `publishToMavenLocal`. As a result this plugin will
be published to `{user-home}/.m2/repository/com/rivancic/greeting-plugin` directory.

To be able to refenrece this plugin from withing a project you will have to define Local Maven repository inside of
`pluginManagement{}` block in `settings.gradle` file.


## Resources

Expand Down
11 changes: 9 additions & 2 deletions binary-plugin/binary-plugin-example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
/**
* 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.
* java-gradle-plugin - Core Gradle Plugin, <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.
*
* maven-publish - Core Gradle Plugin, <a href="https://docs.gradle.org/current/userguide/publishing_maven.html">Java Gradle Plugin</a>Maven Publish</a>
* plugin will make it possible to publish artifacts to Maven repositories.
*
* com.rivancic.greeting-plugin - if uncommented will apply itself to the Gradle build. It's meant to test the
* functionality of the plugin in project itself.
*/
plugins {
id 'java-gradle-plugin'
id 'maven-publish'
// id 'com.rivancic.greeting-plugin' version '0.1.0' // Can be applied after its published to local or private/remote plugin repository
}

group 'com.rivancic'
Expand Down
16 changes: 16 additions & 0 deletions binary-plugin/binary-plugin-example/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
/**
* By default only Gradle Plugin Portal is defined as a repository that provides Gradle plugins that can be applied
* within <pre>plugins{}<pre> block.
*
* If you want to specify any additional repository you have to define them in pluginManagement block within
* setting.gradle file. Remember pluginManagement has to be the first statement inside settings.gradle file.
*
* In definition below both Gradle Plugin Portal and Maven Local repository will be taken into account when Gradle
* will search for defined plugin by its ID and version.
*/
pluginManagement {
repositories {
gradlePluginPortal()
mavenLocal()
}
}
rootProject.name = 'binary-plugin-example'

0 comments on commit 7a2fb86

Please sign in to comment.