上传Android代码到Jcenter(解决了字符映射的问题)
请先阅读:http://blog.saymagic.cn/2015/02/16/release-library-to-jcenter.html
最外面的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() maven {url 'http://dl.bintray.com/tianzhijiexian/maven'} } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' classpath 'com.github.dcendents:android-maven-plugin:1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } }
app的build.gradle
apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version version = "1.0.0" android { compileSdkVersion 22 buildToolsVersion "22.0.1" resourcePrefix "随便填" defaultConfig { minSdkVersion 8 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } lintOptions { abortOnError true } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } def siteUrl = 'https://github.com/xxx/xxx' // 项目的主页 def gitUrl = 'https://github.com/xxx/xxx.git' // Git仓库的url group = "com.kale.xx" // Maven Group ID for the artifact,一般填你唯一的包名 install { repositories.mavenInstaller { // This generates POM.xml with proper parameters pom { project { packaging 'aar' // Add your description here name 'Extra xxx' //项目描述 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 'kale' //填写开发者基本信息 name 'kale' email 'xxxxx@qq.com' } } scm { connection gitUrl developerConnection gitUrl url siteUrl } } } } } tasks.withType(JavaCompile) { options.encoding = "UTF-8" } task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
} task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } javadoc { options { encoding "UTF-8" charSet 'UTF-8' author true // 支持author标记 version true // 支持version标记 links "http://docs.oracle.com/javase/7/docs/api" } } artifacts { archives javadocJar archives sourcesJar } Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") configurations = ['archives'] pkg { repo = "maven" //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库 name = "ExtraXXXXX" //发布到Bintray上的项目名字 websiteUrl = siteUrl vcsUrl = gitUrl licenses = ["Apache-2.0"] publish = true } }
local.properties
## This file is automatically generated by Android Studio. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file should *NOT* be checked into Version Control Systems, # as it contains information specific to your local configuration. # # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. sdk.dir=H\:\\Android\\sdk bintray.user = 名字 bintray.apikey = 密钥
这时你会遇到一些坑,那么就赶快看看下面的文章是如何解决javadoc中的坑吧:
http://www.jianshu.com/p/c721f9297b2f?utm_campaign=hugo&utm_medium=reader_share&utm_content=note
这里还有一个示例:https://github.com/douo/lru-image/blob/master/library/build.gradle
参考自:
http://www.cnblogs.com/qianxudetianxia/p/4322331.html
http://www.linuxidc.com/Linux/2015-02/113874.htm
http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2015/0227/2502.html
http://blog.saymagic.cn/2015/02/16/release-library-to-jcenter.html
分类:
Other Skills
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?