gpt4 book ai didi

maven - Gradle-从单个项目生成和安装多个jar

转载 作者:行者123 更新时间:2023-12-03 04:04:43 27 4
gpt4 key购买 nike

我可以构建我需要的 jar -但是使用gradle install我得到了错误

A POM cannot have multiple artifacts with the same type and classifier. Alr eady have MavenArtifact a:jar:jar:null, trying to add MavenArtifact a:jar:jar:null.



根据文档,为每个存档设置不同的 baseName 可以解决此问题,但不能解决此问题。

我已经尝试过Gradle 2.2.1,以防万一。

相关的build.gradle
task package1 (type: Jar) {
baseName = "a1"
include "**/packageA/**"
}

task package2 (type: Jar) {
baseName "a2"
include "**/packageB/**"
}

task package3 (type: Jar) {
baseName "a3"
include "**/packageC/**"
}
artifacts{
archives package1,package2,package3

}

我不想为Maven POM设置不同的分类器或类型。那是唯一的选择吗?

其他引用:
http://forums.gradle.org/gradle/topics/how_to_publish_multiple_artifacts_w_sources_per_project

最佳答案

我按照https://gradle.org/docs/current/userguide/publishing_maven.html中描述的方法使用gradle publish进行了此工作

task package1 (type: Jar) {
baseName "a1"
version "0.1"
from (sourceSets.main.output){
include "com/packagea/**"
}
}

task package2 (type: Jar) {
baseName "a2"
from (sourceSets.main.output){
include "com/packageb/**"
}
}

// We use the publishing task instead of gradle install to deploy the jar into the local MAVENREPO
publishing {
publications {
publisha1(MavenPublication) {
groupId 'com.my'
artifactId 'a1'
version '0.1'
artifact package1
}
publishb1(MavenPublication) {
groupId 'com.my'
artifactId 'b1'
version '0.1'
artifact package2
}
}

关于maven - Gradle-从单个项目生成和安装多个jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28251513/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com