Code Monkey home page Code Monkey logo

gradle-publish's Introduction

gradle-publish

Introduction

This project includes some gradle scripts that can publish gradle project to JCenter.

bintray.gradle: A script to publish an android gradle project to JCenter.

build.gradle: A demo about how to use it.

gradle.properties: The properties that will be used in bintray.gradle. You are needed to copy this file into your library project and configure the values of these properties.

How To Use

1. Save bintray user and API Key infos

First, you should have one bintray account,(bintray.com) and need save the account user name and API Key info to your .gradle folder. If you havent change the GRADLE_USER_HOME position, it will be under your User folder. In this folder, add the follow infos to gradle.properties file, create it if it doesn`t exist.

BINTRAY_USER=bintray account name
BINTRAY_KEY=bintray API Key

If your OS is Windows, then, the path will be C:\Documents and Settings\YourName\.gradle for XP, and C:\Users\YourName\.gradle for WIN7+.

2. modify build.gradle in your library module

Add the dependencies section into build.gradle in your library if it doesn't already exist:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
    }
}

Note: The Gradle version I use is 2.14.1. For the other version, you may need to upgrade or downgrade the android-maven-gradle-plugin or gradle-bintray-plugin version.

Then you need download the bintray.gradle into your library project, and add the following to the bottom of your build.gradle file:

apply from: './bintray.gradle'

3. setup gradle.properties in your library module

Copy the gradle.properties(which is in this project, not the one we modified in step 1) file to your library module, Click Here to copy it. Then setup it as your needed. Follow is an example,

PROJ_GROUP=com.philcalvin
PROJ_VERSION=1.1.0
PROJ_NAME=iconbutton
PROJ_WEBSITEURL=https://github.com/pnc/IconButton
PROJ_ISSUETRACKERURL=
[email protected]:pnc/IconButton.git
PROJ_DESCRIPTION=android icon button
PROJ_ARTIFACTID=com-phillipcalvin-iconbutton

DEVELOPER_ID=pnc
DEVELOPER_NAME=Phil Calvin
[email protected]

The final useage for this example in Android Studio will be:

dependencies {
    compile 'com.philcalvin:com-phillipcalvin-iconbutton:1.1.0'
}

You can see, the format will be PROJ_GROUP:PROJ_ARTIFACTID:PROJ_VERSION.

4. run publish command

Execute gradle bintrayUpload to publish artifacts to bintray.com.

gradle bintrayUpload

Execute gradle artifactoryPublish to publish SNAPSHOT version to oss.jfrog.org.

gradle artifactoryPublish

5. add library to Jcenter

Send a request to bintray.com about adding the library to Jcenter, after the request be approved, others can use your library by one line code in their build.gradle files.

Contributors

Special thanks to:


介绍

本项目包含一些Gradle脚本及属性文件,用于使用Gradle发布项目.

bintray.gradle: 用于发布到JCenter的脚本。

build.gradle: 怎么使用它的Demo.

gradle.properties: 在bintray.gradle中要用到的属性,需要拷贝到你的项目中并进行配置。

如何使用

1. 保存bintray账号信息

首先注册bintray账号,地址:https://bintray.com/ ,账号生成后会自动为你分配一个API Key,账号名以及API Key是我们能够上传库到bintray的钥匙。 我们需要将这些信息存到本地,也就是你的系统.gradle目录,这里要注意,我们保存在系统下,而不是你的project下的.gradle目录,如果你没有配置过GRADLE_USER_HOME的环境变量,则是在你的用户目录下,编辑gradle.properties(如果没有则创建),加入配置:

BINTRAY_USER=bintray account name
BINTRAY_KEY=bintray API Key

并且你的OS是Windows, 并且是XP,那么一般是在 C:\Documents and Settings\用户名\.gradle,而如果是win7以上,那么是在c:\Users\用户名\.gradle

2. 修改library目录下的build.gradle文件

首先在你的library项目中创建bintray.gradle文件,把本项目中的bintray.gradle文件内容拷贝进入,然后在你的library项目的build.gradle添加以下的构建脚本依赖:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
    }
}

接着在这个build.gradle底部添加以下代码:

apply from: './bintray.gradle'

3. 配置library目录下的gradle.properties

复制本项目下的 gradle.properties文件(注意不是第二步中修改的那个文件)到你的library目录下, 点 Here 直接复制。 接下来对内容进行配置,下面是一个例子:

PROJ_GROUP=com.philcalvin
PROJ_VERSION=1.1.0
PROJ_NAME=iconbutton
PROJ_WEBSITEURL=https://github.com/pnc/IconButton
PROJ_ISSUETRACKERURL=
[email protected]:pnc/IconButton.git
PROJ_DESCRIPTION=android icon button
PROJ_ARTIFACTID=com-phillipcalvin-iconbutton

DEVELOPER_ID=pnc
DEVELOPER_NAME=Phil Calvin
[email protected]

上面的例子最终在Android Studio中的引用形式为:

dependencies {
    compile 'com.philcalvin:com-phillipcalvin-iconbutton:1.1.0'
}

可以发现,它的格式是 PROJ_GROUP:PROJ_ARTIFACTID:PROJ_VERSION组成。

4. 执行发布命令

执行 gradle bintrayUpload 将库发布到 bintray.com.

gradle bintrayUpload

执行 gradle artifactoryPublish 可以发布版本到 oss.jfrog.org.

gradle artifactoryPublish

5. 将库加入Jcenter

最后一步,需要登录bintray.com,将我们刚刚发布的库申请加入到jcenter,这样别人才能直接引用到。

特别鸣谢

gradle-publish's People

Contributors

dxjia avatar msdx avatar stephentuso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-publish's Issues

有报错信息

HTTP/1.1 404 Not Found [message:Repo 'maven' was not found

关于提交aar

你好,我的aar里面依赖了第三方aar,那么在其他项目里面依赖我push到jcenter的aar后,并没有关联上我aar里面依赖的第三方aar,请问这个需要怎么做?

关于同步到Maven Central

相关资料显示,在

bintray {
    pkg {
    ....
    }
}

内加入以下内容可以把发布到jcenter的项目同步到Maven Central:

        version {
            name = PROJ_VERSION
            desc = PROJ_DESCRIPTION
            gpg {
                sign = true    //是否GPG签名,可使用Gpg4win创建密钥文件
                passphrase = properties.getProperty("bintray.gpg.password")    //GPG签名所用密钥
            }
            mavenCentralSync {
                sync = true    //是否同步到Maven Central
                user = properties.getProperty("sonatype.user")    //sonatype用户名
                password = properties.getProperty("sonatype.password")    //sonatype密码
                close = '1'
            }
        }

经过不断尝试,发布时没能同步成功,显示以下错误:

* What went wrong:
Execution failed for task ':library:bintrayUpload'.
> Could not sync 'gzu-liyujiang/maven/AndroidPicker/1.0.3' to Maven Central: HTT
P/1.1 400 Bad Request [messages:[Failed to promote repository: central_bundles-6
031. Server response:
 <nexus-error>
  <errors>
    <error>
      <id>*</id>
      <msg>User &apos;liyujiang&apos; missing &apos;promote&apos; permission for
 staging profile: 7edbe315063867</msg>
    </error>
  </errors>
</nexus-error>, Dropping existing partial staging repository.], status:Sync Fail
ed]

您有研究过同步到Maven Central么,能不能指点下?不胜感谢!

SONATYPE_KEY是什么

不好意思,麻烦问一下,SONATYPE_KEY 这个是 GPG 的密码还是什么

引用脚本部分可以修改得更方便

可以修改为以下这个样子,就不用手动下载脚本了,gradle 会自动下载脚本的

apply from : "https://raw.githubusercontent.com/msdx/gradle-publish/master/bintray.gradle"

请教个问题

你好,现在bintray是收费吗?请问下现在您这边还有在使用吗?bintray使用过期后会怎么样?
image

无法发布

系统:windows 7
gradle : 2.10
android plugin 2.0.0-alpha6

日志如下:

D:\github\ClipImageView>gradlew bin
Parallel execution with configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.                                   
:clipimage:bintrayUpload                                                                   
Skipping upload for missing file 'D:\github\ClipImageView\clipimage\build\libs\clipimage-0.1-javadoc.jar'.
Skipping upload for missing file 'D:\github\ClipImageView\clipimage\build\libs\clipimage-0.1-sources.jar'.
Skipping upload for missing file 'D:\github\ClipImageView\clipimage\build\outputs\aar\clipimage-release.aar'.
Skipping upload for missing file 'D:\github\ClipImageView\clipimage\build\publications\mavenJava\pom-default.xml'.

不好用

按照上面配置,依然上传不上去

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.