wordpress不同语言,郑州企业网站优化排名,v2ex wordpress主题,潍坊网站的公司电话一、写在前面 自使用android studio开始#xff0c;就被它独特的依赖方式#xff1a;compile com.android.support:appcompat-v7:25.0.1所深深吸引#xff0c;自从有了它#xff0c;麻麻再也不用担心依赖第三方jar包繁琐无趣啦。而#xff0c;如果自己写一个开源库是一种怎…一、写在前面 自使用android studio开始就被它独特的依赖方式compile com.android.support:appcompat-v7:25.0.1所深深吸引自从有了它麻麻再也不用担心依赖第三方jar包繁琐无趣啦。而如果自己写一个开源库是一种怎样的体验此乃利装国逼利神民器呀 而一路装逼不易你会发现如果你要发布你的开源库到官方的Bintray/Jcenter并非易事所以先去网上一探究竟简单的难的五花八门全误面人具子备弟 不得不感叹学技术本身不难难于达到一个目的的有多种方式而各种方式参差不齐给新手带来很大困惑。但是没办法谁叫你是初学者呢你所能做的只能一步一步的折腾自己。 网上的帖子真多呀五花八门注册账号有问题编写过程有问题版本不一致有问题install有问题....每个人的步骤都不一致所以难于得到一个真正正确的东西导致你错了却不知道错在何处这是最难受的好吧程序员加班就是因为这些细节末梢的事情导致的所以我们要细致 其实给个全面解析楼主是诚惶诚恐深怕一个小细节没有注意又去误人子弟不过楼主也是折腾了很多时间才得以处理的所以真心希望能给大家带来一点帮助不足的地方还请各位拍砖~ 废话不多说直接进入正题这里拿我一个随便的开源库来做处理git地址https://github.com/nanchen2251/CalendarView这是一个炫酷的日历选择控件支持左右滑动农历节假日显示等 演示效果 二、注册账号 1首先你的有开门的钥匙先去https://bintray.com注册一个账号吧你也可以使用第三方登录GithubGoogle但楼主发现如果你的github一直都不能成功原来是邮箱地址不能用qq邮箱 2注册 3提交注册信息 4创建组织和仓库 5填写基本信息 三、配置项目相关 1在project的build.grald添加 classpath com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4 classpath com.github.dcendents:android-maven-gradle-plugin:1.4.1 2)module里面添加 //配置插件
apply plugin: com.github.dcendents.android-maven
apply plugin: com.jfrog.bintray 3Module的build.gradle里面添加如下代码注意注释 version 1.0.7 //这个是版本号必须填写
def siteUrl https://github.com/nanchen2251/CalendarView // 项目的主页
def gitUrl https://github.com/nanchen2251/CalendarView // Git仓库的urlgroup com.nanchen.calendarview // 这里是groupId ,必须填写 一般填你唯一的包名install {repositories.mavenInstaller {// This generates POM.xml with proper parameterspom {project {packaging aar// 项目描述复制我的话这里需要修改。name a view with the lunar calendar //项目描述url siteUrl// 软件开源协议现在一般都是Apache License2.0吧复制我的这里不需要修改。licenses {license {name The Apache Software License, Version 2.0url http://www.apache.org/licenses/LICENSE-2.0.txt}}//填写开发者基本信息复制我的这里需要修改。developers {developer {id nanchen //你公司的idname nanchen2251 //你的用户名email liushilin520foxmail.com // 你的邮箱}}// SCM复制我的这里不需要修改。scm {connection gitUrldeveloperConnection gitUrlurl siteUrl}}}}
}
// 生成jar包的task不需要修改。
task sourcesJar(type: Jar) {from android.sourceSets.main.java.srcDirsclassifier sources
}
// 生成javaDoc的jar不需要修改
task javadoc(type: Javadoc) {options.encoding UTF-8source android.sourceSets.main.java.srcDirsclasspath project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {classifier javadocfrom javadoc.destinationDir
}//下面设置编码格式重点注意如果不设置可能会在gradlew install的时候出现GBK编码映射错误
javadoc {options {encoding UTF-8charSet UTF-8author trueversion truelinks http://docs.oracle.com/javase/7/docs/apititle A CalendarView Support Lunar Calendar For Android // 文档标题}
}artifacts {
// archives javadocJararchives sourcesJar
}// 生成jar包
task releaseJar(type: Copy) {from( build/intermediates/bundles/release)into( ../jar)include(classes.jar)rename(classes.jar, okgo- version .jar)
}// 这里是读取Bintray相关的信息我们上传项目到github上的时候会把gradle文件传上去
// 所以不要把帐号密码的信息直接写在这里写在local.properties中这里动态读取。
Properties properties new Properties()
properties.load(project.rootProject.file(local.properties).newDataInputStream())
bintray {//读取 local.properties 文件里面的 bintray.useruser properties.getProperty(bintray.user)//读取 local.properties 文件里面的 bintray.apikeykey properties.getProperty(bintray.apikey)configurations [archives]pkg {userOrg nanchen //发布到JCenter的组织注意新版本的bintray是需要手动创建的repo maven //发布到JCenter上的仓库名称注意新版本的bintray是需要手动创建的// 发布到Bintray上的项目名字name calendarview-librarywebsiteUrl siteUrlvcsUrl gitUrllicenses [Apache-2.0]publish true // 是否是公开项目 }
} 4一些说明 注意把你的user和apikey信息放在项目的gradle.properties里面当然这是最好的建议 sdk.dirC\:\\Users\\Administrator\\AppData\\Local\\Android\\Sdk1\\Sdk
bintray.user***
bintray.apikey*** 注意上面的userOrg是组织organization的id上面创建过的很多帖子都没有这个或者写的是用户名新版本要使用你创建的组织名称否则失败repo是仓库repository的名称上面创建的我当初就是看的帖子这里说的不清楚怎么也不能成功。 如果忘记了则可以这样查看组织对应id,仓库对应repo,项目对应上面的name。 5如果不出意外这时候你已经可以在android studio的命令行操作Terminal工作空间输入gradlew install; 6)如果你成功了则可以在module的build/outputs下面看到你的aar文件 7 这时候你可以通过命令行输入gradlew bintrayUpload上传到bintray仓库。 8一切准备就绪你这时候已经可以在bintray中看到你的库了最后点击Add to Jcenter申请审核吧一般2-3小时可以审核 9发送请求 填下你的groupId直接send,就会发起一个打包版本的请求 过几个小时通过jcenter那边的审核就会在bintray上收到jcenter那边的同意消息提醒。 恭喜你你的类库上传到jcenter成功了大家都可以用你的类库了。 10开源库的后续更新 我们上传完成后如果发现类库中出现类库中的一个bug这就涉及到更新问题那么怎么更新呢 你只需要在修改代码后该本地build.gradle的版本号按上面的操作执行gradlew installgradlew bintrayUpload到bintray上点击Stage snapshots on oss.jfrog.org”同样发送一个请求不用几分钟就可以用了升级不像首次提交那样非常快。马上就你可以更新github上的引用版本号瞬间心情爽爽哒。 五、一些踩过的坑 1Lint found errors in the project Lint 检查默认是开启的Lint 会检查项目中的语法错误如果没有通过则无法继续。只需要在 Module 的 build.gradle 添加如下代码 android {lintOptions {abortOnError false}
} 2编码问题 也许你会遇到这样 在 windows 下 javadoc 默认的是系统编码Windows 就是 GBK 编码。所以一旦 java 文件中出现中文注释就会报错提示无法映射的GBK编码。 task javadoc(type: Javadoc) {options.encoding utf-8
} 如果还不行则采用我上面的方式 //下面设置编码格式重点注意如果不设置可能会在gradlew install的时候出现GBK编码映射错误
javadoc {options {encoding UTF-8charSet UTF-8author trueversion truelinks http://docs.oracle.com/javase/7/docs/apititle A CalendarView Support Lunar Calendar For Android // 文档标题}
}