我使用本教程将我的小型库发布到jcenter:
https://github.com/danielemaddaluno/gradle-jcenter-publish
然而,当我将它添加到其他项目中的依赖项时,它发现它没有从库中提取任何javadoc。我google了,看起来原因是.aar - 包装。该库不包含任何资源,只包含源代码,因此我认为它可以打包为.jar。我该如何更改gradle脚本呢?提前谢谢。
我使用的build.gradle示例:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"
// This is the library version used when deploying the artifact
version = "1.0.0"
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
//applicationId "com.madx.updatechecker.lib"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jsoup:jsoup:1.8.1'
}
def siteUrl = 'https://github.com/danielemaddaluno/Android-Update-Checker' // Homepage URL of the library
def gitUrl = 'https://github.com/danielemaddaluno/Android-Update-Checker.git' // Git repository URL
group = "com.github.danielemaddaluno.androidupdatechecker" // 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 'Android Update Checker'
description = 'The project aims to provide a reusable instrument to check asynchronously if exists any newer released update of your Android app on the Store.'
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 'danielemaddaluno'
name 'Daniele Maddaluno'
email 'daniele.maddaluno@gmail.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
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
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
// https://github.com/bintray/gradle-bintray-plugin
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "androidupdatechecker"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
// mavenCentralSync {
// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
// user = properties.getProperty("bintray.oss.user") //OSS user token
// password = properties.getProperty("bintray.oss.password") //OSS user password
// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
// }
}
}
}