Mat*_*345 7 gradle build.gradle
我有一个 gradle 构建脚本,它检索许多常见的依赖项,并将它们全部组合起来创建一个“胖罐子”。
gradle fatJar 上传档案
但是,随后的 uploadArchives 步骤不会使用生成的 jar,而是使用没有任何依赖项的默认 jar 覆盖它。
如何指定发布步骤以使用“fat 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'
}
}
}
Run Code Online (Sandbox Code Playgroud)
按照 RaGe 的建议,我切换到maven-publish,它允许通过任务名称指定工件。这有效。
publishing {
publications {
maven(MavenPublication) {
groupId 'org.something'
artifact fatJar
}
}
repositories {
maven {
url "http://localhost:8081/artifactory/sandbox"
credentials {
username 'admin'
password 'password'
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7518 次 |
| 最近记录: |