gpt4 book ai didi

gradle - 读取外部 .gradle 文件时发布源 jar

转载 作者:行者123 更新时间:2023-12-03 05:53:00 25 4
gpt4 key购买 nike

我的项目中有一个 git 子模块(我无法控制它),其中包含名为 publish.gradle 的文件.这个文件的内容是:

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

version = System.getenv()['VERSION'] ?: version

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}

artifactory {
contextUrl = repoBaseUrl
publish {
String publishRepoKey = version.endsWith('SNAPSHOT') ? repoKeySnapshot : repoKeyRelease
repository {
repoKey = publishRepoKey // The Artifactory repository key to publish to
username = System.getenv()['ARTIFACTORY_USERNAME'] ?: artifactoryUser // The publisher user name
password = System.getenv()['ARTIFACTORY_PASSWORD'] ?: artifactoryPassword // The publisher password
}
defaults {
publications('mavenJava')
publishArtifacts = true
publishPom = true
}
}
resolve {
repoKey = repoKey
}
}

在我的 build.gradle文件我有以下行:
apply from: "${rootDir}/submodule/gradle/publish.gradle"
当我尝试在此行之后添加以下行时:
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}

publishing.publications.mavenJava.artifact sourceJar {
classifier 'sources'
}

然后发布正确的内容,除了 pom存储库中的文件仅包含 <dependencyManagement/>部分和所有依赖项都丢失了。当我从 build.gradle 中删除上述行时 pom是正确的。

最佳答案

尝试覆盖所有 publishing阻止:

publishing {
publications {
mavenJava(MavenPublication) {
from components.java

artifact sourceJar {
classifier "sources"
}
}
}
}

关于gradle - 读取外部 .gradle 文件时发布源 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46582096/

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