2
我有一个gradle构建脚本,用于检索一些常见的依赖关系,并将它们全部组合起来创建一个“fat jar”。使用gradle发布自定义jar输出?
gradle这个fatJar uploadArchives
然而uploadArchives步以后不使用所产生的罐子,而是与现在没有依赖关系的默认罐子将其覆盖。
如何指定发布步骤以使用“胖jar”而不覆盖创建的jar?
apply plugin: 'java'
apply plugin: 'maven'
version '1.2.3'
sourceSets {
main {
resources.srcDirs = ["resources"]
}
}
repositories {
mavenCentral()
}
dependencies {
runtime 'commons-cli:commons-cli:1.3.1'
....
runtime 'xerces:xercesImpl:2.11.0'
}
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Some common jars',
'Implementation-Version': version
}
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "http://localhost:8081/artifactory/org-sandbox") {
authentication(userName: "admin", password:"password")
}
pom.groupId = 'org.something'
}
}
}
你要发布这两个罐子?或只有胖的?顺便说一句,gradle有一个更新的['maven-publish'](https://docs.gradle.org/current/userguide/publishing_maven.html)插件,它比您使用的'maven'插件处理定制要好一点。 – RaGe
只有胖子......看着maven jar覆盖fatJar步骤创建的jar的过程。 –
您可以随时更改其中的一个文件名。 – RaGe