I have built a Gradle plugin and published it to the local maven repository. I can see it in my ~/.m2/repository. However, when I run a Gradle project to use this plugin, it does not even look in the local repository...at least, not based on the output.
It reports this when running from the command-line:
FAILURE: Build failed with an exception.
Where: Build file 'D:\Work\MuseProject\update4j-gradle-plugin\example\build.gradle' line: 15
What went wrong: Plugin [id: 'net.christophermerrill.gradle.update4j', version: '0.1'] was not found in any of the following sources:
-- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
-- Plugin Repositories (could not resolve plugin artifact 'net.christophermerrill.gradle.update4j:net.christophermerrill.gradle.update4j.gradle.plugin:0.1')
Searched in the following repositories: Gradle Central Plugin Repository
I have added mavenLocal() to the buildscript configuration. I also tried adding the specific dependency (as was suggested elsewhere) with no effect
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath 'net.christophermerrill:update4j-gradle-plugin:0.1'
}
}
Best I can tell from the output, it is not even looking in the local repository, but I am not 100% sure. Using the --scan and --info options does not provide any additional insights - they appear to do nothing at all, which I suspect is because the failure appears before the plugins finish loading (just guessing).
Is there a way to determine if Gradle is looking in the local Maven repo? I am trying to eliminate this as a possibility. The alternative, of course, is that my plugin is not published correctly. That will be my next question, after I settle this one :)
Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project. Gradle stores resolved dependencies in its own cache.
You can't use a Maven plugin as-is in Gradle; you'll have to port it to a Gradle plugin. How difficult this is depends on how many Maven APIs the plugin is using. Another strategy might be to call into Maven via Gradle's Exec task.
To convert Maven to Gradle, the only step is to run gradle init in the directory containing the POM. This will convert the Maven build to a Gradle build, generating a settings. gradle file and one or more build. gradle files.
Gradle's local repository folder is: $USER_HOME/. gradle/caches/modules-2/files-2.1.
I think that specifying a custom plugin repository looks promising: this feature lets you configure the plugins{}
DSL to resolve from other repositories in addition to the gradle plugin portal. I think you'd want to update your settings.gradle
with configuration something along the lines of:
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}
(Note that this code block needs to appear at the top of settings.gradle
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With