我向 JitPack 提出了支持请求,他们返回了以下代码,我已经测试过这些代码在 2018 年 4 月 12 日可以正常工作:
plugins {
id "com.github.johnrengelman.shadow" version "2.0.2"
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
group = 'com.github.jitpack-io'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.guava:guava:18.0'
testCompile 'junit:junit:4.12'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
shadowJar {
archiveName = "$baseName-$version.$extension"
}
artifacts {
archives sourcesJar
archives javadocJar
archives shadowJar
}
他们已经通过GitHub发布了代码。
它也可以与 gradle 包装器结合使用:
allprojects {
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionType = Wrapper.DistributionType.ALL
}
}