https://plugins.gradle.org/docs/publish-plugin
gradle.publish.key=xxx
gradle.publish.secret=xxx
https://plugins.gradle.org/u/qssq666?tab=publishing
将以下内容复制到HOME_DIR/.gradle/gradle.properties (~/.gradle/gradle.properties)文件中:
xxxxxxxxxxxxxxxx
如何将插件添加到插件门户?
注意:如果您以前通过Bintray发布了Gradle插件,请阅读此信息。
步骤1:创建一个帐户。
看起来你已经创建了一个帐户!
步骤2:创建一个API密钥。
访问您的 个人资料页面 ,通过“API密钥”选项卡获取您的API密钥。
您可以使用相同的API密钥来发布尽可能多的插件。
步骤3:将您的API密钥添加到您的Gradle配置。
创建API密钥后, 您的个人资料页面 的“API密钥”选项卡 将提供可以复制并粘贴到Gradle用户属性文件中的代码段。
对于摇篮用户属性文件的默认位置是 $USER_HOME/.gradle/gradle.properties,这里$USER_HOME指的是用户主目录。
还有一个实验任务“登录”,这是插件发布插件的一部分,它自动执行此步骤。您需要遵循参考文档 来了解如何配置此插件。
步骤4:使用插件发布插件。
插件发布插件提供将插件上传到插件门户的任务。它也可以用于在将来发布插件的更新版本。
该插件允许您指定插件的ID,描述,标签和其他信息。该信息也可以在插件发布后稍后进行编辑。
请参阅该插件参考文档了解如何配置和使用这个插件。
步骤5:你完成了
您的插件现在是Gradle插件门户的一部分,可以由世界各地的Gradle用户使用。
谢谢你的贡献。
如何使用插件发布插件?
将Gradle插件发布到插件门户的能力由Gradle“插件发布”插件提供。这个插件不是Gradle发行版的一部分,但是可以从插件门户中获得。
配置完成后,只需运行publishPlugins 插件的构建任务即可发布插件。
在使用插件之前, 请遵循提交说明,以便对Gradle环境进行必要的一次性配置。
build.gradle (Simple Example)
下面开始了
// 首先应用插件 First, apply the publishing plugin
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.gradle.publish:plugin-publish-plugin:0.9.7"
}
}
···
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
// 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
}
// Unless overridden in the pluginBundle config DSL, the project version will
// be used as your plugin version when publishing
version = "1.2"
group = "com.foo.myplugin"
// 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 = 'Greetings from here!'
tags = ['greetings', 'salutations']
plugins {
greetingsPlugin {
id = 'org.samples.greeting'
displayName = 'Gradle Greeting plugin'
}
}
}
完整演示
// First, apply the publishing plugin
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.gradle.publish:plugin-publish-plugin:0.9.7"
}
}
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
// 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
}
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 = 'Greetings from here!'
// 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 {
// first plugin
greetingsPlugin {
id = 'org.samples.greeting'
displayName = 'Gradle Greeting plugin'
tags = ['individual', 'tags', 'per', 'plugin']
version = '1.2'
}
// another plugin
goodbyePlugin {
id = 'org.samples.goodbye'
displayName = 'Gradle Goodbye plugin'
description = 'Override description for this plugin'
tags = ['different', 'for', 'this', 'one']
version = '1.3'
}
}
// Optional overrides for Maven coordinates.
// If you have an existing plugin deployed to Bintray and would like to keep
// your existing group ID and artifact ID for continuity, you can specify
// them here.
//
// As publishing to a custom group requires manual approval by the Gradle
// team for security reasons, we recommend not overriding the group ID unless
// you have an existing group ID that you wish to keep. If not overridden,
// plugins will be published automatically without a manual approval process.
//
// You can also override the version of the deployed artifact here, though it
// defaults to the project version, which would normally be sufficient.
mavenCoordinates {
groupId = "org.samples.override"
artifactId = "greeting-plugins"
version = "1.4"
}
}
用户名错误
Execution failed for task ':banner2:bintrayUpload'.
> Could not create package '1xxx': HTTP/1.1 401 Unauthorized [message:This resource requires authentication]
版本错误
Execution failed for task ':banner2:bintrayUpload'.
> Could not create v': HTTP/1.1 401 Unauthorized [message:This resource requires authentication]
我编写的代码
publish {
userOrg = 'luozheng'//bintray网的用户id
groupId = 'cn.qssq666'//自己定义一个唯一的java的包名
artifactId = 'banner'//在bintray上的package名字
publishVersion = '1.0'//版本号
desc = 'just upload this and ?'//描述,不重要
website = 'https://github.com/qssq666/banner'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
licences = ['Apache-2.0']//协议
}
tasks.withType(Javadoc) { //防止doc错误
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}
//gradlew clean build bintrayUpload -PbintrayUser=luozheng -PbintrayKey=%JCENTER_PWD% -PdryRun=false
本文档实际编写与http://note.youdao.com/noteshare?id=1183d22c3c3246167d6d671d43c5101c&sub=1CEF703230F84D15A18426229272D168
http://note.youdao.com/noteshare?id=3e3cb7a9706fdebed3a4c27276a8b036&sub=05801156892847CBAE73D05B1F971024
http://note.youdao.com/noteshare?id=e7e754ece3025ccebabb5d542688b976&sub=4468E9AA93F84035B3B2D31964A74DDE