Skip to content

Instantly share code, notes, and snippets.

@twiceyuan
Last active July 11, 2021 01:11
Show Gist options
  • Save twiceyuan/6823979dd4eba441df36cc0bd65b3eb9 to your computer and use it in GitHub Desktop.
Save twiceyuan/6823979dd4eba441df36cc0bd65b3eb9 to your computer and use it in GitHub Desktop.
[Gradle 配置 上传 source.jar] #Gradle
// build a jar with source files
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.set('sources')
}
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
// 如果需要制定上传的仓库和 artifact 信息需要加这个
uploadArchives {
repositories.mavenDeployer {
repository(url: "file://$rootDir/repo")
pom.groupId = "com.ohosure"
pom.artifactId = "component"
pom.version = "1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment