Gradle - 从单个项目生成并安装多个 jar
Gradle - generating and installing multiple jar from single project
我能够构建我需要的罐子 - 但是使用 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
}
}
我能够构建我需要的罐子 - 但是使用 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
}
}