我的项目中有一个 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
正确的。