Resolving gradle plugins from mavenLocal via pluginId

Resolving gradle plugins from mavenLocal via pluginId
  1. Before you can publish your plugin code to mavenLocal(), you have to add add the ‘maven-publish’ to your plugin build.gradle.
    plugins {
     id 'java-gradle-plugin'
     id 'maven-publish'
     ...
    }
    
  2. Then publish you artifacts to mavenLocal()
    $ gradlew publishToMavenLocal
    
  3. In your application code add mavenLocal() to the pluginManagement of your settings.gradle file.
    pluginManagement {
     repositories {
         mavenLocal()
         gradlePluginPortal()
     }
    }
    
  4. Now you can reach your plugin in your application build.gradle from maven local repository :)
    plugins {
     id '<myplugin-id>' version '<myplugin-version>'
    }
    

A Working example on github

  1. Example Plugin
  2. Example Application Code
$ git clone https://github.com/elmolm/gradle-playground.git
$ cd extended-java-library-plugin
$ gradlew publishToMavenLocal
$ cd ../mavenlocal-plugin-resolve
$ gradlew check

Florian Schmidt

Senior Java EE Software Engineer, Swift Enthusiast, Techie, Managing Partner Sneed IT UG, Founder Smipty