Hi, apologies if this is a silly question but I seem unable to find a clear answer.
I have written a custom plugin which has been successfully uploaded as a release into my local nexus repo.
From a maven perspective it all seems to be fine. The pom looks like this
in my build.gradle I am referencing the plugin
plugins {
id “com.spidasolutions.gradle.SpidaGradleBasePlugin” version “0.1.0”
}
the build however fails saying the plugin doesnt exist. I assume I need to customise the way the artefact goes into nexus but I cant seem to find anything to help me with this
* What went wrong:
09:05:17.220 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Plugin [id: 'com.spidasolutions.gradle.SpidaGradleBase', version: '0.1.0'] was not found in any of the following sources:
09:05:17.220 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
09:05:17.220 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
09:05:17.220 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] - maven(https://mynexus/nexus/repository/maven-releases) (Could not resolve plugin artifact 'com.spidasolutions.gradle.SpidaGradleBase:com.spidasolutions.gradle.SpidaGradleBase.gradle.plugin:0.1.0')
any assistance would be much appreciated.
thanks
Paul
In order to use the new plugins DSL, it is necessary to publish both the plugin implementation artifact and a marker artifact. The marker artifact is used to resolve the implementation artifact from the id that you provide in the plugins {...} block. The exception suggests that you did not publish the marker artifact (this can be handled automatically for you).
Does your build that published the plugin look like the example plugin example in the user guide? Your usage of the plugin looks fine.
HI James, thanks for the advice. That was what was missing for sure.
I have applied changes that should I would have said have worked but I am still not resolving the plugin for some reason.
I have the gradlePlugin section now
gradlePlugin {
plugins {
spidagradlebase {
id = "com.spidasolutions.gradle.spidagradlebase"
implementationClass = “com.spidasolutions.gradle.SpidaGradleBase”
}
}
}
my plugin has a properties file in the META-INF/gradle-plugins folder to match the id.
I can run gralde plublish successfully and the marker is being generated. It looks like it should be fine to me, the generated POM is
I am then referencing the plugin
plugins {
id ‘com.spidasolutions.gradle.spidagradlebase’ version '0.1.0’
id 'maven’
id ‘groovy’
}
the error appears much the same
* What went wrong:
16:33:12.023 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Plugin [id: ‘com.spidasolutions.gradle.spidagradlebase’, version: ‘0.1.0’] was not found in any of the following sources:
16:33:12.023 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
16:33:12.023 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] - Gradle Core Plugins (plugin is not in ‘org.gradle’ namespace)
16:33:12.023 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] - maven(https://mynexus/nexus/repository/maven-releases/) (Could not resolve plugin artifact ‘com.spidasolutions.gradle.spidagradlebase:com.spidasolutions.gradle.spidagradlebase.gradle.plugin:0.1.0’)
16:33:12.023 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] - Gradle Central Plugin Repository (no ‘com.spidasolutions.gradle.spidagradlebase’ plugin available - see https://plugins.gradle.org for available plugins)
I thought it might be usefull to know that I can resolve the marker artifact using maven
Not sure if this helps the discussion but looking into the --debug output I can see gradle is contructing the url for the marker pom correctly. I can take that url and use curl to get the file
It seems I’m having the same problem you had.
Were you ever able to use the plugins DSL successfully with your custom plugins on Nexus or are you still using the buildscript block?
It looks like the issue is that the plugins dsl ignores the transitive dependency in the marker pom.
I tested this on Gradle version 4.10.
I got it to work eventually, although why it did now work in the first place is still unknown.
My problem was similar to the others’ - the pom file would get downloaded from nexus and for no reason at all gradle would ignore it and go on to try to download it from the gradle plugin portal.
My settings.gradle had some fancy resolution of the maven username and password, and when I simplified that it started working. So now the settings.gradle file looks like: