我们已经将一个 Maven 多模块项目转换为 gradle,并且在发布 Spring Boot jar 时遇到了问题。
设置是这样的
root
|- module1
|- common
|- common-test
|- module2-common
|- module2-write
|- module3-common
|- module3-write
|- module4
|- module5
|- deploy
deploy包含重新打包的 jar。
发布时(使用 maven-publish),工件只有几千字节大。显然,它实际上并没有发布deployjar。
部署build.gradle.kts
import org.flywaydb.gradle.task.FlywayMigrateTask
import org.springframework.boot.gradle.repackage.RepackageTask
import org.springframework.boot.gradle.run.BootRunTask
plugins {
kotlin("jvm")
id("org.springframework.boot") version ("1.5.6.RELEASE")
id("io.spring.dependency-management") version("1.0.6.RELEASE")
id("org.flywaydb.flyway")
java
}
tasks {
withType<Jar> {
baseName = project.name
version = project.version as String
}
val implementation = configurations.getByName("implementation")
configurations.create("includeAllJars") {
this.extendsFrom(implementation)
}
withType<RepackageTask> {
this.setCustomConfiguration("includeAllJars")
// this.classifier = "exec"
}
}
根build.gradle.kts
plugins {
base
java
idea
kotlin("jvm") version "1.2.51"
kotlin("plugin.jpa") version ("1.2.51")
kotlin("plugin.spring") version ("1.2.51")
id("nebula.maven-publish") version "8.1.0"
...
}
对于出版物部分,我尝试指定 from(components["java"])、artifact(file("deploy/build/libs/deploy-${project.version}.jar"))和上述选项。所有结果都导致发布的 jar 文件只有 1-3KB 大。
我已尝试将发布块移动到 deploy build.gradle.kts,但这会导致此错误
* What went wrong:
Execution failed for task ':deploy:publishMavenPublicationToMavenLocal'.
> Failed to publish publication 'maven' to repository 'mavenLocal'
> Invalid publication 'maven': POM file is invalid. Check any modifications you have made to the POM file.
gradle 插件的 Spring Boot 文档似乎没有列出任何关于此的内容。
MYYA
相关分类