将 .jar 文件上传到远程存储库
Posted
技术标签:
【中文标题】将 .jar 文件上传到远程存储库【英文标题】:Uploading a .jar file to a remote repository 【发布时间】:2015-10-06 01:25:30 【问题描述】:这个问题与this有关。我在将 .jar 文件上传到 this 站点时遇到了很多麻烦。按照here 和here 描述的文档步骤,我创建了一个 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/local/bin", include: ["*.jar"])
compile fileTree(dir: "/usr/lib/jvm/java-8-jdk/jre/lib/", include: ["*.jar"])
compile fileTree(dir: "/home/kiara/AppLab/KIARA/kiaragen/lib/", include: ["*.jar"])
pluginBundle
// These settings are set for the whole plugin bundle
website = 'http://www.gradle.org/'
vcsUrl = 'https://github.com/gradle/gradle'
// tags and description can be set for the whole bundle here, but can also
// be set / overridden in the config for specific plugins
description = 'kiaragen version 0.1.0'
version = '0.1.0'
// The plugins block can contain multiple plugin entries.
//
// The name for each plugin block below (greetingsPlugin, goodbyePlugin)
// does not affect the plugin configuration, but they need to be unique
// for each plugin.
// Plugin config blocks can set the id, displayName, version, description
// and tags for each plugin.
// id and displayName are mandatory.
// If no version is set, the project version will be used.
// If no tags or description are set, the tags or description from the
// pluginBundle block will be used, but they must be set in one of the
// two places.
plugins
kiaragenPlugin
id = 'org.fiware.kiara.generator.kiaragen'
displayName = 'kiaragen 0.1.0'
tags = ['kiaragen', 'IDL', 'code', 'generator']
version = '0.1.0'
包含该文件的项目目录也包含 .jar 文件:
$ ls
build build.gradle build.gradle.bak kiaragen-0.1.0.jar kiaragen-0.2.0.jar META-INF
META-INF/gradle-plugins/org.fiware.kiara.generator.kiaragen.properties 包含主类的名称:
Manifest-Version: 1.0
Main-Class: org.fiware.kiara.generator.kiaragen
我需要上传的.jar文件是kiaragen-0.1.0.jar,它的依赖位于:
/home/kiara/AppLab/KIARA/kiaragen/lib/
跑步:
$ gradle publishPluginJar
:publishPluginJar UP-TO-DATE
BUILD SUCCESSFUL
Total time: 4.435 secs
This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.html
使用 --info 标志运行会给出:
$ gradle publishPluginJar --info
Starting Build
Settings evaluated using settings file '/master/settings.gradle'.
Projects loaded. Root project using build file '/home/kiara/AppLab/KIARA/Uploadkiaragen/build.gradle'.
Included projects: [root project 'Uploadkiaragen']
Evaluating root project 'Uploadkiaragen' using build file '/home/kiara/AppLab/KIARA/Uploadkiaragen/build.gradle'.
All projects evaluated.
Selected primary task 'publishPluginJar' from project :
Tasks to be executed: [task ':publishPluginJar']
:publishPluginJar (Thread[main,5,main]) started.
:publishPluginJar
Skipping task ':publishPluginJar' as it is up-to-date (took 0.086 secs).
:publishPluginJar UP-TO-DATE
:publishPluginJar (Thread[main,5,main]) completed. Took 0.148 secs.
BUILD SUCCESSFUL
Total time: 4.792 secs
Stopped 0 compiler daemon(s).
This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.html
问题是我不确定 .jar 文件是否已上传。加载一个使用它的不同项目表明它不是。 阅读文档page:
Some plugins require manual acceptance by the Plugin Portal maintainers, and will not be made available immediately when they are published. This is only the case when you have specified a custom “group ID” for your plugin artifact. The plugin publishing plugin will tell you if your plugin is pending acceptance when you publish.
If your plugin requires changes before it can be accepted, you will be contacted via the email address associated with your account. You will also receive an email when your plugin is accepted.
“插件发布插件”如何在我发布时告诉我我的插件是否正在等待接受?
【问题讨论】:
我猜测 plugin-publishing 插件期望构建创建需要上传的 JAR。按照惯例,JAR 由 jar 任务创建。您没有任何可以编译并打包成 JAR 的源文件,因此所有任务基本上都是“最新的”。可能有一种方法可以将预构建的 JAR 附加到发布任务,但我需要研究如何做到这一点。另外,为什么要预先构建 JAR? @Peter Led*** .jar 文件有两个版本,我只有其中一个版本的代码,只需要另一个 .jar 文件(没有源代码)。我似乎无法在任何地方找到关于将插件上传(发布)到 plugins.gradle.com 的信息。 您应该在 Gradle 论坛的 Plugin Portal 类别下提问。曾经有一个手动过程(我过去使用过),但该文档似乎不再存在。即使您知道如何操作,插件也会经过手动审批流程,Gradle 团队可能对没有源代码的插件不满意。因此,为什么我认为您应该通过论坛与他们联系。我现在也看到我需要“回收”我的一个插件...... 【参考方案1】:plugins.gradle.com 似乎只适用于扩展 gradle 本身功能的插件。
【讨论】:
以上是关于将 .jar 文件上传到远程存储库的主要内容,如果未能解决你的问题,请参考以下文章