我制作了一个android库,将它发布到jcenter中的几个版本。但是当我使用它时,我从我自己的库中找到了R和BuildConfig引用。如何避免上传R和BuildConfig。 这是我的build.gradle:
version = "2.1.3"
def siteUrl = 'https://github.com/boybeak/DelegateAdapter'
def gitUrl = 'https://github.com/boybeak/DelegateAdapter.git'
group = "com.github.boybeak"
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
name 'DelegateAdapter'
url siteUrl
licenses {
license {
name 'Apache-2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'boybeak'
name 'gaoyunfei'
email 'boybeak@qq.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
exclude "**/R.class"
exclude "**/BuildConfig.class"
}
task jar(type: Jar) {
from 'build/intermediates/classes/release'
exclude '**/BuildConfig.class'
exclude '**/R.class'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options.encoding "UTF-8"
options.charSet 'UTF-8'
failOnError false
exclude "**/R.java"
exclude "**/BuildConfig.java"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
exclude "**/R.java"
exclude "**/BuildConfig.java"
}
artifacts {
archives jar
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 = "nulldreams"
name = "adapter" // project name in jcenter
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}
答案 0 :(得分:2)
以下是如何避免为您的Android库生成BuildConfig
的方法:
// TODO replace with https://issuetracker.google.com/issues/72050365 once released.
libraryVariants.all(Action {
generateBuildConfigProvider.configure {
enabled = false
}
})
这也适用于Gradle Kotlin DSL。
当您没有任何资源时,我不知道一种防止生成R
类的方法。请发表评论,如果您找到解决方法。