如何将本地.jar文件依赖项添加到远程存储库?

时间:2015-07-15 17:39:11

标签: java eclipse maven groovy gradle

我尝试使用gradle将.jar文件添加到远程存储库。在阅读this问题以及herehere所述的步骤后,我提出了以下 build.gradle 文件:

// 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"
    }
  }
}

我要发布的.jar文件是:

/usr/local/bin/kiaragen-0.1.0.jar

当我尝试发布插件( kiaragen-0.1.0.jar )时,出现以下错误:

$ 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

当我删除凭据属性时,我得到:

$ 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

我不太清楚此时发生了什么:gradle尝试使用发布插件发布发布插件或插件吗?

修改

我已将 build.gradle pluginBundle 部分修改为:

// 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"
    }
  }
}

发布操作现在返回:

$ 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

为什么我需要:

Create a 'META-INF/gradle-plugins/org.fiware.kiara.generator.kiaragen.properties' file with a 'implementation-class' property pointing to the plugin class implementation.

当我只想上传.jar文件?

0 个答案:

没有答案
相关问题