简书链接:熬夜搞定单独通过gradle上传java子模块上传到jcenter 文章字数:460,阅读全文大约需要1分钟
这个还是比较头疼的,jiko我换了各种写法都有问题,显然他们系统自带了一个gradle,我设置弄一个gradle文件而且是最新版也没用找不到 ‘java-library’的错误 于是就开始研究以前成功过的,其实也非常简单的jcenter上传了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 //确保可以单独运行本项目 buildscript { repositories { mavenCentral() // maven { url 'https://jitpack.io' } // maven { url 'https://maven.google.com/' } // maven { url 'https://dl.google.com/dl/android/maven2/' } jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' } } apply plugin: 'java-library' dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') compileOnly files('libs/android.jar')//不编译进去。 } //android studio 错误: 编码GBK的不可映射字符 tasks.withType(JavaCompile) { options.encoding = "UTF-8" } sourceCompatibility = "1.7" targetCompatibility = "1.7" apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' def siteUrl = 'https://qssq666.cn' // 修改为你的项目的主页 def gitUrl = 'https://github.com/qssq/robotsdk' // 修改为你的Git仓库的ur group = "cn.qssq666" // Maven Group ID for the artifact,一般填你唯一的包名 install { repositories.mavenInstaller { // This generates POM.xml with proper parameters pom { project { packaging 'aar' // Add your description here qssq name 'auto extand qssq for Android.' //项目描述 url siteUrl // Set your license licenses { license { name 'The Apache Software License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' } } developers { developer { id 'luozheng' //填写的一些基本信息 name 'luozheng1' email '[email protected] ' } } scm { connection gitUrl developerConnection gitUrl url siteUrl } } } } } tasks.withType(Javadoc) { //防止doc错误 options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('encoding', 'UTF-8') options.addStringOption('charSet', 'UTF-8') } task sourcesJar(type: Jar) { // from android.sourceSets.main.java.srcDirs from sourceSets.main.allSource classifier = 'sources' } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from 'build/docs/javadoc' } artifacts { archives javadocJar archives sourcesJar } Properties properties = new Properties() properties.load(project.file('..\\local.properties').newDataInputStream()) bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") configurations = ['archives'] pkg { repo = "maven" name = "extend-imageview" //发布到JCenter上的项目名字 websiteUrl = siteUrl vcsUrl = gitUrl licenses = ["Apache-2.0"] publish = true } }
在项目根目录打开gradle控制台
1 gradlew robot_sdk:clean robot_sdk:build bintrayUpload -PbintrayUser=luozheng -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -PdryRun=false
我这里是执行子目录的打包,这种姿势也是挑战难度了.不然早就搞定了,jiko都搞不定这玩意 里面比较关键的是要修改android的姿势为java的姿势,表示网上根本找不到java的姿势
上传成功之后再次上传提示:
1 2 3 > Could not upload to 'https://api.bintray.com/content/luozheng/maven/extend-imageview/unspecified/cn/qssq666/robot_sdk/unspecified/robot_sdk-unspecified.jar': HTTP/1.1 409 Conflict
应该是一件上传过了
https://www.jianshu.com/p/41e4215b1801