使用这篇文章中所讲解的内容,能够上传文件到jCenter,亲测可行。 html
1. 纠正许多文章中出现的错误。
Terminal使用的命令行有两个:gradlew install和gradlew bintrayUpload, 注意是“gradlew”而不是“gradle”,若是使用“gradle”会报【'gradle' 不是内部或外部命令,也不是可运行的程序 】的错误。 java
2. 修改gradle文件:
在Project下的build.gradle文件中添加: android
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }在Library下的build.gradle文件中添加:
ext { bintrayRepo = 'maven' bintrayName = 'dateutils' publishedGroupId = 'com.atide.utils.dateutils' libraryName = 'DateUtils' artifact = 'dateutils' libraryDescription = 'Android commonly date utils.' siteUrl = 'null' gitUrl = 'null' libraryVersion = '0.1.9' //做者信息 developerId = 'grofis' developerName = 'Grofis Wagner' developerEmail = '1216226589@qq.com' licenseName = 'The Apache Software License, Version 2.0' licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' allLicenses = ["Apache-2.0"] } apply from: 'https://raw.githubusercontent.com/grofis/gradle/master/jcenter/module_install.gradle' apply from: 'https://raw.githubusercontent.com/grofis/gradle/master/jcenter/module_bintray.gradle'
在Project目录下的local.properties文件中输入以下内容: git
bintray.user=YOUR_BINTRAY_USERNAME bintray.apikey=YOUR_BINTRAY_API_KEY bintray.gpg.password=YOUR_GPG_PASSWORD
3. 在项目中使用已经上传到jCenter并审核经过的Library。
使用时在bintray的项目主页上找到Library,点击“gradle”获取gradle可用的地址,而后把这串地址黏贴到Project的build.gradle文件中,便可正常使用Library的内容。 github