{"id":15651440,"url":"https://github.com/carguo/publishtojcenter","last_synced_at":"2025-04-30T19:46:35.928Z","repository":{"id":107563609,"uuid":"73659266","full_name":"CarGuo/PublishToJcenter","owner":"CarGuo","description":"快速集成发布lib到jcenter的例子，针对新版本的brintray，让你的库可以更简单的发布到jcenter","archived":false,"fork":false,"pushed_at":"2016-11-14T05:44:57.000Z","size":180,"stargazers_count":32,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T14:54:19.434Z","etag":null,"topics":["android","bintray","jcenter","jitpack"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CarGuo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-14T02:29:38.000Z","updated_at":"2023-02-16T19:25:50.000Z","dependencies_parsed_at":"2023-06-08T12:15:48.905Z","dependency_job_id":null,"html_url":"https://github.com/CarGuo/PublishToJcenter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarGuo%2FPublishToJcenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarGuo%2FPublishToJcenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarGuo%2FPublishToJcenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarGuo%2FPublishToJcenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CarGuo","download_url":"https://codeload.github.com/CarGuo/PublishToJcenter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251773656,"owners_count":21641671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","bintray","jcenter","jitpack"],"created_at":"2024-10-03T12:38:27.721Z","updated_at":"2025-04-30T19:46:35.894Z","avatar_url":"https://github.com/CarGuo.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# PublishToJcenter\n发布到jcenter路过各种坑，尝试了各个大神的文章一直跑步起来，这里综合一下\n\n##主要是针对新版本的bintray，发布Android的lib发布Jcenter，需要的Gradle脚本及属性文件.\n\n`bintray.gradle`: 用于发布到JCenter的脚本。\n\n`build.gradle`: project下的脚本\n\n`gradle.properties`: 在`bintray.gradle`对应的属性，新版本增加了组织的概念\n\n`lib/build.gradle`: 针对需要发布的model，其中切记 \u003ch5\u003eapply from: '../bintray.gradle'一定要写在最后面\u003c\\h5\u003e\n\n###1. 注册保存bintray\n\nbintray的地址：https://bintray.com/ ，注册时候qq邮箱和163邮箱注册不了，微软的live邮箱和新浪邮箱可以注册。\n\n网上大多数文章都说进入后会有一个API Key，但是我在edit profile一直没找到，直达后来创建了maven之后才发现。\n\n记住账号名以及API Key是bintray上传必须的。 \n\n目前我是放在了项目的gradle.properties下，需要的时候就填写了发布，配置了一个ignore的文件不会上传，要用就复制过去，各位如果有更好的办法可以提供下\n```\nBINTRAY_USER=bintray account name\nBINTRAY_KEY=bintray API Key\n```\n\n###2. project目录下的`build.gradle`文件，对应\u003ca href=\"https://github.com/CarGuo/PublishToJcenter/blob/master/build.gradle\"\u003ebuild.gradle\u003c/a\u003e\n主要添加这个依赖\n```\nbuildscript {\n    repositories {\n        jcenter()\n    }\n    dependencies {\n        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'\n        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'\n    }\n}\n```\n###3. 在lib的这个`build.gradle`的**底部**添加以下代码：\n    （一定要在底部，對應\u003ca href=\"https://github.com/CarGuo/PublishToJcenter/blob/master/lib/build.gradle\"\u003ebuild.gradle\u003c/a\u003e\n主要添加这个依赖）\n    apply from: './bintray.gradle'\n\n###34.根目录下的`gradle.properties`\n\n接下来对内容进行配置，下面是一个例子：\n```\n# \u003cdependency\u003e\n#   \u003cgroupId\u003ecom.shuyu\u003c/groupId\u003e\n#   \u003cartifactId\u003ebbb\u003c/artifactId\u003e\n#   \u003cversion\u003e1.0.0\u003c/version\u003e\n#   \u003ctype\u003epom\u003c/type\u003e\n# \u003c/dependency\u003e\n\nBINTRAY_USER= 你在bintray上的账号名\nBINTRAY_KEY=  你在bintray上的API KEY\nPROJ_USER_ORG=你在bintray上的组织名字\nPROJ_USER_MAVEN=你在bintray上的repo名字\nPROJ_NAME=你在bintray上的repo名字下的包名\n\nPROJ_GROUP= 这是上的groupId，自己配置\nPROJ_VERSION=这是上面的version，自己配置\nPROJ_ARTIFACTID=上面的artifactId\n\nPROJ_WEBSITEURL=github上的url就好了，可以不填\nPROJ_ISSUETRACKERURL=可以不填\nPROJ_VCSURL=github上的ssh就好了，可以不填\nPROJ_DESCRIPTION=描述，可以不填\n\n\nDEVELOPER_ID=发布人id，自己填\nDEVELOPER_NAME=发布人名字，自己填\nDEVELOPER_EMAIL=发布人邮箱，自己填\n```\n上面的例子最终在Android Studio中的引用形式为：\n```\ndependencies {\n    compile 'com.shuyu:bbb:1.0.0'\n}\n```\n它的格式是 `PROJ_GROUP:PROJ_ARTIFACTID:PROJ_VERSION`组成。\n\n###4. 执行发布命令\n执行 `gradlew bintrayUpload` 将库发布到 bintray.com.\n```\ngradlew bintrayUpload\n```\n###5. 将库加入Jcenter\n最后一步，需要登录bintray.com，将我们刚刚发布的库申请加入到jcenter，这样别人才能直接引用到。\n\n###6、 备注与问题 \nbintray上的创建:\n\n* 这里可以找到你的api key\n\n\u003cimg src= \"https://github.com/CarGuo/PublishToJcenter/blob/master/readmeImg/001.jpg\"\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\n\u003cimg src= \"https://github.com/CarGuo/PublishToJcenter/blob/master/readmeImg/002.jpg\"\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\n* 你需要先创建repo，不然会出现404找不到package，其中name可以根据你的喜欢来填写，后面对应配置到上面gradle.properties的的PROJ_USER_MAVEN\n\n\u003cimg src= \"https://github.com/CarGuo/PublishToJcenter/blob/master/readmeImg/003.jpg\"\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\n\u003cimg src= \"https://github.com/CarGuo/PublishToJcenter/blob/master/readmeImg/004.jpg\"\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\n\n* 你还需要再改repo下创建包，不然会出现404找不到package，主要添加name，后面对应配置到上面gradle.properties的PROJ_NAME\n\n\u003cimg src= \"https://github.com/CarGuo/PublishToJcenter/blob/master/readmeImg/005.jpg\"\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\n\u003cimg src= \"https://github.com/CarGuo/PublishToJcenter/blob/master/readmeImg/006.jpg\"\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\n* 新版本有组织的概念，这个就是组织id，后面对应配置到上面gradle.properties的PROJ_USER_ORG\n\n\u003cimg src= \"https://github.com/CarGuo/PublishToJcenter/blob/master/readmeImg/007.jpg\"\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\n* 一般出现401，400，404的基本都是没有创建好repo和package，还有就是groupId不对，最后就是username和apikey正确就好了\n\n##参考自\n\n* http://www.jianshu.com/p/e2cc4f66b1e7\n* https://github.com/msdx/gradle-publish\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarguo%2Fpublishtojcenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarguo%2Fpublishtojcenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarguo%2Fpublishtojcenter/lists"}