{"action":"opened","issue":{"url":"https://api.github.com/repos/supengchao/MyApplication/issues/1","repository_url":"https://api.github.com/repos/supengchao/MyApplication","labels_url":"https://api.github.com/repos/supengchao/MyApplication/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/supengchao/MyApplication/issues/1/comments","events_url":"https://api.github.com/repos/supengchao/MyApplication/issues/1/events","html_url":"https://github.com/supengchao/MyApplication/issues/1","id":134779320,"number":1,"title":"如何将自己的项目上传到jcenter上？","user":{"login":"supengchao","id":11920742,"avatar_url":"https://avatars.githubusercontent.com/u/11920742?v=3","gravatar_id":"","url":"https://api.github.com/users/supengchao","html_url":"https://github.com/supengchao","followers_url":"https://api.github.com/users/supengchao/followers","following_url":"https://api.github.com/users/supengchao/following{/other_user}","gists_url":"https://api.github.com/users/supengchao/gists{/gist_id}","starred_url":"https://api.github.com/users/supengchao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supengchao/subscriptions","organizations_url":"https://api.github.com/users/supengchao/orgs","repos_url":"https://api.github.com/users/supengchao/repos","events_url":"https://api.github.com/users/supengchao/events{/privacy}","received_events_url":"https://api.github.com/users/supengchao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-19T05:50:56Z","updated_at":"2016-02-19T05:50:56Z","closed_at":null,"body":"### [如何将自己的项目上传到jcenter上？](http://my.oschina.net/weiCloudS/blog/384865)\r\n### 开始\r\n\r\n最近自己写了一个开源控件,是有关标签流控件的(从服务器端获取标签，然后将标签自适应的放进一个容器里)。现在控件写完了，自己就想将它提交到Maven的中心仓库或者是JCenter。可是自己对maven不熟，并且用Android Studio写的工程提交到Maven的中心仓库确实比较繁琐，所以决定还是用JCenter。\r\n### 申请账号\r\n\r\n关与项目提交到JCenter，网上有个教程写的很好，我基本上也是参照上面来做的，但是途中也遇到了一些坑，所以觉得还是有必要叙述一下的。首先你要做的是申请Bintray账号，它是JCenter的托管商，注册完成之后，你需要来到这个界面,记住你的账户名和API key，我一般将它放在local.properties文件中。因为我们待会会用到，做完这些后，你的第一步差不多即完成了。\r\n`sdk.dir=/Applications/ADT/sdk\r\nbintray.user = fyales\r\nbintray.apikey = *************************`\r\n\r\n### 配置工程的build.gradle文件和你要提交的Module的build.gradle文件\r\n\r\n下面我们来看build.gradle文件:\r\n`buildscript {\r\n    repositories {\r\n        jcenter()\r\n    }\r\n    dependencies {\r\n        classpath 'com.android.tools.build:gradle:1.1.0'\r\n        classpath 'com.github.dcendents:android-maven-plugin:1.2'\r\n        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'\r\n        // NOTE: Do not place your application dependencies here; they belong\r\n        // in the individual module build.gradle files\r\n    }\r\n}\r\n\r\nallprojects {\r\n    repositories {\r\n        jcenter()\r\n    }\r\n}`\r\n这里我们用的仓库是JCenter而不是MavenCentral。并且我们需要引入官方提供的两个插件android-maven-plugin和gradle-bintrayl-plugin，这样便于我们提交项目到JCenter.\r\n\r\n接下来就是配置Module的build.gradle文件了\r\n`apply plugin: 'com.android.library'\r\napply plugin: 'com.github.dcendents.android-maven'\r\napply plugin: 'com.jfrog.bintray'\r\n// 提交到仓库中的版本号\r\nversion = \"1.0.0\"\r\n\r\nandroid {\r\n    compileSdkVersion 21\r\n    buildToolsVersion \"21.1.2\"\r\n\r\n    defaultConfig {\r\n        minSdkVersion 14\r\n        targetSdkVersion 21\r\n        versionCode 1\r\n        versionName \"1.0\"\r\n    }\r\n    buildTypes {\r\n        release {\r\n            minifyEnabled false\r\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\r\n        }\r\n    }\r\n}\r\n\r\ndependencies {\r\n    compile fileTree(dir: 'libs', include: ['*.jar'])\r\n    compile 'com.android.support:appcompat-v7:21.0.2'\r\n}\r\n\r\ndef siteUrl = 'https://github.com/fyales/tagcloud'      // 项目的主页\r\ndef gitUrl = 'https://github.com/fyales/tagcloud.git'   // Git仓库的url\r\ngroup = \"com.fyales.android\"\r\ninstall {\r\n    repositories.mavenInstaller {\r\n        pom {\r\n            project {\r\n                packaging 'aar'\r\n                name 'Android TagCloud'    //项目描述\r\n                url siteUrl\r\n                licenses {\r\n                    license {\r\n                        name 'The Apache Software License, Version 2.0'\r\n                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'\r\n                    }\r\n                }\r\n                developers {\r\n                    developer {\r\n                        id 'fyales'        //填写的一些基本信息\r\n                        name 'fyales'\r\n                        email 'fyales@gmail.com'\r\n                    }\r\n                }\r\n                scm {\r\n                    connection gitUrl\r\n                    developerConnection gitUrl\r\n                    url siteUrl\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\ntask sourcesJar(type: Jar) {\r\n    from android.sourceSets.main.java.srcDirs\r\n    classifier = 'sources'\r\n}\r\ntask javadoc(type: Javadoc) {\r\n    source = android.sourceSets.main.java.srcDirs\r\n    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))\r\n}\r\ntask javadocJar(type: Jar, dependsOn: javadoc) {\r\n    classifier = 'javadoc'\r\n    from javadoc.destinationDir\r\n}\r\nartifacts {\r\n    archives javadocJar\r\n    archives sourcesJar\r\n}\r\n\r\nProperties properties = new Properties()\r\nproperties.load(project.rootProject.file('local.properties').newDataInputStream())\r\nbintray {\r\n    user = properties.getProperty(\"bintray.user\")\r\n    key = properties.getProperty(\"bintray.apikey\")\r\n    configurations = ['archives']\r\n    pkg {\r\n        repo = \"maven\"\r\n        name = \"TagCloud\"    //发布到JCenter上的项目名字\r\n        websiteUrl = siteUrl\r\n        vcsUrl = gitUrl\r\n        licenses = [\"Apache-2.0\"]\r\n        publish = true\r\n    }\r\n}`\r\n做完这些后，就可以运行下面的命令将你的项目提交到Bintray了\r\n**gradle bintrayUpload**\r\n\r\n### 最后的步骤\r\n\r\n提交完成之后，你就可以申请你的项目到JCenter,点击Include My Package，在弹出的界面输入你的项目名称确定就可以了，当审核通过后，你就可以直接用你自己项目了.\r\n`dependencies {\r\n    compile 'com.fyales.android:library:1.0.0'\r\n}`\r\n"}}