Kotlin Gradle build with Spring Boot not publishing jars to Artifactory - only build info
Kotlin Gradle build with Spring Boot not publishing jars to Artifactory - only build info
我正在尝试将 Spring 引导 jar 发布到 Artifactory,但无法使其正常工作。这是我的 build.gradle.kts
:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "com.blah"
version = "0.0.2"
java.sourceCompatibility = JavaVersion.VERSION_1_8
plugins {
id("maven-publish")
id("org.springframework.boot") version "2.3.1.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
id("com.google.cloud.tools.jib") version "2.5.0"
kotlin("jvm") version "1.3.72"
kotlin("plugin.spring") version "1.3.72"
id("com.jfrog.artifactory") version "4.13.0"
}
tasks.getByName<Jar>("jar") {
enabled = true
}
tasks.getByName<Jar>("bootJar") {
classifier = "application"
}
repositories {
mavenCentral()
maven {
setUrl("https://artifactory:443/artifactory/txo-maven-virtual")
credentials {
username = System.getenv("ARTIFACTORY_USR")
password = System.getenv("ARTIFACTORY_PSW")
}
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
//publishing {
// (publications) {
// "mavenJava" (MavenPublication::class) {
// from(components["java"])
// }
// }
//}
artifactory {
setContextUrl("https://artifactory/artifactory")
publish(delegateClosureOf<org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig> {
repository(delegateClosureOf<org.jfrog.gradle.plugin.artifactory.dsl.DoubleDelegateWrapper> {
setProperty("repoKey", "txo-")
setProperty("username", System.getenv("ARTIFACTORY_USR"))
setProperty("password", System.getenv("ARTIFACTORY_PSW"))
setProperty("maven", true)
})
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
invokeMethod("publications", "mavenJava")
})
})
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
这会构建并将构建信息推送到 artifactory/api/build
,但不会推送任何 jars。
如果我取消注释掉的内容,我得到:
- What went wrong: Publication with name 'mavenJava' not found.
我怎样才能得到这个东西来发布我的 jar 文件?
试试这个:
publishing {
publications {
register("mavenJava", MavenPublication::class) {
from(components["java"])
}
}
}
我正在尝试将 Spring 引导 jar 发布到 Artifactory,但无法使其正常工作。这是我的 build.gradle.kts
:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "com.blah"
version = "0.0.2"
java.sourceCompatibility = JavaVersion.VERSION_1_8
plugins {
id("maven-publish")
id("org.springframework.boot") version "2.3.1.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
id("com.google.cloud.tools.jib") version "2.5.0"
kotlin("jvm") version "1.3.72"
kotlin("plugin.spring") version "1.3.72"
id("com.jfrog.artifactory") version "4.13.0"
}
tasks.getByName<Jar>("jar") {
enabled = true
}
tasks.getByName<Jar>("bootJar") {
classifier = "application"
}
repositories {
mavenCentral()
maven {
setUrl("https://artifactory:443/artifactory/txo-maven-virtual")
credentials {
username = System.getenv("ARTIFACTORY_USR")
password = System.getenv("ARTIFACTORY_PSW")
}
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
//publishing {
// (publications) {
// "mavenJava" (MavenPublication::class) {
// from(components["java"])
// }
// }
//}
artifactory {
setContextUrl("https://artifactory/artifactory")
publish(delegateClosureOf<org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig> {
repository(delegateClosureOf<org.jfrog.gradle.plugin.artifactory.dsl.DoubleDelegateWrapper> {
setProperty("repoKey", "txo-")
setProperty("username", System.getenv("ARTIFACTORY_USR"))
setProperty("password", System.getenv("ARTIFACTORY_PSW"))
setProperty("maven", true)
})
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
invokeMethod("publications", "mavenJava")
})
})
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
这会构建并将构建信息推送到 artifactory/api/build
,但不会推送任何 jars。
如果我取消注释掉的内容,我得到:
- What went wrong: Publication with name 'mavenJava' not found.
我怎样才能得到这个东西来发布我的 jar 文件?
试试这个:
publishing {
publications {
register("mavenJava", MavenPublication::class) {
from(components["java"])
}
}
}