Psycho Punch
Psycho Punch

Reputation: 6892

Using Gradle plugin from a custom Maven repository

I'm working within a limited dev environment that uses a private Maven repository. In it is hosted a Gradle plugin that I'm trying to use. However, I don't think it's following the expected naming and directory structure for Gradle plugins, so my build fails when I use the Plugin DSL. In the Maven repository, the plugin is structured as something like:

com.mydomain.project:mydomain-plugin:1.0.0

When I refer to this plugin using the Gradle plugin DSL using the following definition:

plugins {
    id 'com.mydomain.project' version '1.0.0'
}

I get an error with my build complaining that it can't find com.mydomain.project:com.mydomain.poject.gradle.plugin:1.0.0. However, there doesn't seem to be a way through the plugin DSL to indicate that the plugin uses a different artifact id pattern. Any ideas how to resolve this?

Upvotes: 1

Views: 4242

Answers (1)

Cisco
Cisco

Reputation: 22952

You can use pluginManagement { } to specify additional repositories for Gradle plugins.

pluginManagement {
    repositories {
        maven {
            url 'https://my-company-maven-repo.com/'
        }
        gradlePluginPortal()
    }
}

See Custom Plugin Repositories for more details.

That's the first step, second you need to ensure you are publishing two artifacts in order to use the plugins { } DSL:

  1. Plugin Marker Artifact
  2. Gradle plugin JAR itself

Both artifacts are created for you by the Java Gradle Plugin Development plugin. If you are not using the plugin, then you will need to create the plugin marker artifact yourself.

Upvotes: 5

Related Questions