Within it’s documentation it states to use: plugins { id 'net.researchgate.release' version '2.0.2' }
if using gradle 2.1 or later. This works fine in the build.gradle script.
The problem is I want to use this from within a binary plugin. The plugin is to replace Maven and I need to setup the release configuration/tasks. I have the normal apply plugin: 'XXX@ code for other common plugins e.g. Java, War, PMD etc. I just can’t figure out how to set the above from within the plugin.
When I try to install the project to my local maven repository it fails the tests. The tests do pass without the changes to the plugin. The error message from the failed tests is the same always, failure to apply my custom plugin.
From your original reply it appears I should really put the buildscript block in the project using my plugin, but I don’t even get that far, that is why I put it in the plugin’s build.gradle.
I find it difficult to debug problems with the plugin because it always fails to apply the plugin. What would be the best way to debug this?
I have ran again with --stacktrace and --info, looking at the stacktrace created, the release plugin is not being applied as it cannot find it see the following stacktrace except.
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'net.researchgate.release']
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:117)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:131)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:37)
at org.gradle.api.Project$apply.call(Unknown Source)
at edina.shared.gradle.EdinaPlugin.apply(EdinaPlugin.groovy:31)
at edina.shared.gradle.EdinaPlugin.apply(EdinaPlugin.groovy)
Below is my actual plugin (I’ve removed code not pertinent to the current problem e.g. applying static code analysis plugins.
I’ve added the compile time dependency to a number of places but each has the same result i.e. cannot find ‘net.researchgate:gradle-release:2.0.2’ plugin. I’ve pushed my code to my github page for anyone interest in helping me solve this problem.
Ah, it’s trying to apply the gradle-release plugin but an exception occurs within it. It’s looking for an SCM directory:
Caused by: org.gradle.api.GradleException: Unsupported SCM system, no .svn, .bzr, .git, or .hg found in [some projectDir] or its parent directories.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
at net.researchgate.release.ReleasePlugin.applyScmPlugin(ReleasePlugin.groovy:259)
at net.researchgate.release.ReleasePlugin.apply(ReleasePlugin.groovy:35)
at net.researchgate.release.ReleasePlugin.apply(ReleasePlugin.groovy)
Try putting this in your setup method for your EdinaPluginTest.
project.file(".git").mkdirs()
.hg, .svn would work too, I think. I don’t know enough about the plugin if it makes sense to treat that as a fatal error or just degrade the functionality. You could raise an issue on their GitHub.