I'm trying to add a .jar file to a remote repository using gradle. After reading this question, and the steps described here and here I have come up with the following build.gradle file:
// First, apply the publishing plugin
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.gradle.publish:plugin-publish-plugin:0.9.1"
}
}
apply plugin: "com.gradle.plugin-publish"
// Apply other plugins here, e.g. java plugin for a plugin written in java or
// the groovy plugin for a plugin written in groovy
apply plugin: "java"
// If your plugin has any external java dependencies, Gradle will attempt to
// downloaded them from JCenter for anyone using the plugins DSL
// so you should probably use JCenter for dependency resolution in your own
// project.
repositories {
jcenter()
}
dependencies {
compile gradleApi()
compile localGroovy() //not needed for Java plugins
// other dependencies that your plugin requires
compile fileTree(dir: "/usr/lib/jvm/java-8-jdk/jre/lib/", include: ["*.jar"])
compile fileTree(dir: "/home/kiara/AppLab/KIARA/kiaragen/lib/", include: ["*.jar"])
}
// Unless overridden in the pluginBundle config DSL, the project version will
// be used as your plugin version when publishing
version = "0.1.0"
group = "org.fiware.kiara.kiaragen"
// The configuration example below shows the minimum required properties
// configured to publish your plugin to the plugin portal
pluginBundle {
credentials {
username "Sebi"
password "**************"
}
url = "https://plugins.gradle.org"
description = "kiaragen 0.1.0"
tags = ["fiware", "kiara", "kiaragen"]
plugins {
kiaragenPlugin {
id = "org.fiware.kiara.generator.kiaragen"
displayName = "kiaragen 0.1.0"
}
}
}
The .jar file I want to publish is:
/usr/local/bin/kiaragen-0.1.0.jar
When I try to publish the plugin(kiaragen-0.1.0.jar) I get the following error:
$ gradle publishPlugins
FAILURE: Build failed with an exception.
* Where:
Build file '/home/kiara/AppLab/KIARA/Uploadkiaragen/build.gradle' line: 42
* What went wrong:
A problem occurred evaluating root project 'Uploadkiaragen'.
> Could not find method credentials() for arguments [build_4zc9ztisu145lwynn3m693mcz$_run_closure3_closure4@430b2699] on root project 'Uploadkiaragen'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
When I remove the credential attributes I get:
$ gradle publishPlugins
FAILURE: Build failed with an exception.
* Where:
Build file '/home/kiara/AppLab/KIARA/Uploadkiaragen/build.gradle' line: 43
* What went wrong:
A problem occurred evaluating root project 'Uploadkiaragen'.
> No such property: url for class: com.gradle.publish.PluginBundleExtension
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
It's not very clear to me what's happening at this point: does gradle try to publish the publishing plugin or my plugin using the publishing plugin?
Edit:
I have modified the pluginBundle section of build.gradle to:
// The configuration example below shows the minimum required properties
// configured to publish your plugin to the plugin portal
pluginBundle {
website = "http://www.gradle.org/"
vcsUrl = "https://github.com/gradle/gradle"
description = "kiaragen 0.1.0"
tags = ["fiware", "kiara", "kiaragen"]
plugins {
kiaragenPlugin {
id = "org.fiware.kiara.generator.kiaragen"
displayName = "kiaragen 0.1.0"
}
}
}
The publish operation now returns:
$ gradle publishPlugins
FAILURE: Build failed with an exception.
* Where:
Build file '/home/kiara/AppLab/KIARA/Uploadkiaragen/build.gradle' line: 43
* What went wrong:
A problem occurred evaluating root project 'Uploadkiaragen'.
> No such property: url for class: com.gradle.publish.PluginBundleExtension
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 6.688 secs
[kiara@kiara Uploadkiaragen]$ gradle publishPlugins
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:publishPluginJar
:javadoc UP-TO-DATE
:publishPluginJavaDocsJar
:publishPlugins FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':publishPlugins'.
> No plugin descriptor for plugin ID 'org.fiware.kiara.generator.kiaragen'.
Create a 'META-INF/gradle-plugins/org.fiware.kiara.generator.kiaragen.properties' file with a 'implementation-class' property pointing to the plugin class implementation.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Why do I need to:
Create a 'META-INF/gradle-plugins/org.fiware.kiara.generator.kiaragen.properties' file with a 'implementation-class' property pointing to the plugin class implementation.
when I simply want to upload a .jar file?