我正在尝试从groovy迁移到gradle-kotlin dsl,但我是新手,所以我不知道如何配置Jfrog Artifactory。请帮助我将这部分代码转换为gradle-kotlin dsl:
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
artifactory {
contextUrl = "http://10.0.0.49:8081/artifactory"
publish {
repository {
repoKey = 'gradle-dev-local'
username = artifactory_username
password = artifactory_password
}
defaults {
publications('mavenJava')
publishArtifacts = true
publishPom = true
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = "ua.tiras.oloader"
artifactId = 'core'
version = "1.0.62"
artifact("$buildDir/libs/${project.getName()}.jar")
artifact sourceJar {
classifier "sources"
}
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.api.allDependencies.each { dependency ->
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dependency.group)
dependencyNode.appendNode('artifactId', dependency.name)
dependencyNode.appendNode('version', dependency.version)
}
}
}
}
}
4条答案
按热度按时间63lcw9qa1#
我是这样解决的:
oogrdqng2#
我找到了另一个例子-一个官方的JFrog:
https://github.com/jfrog/project-examples/blob/master/gradle-examples/gradle-kts-example-publish/build.gradle.kts
wdebmtf23#
接受的答案并不适合我的artifactory插件版本
4.27.1
。一个很好的地方肯定是前面提到的provided example by JFrog。以下是一个基于官方示例的简化摘录:请注意,
artifactory_url
等引用属性可以在gradle.properties
文件中定义。8zzbczxx4#
你可以用这种方式简化接受的答案。