使用這篇文章中所講解的內容,能夠上傳文件到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