Last active
October 25, 2017 15:00
-
-
Save douo/ef1856415c461953d3c1 to your computer and use it in GitHub Desktop.
Android 项目打包成 maven 工件,并发布到 jcenter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.library' | |
apply plugin: 'com.github.dcendents.android-maven' | |
apply plugin: 'com.jfrog.bintray' | |
version = "" // 项目的版本名 | |
android { | |
compileSdkVersion 22 | |
buildToolsVersion '22.0.1' | |
defaultConfig { | |
minSdkVersion 14 | |
targetSdkVersion 22 | |
versionCode 1 | |
versionName version | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' | |
} | |
} | |
sourceSets { | |
main { | |
jniLibs.srcDirs = ['libs'] | |
} | |
} | |
} | |
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
compile 'com.android.support:support-v4:22.1.1' | |
compile 'com.android.support:appcompat-v7:22.1.1' | |
} | |
def siteUrl = '' // 项目的主页 | |
def gitUrl = '' // Git仓库的url | |
group = "info.dourok" | |
install { | |
repositories.mavenInstaller { | |
// This generates POM.xml with proper parameters | |
pom.project { | |
artifactId = "" // 项目名称 | |
packaging 'aar' | |
// Add your description here | |
name '' //项目描述 | |
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 'douo' //填写的一些基本信息 | |
name 'Tiou Lims' | |
email '' | |
} | |
} | |
scm { | |
connection gitUrl | |
developerConnection gitUrl | |
url siteUrl | |
} | |
} | |
} | |
} | |
task sourcesJar(type: Jar) { | |
from android.sourceSets.main.java.srcDirs | |
classifier = 'sources' | |
} | |
artifacts { | |
archives javadocJar | |
} | |
android.libraryVariants.all { variant -> | |
println variant.javaCompile.classpath.files | |
if(variant.name == 'release') { //我们只需 release 的 javadoc | |
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) { | |
// title = '' | |
// description = '' | |
source = variant.javaCompile.source | |
classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath()) | |
options { | |
encoding "utf-8" | |
links "http://docs.oracle.com/javase/7/docs/api/" | |
linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference" | |
} | |
exclude '**/BuildConfig.java' | |
exclude '**/R.java' | |
} | |
task("javadoc${variant.name.capitalize()}Jar", type: Jar, dependsOn: "generate${variant.name.capitalize()}Javadoc") { | |
classifier = 'javadoc' | |
from tasks.getByName("generate${variant.name.capitalize()}Javadoc").destinationDir | |
} | |
artifacts { | |
archives tasks.getByName("javadoc${variant.name.capitalize()}Jar") | |
} | |
} | |
} | |
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" | |
name = "base" //发布到JCenter上的项目名字 | |
websiteUrl = siteUrl | |
vcsUrl = gitUrl | |
licenses = ["Apache-2.0"] | |
publish = true | |
} | |
} |
找不到javadocJar啊
同楼上
同楼上
试了下打包成也 AAR 没问题的。可再参考这个 ActivityBuilder/release.gradle at master · douo/ActivityBuilder
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请问你确实用这个生成过AAR吗,我这边按着这个操作会提示找不到R文件