publish不会构建独立的spring

publish不会构建独立的spring

本文介绍了Gradle maven-publish不会构建独立的spring-boot应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 gradle build 构建一个spring-boot应用程序(对于独立jar)时,会生成正确的工件。生成的jar包含所有依赖jar,并且是可执行的。

When I build a spring-boot application (to a standalone jar) using gradle build, the proper artifacts are generated. The resulting jar contains all dependent jars and is executable.

我还配置了maven-publish插件,如下所示:

I have also configured the maven-publish plugin as follows:

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

现在当我执行 gradle publish ,一个没有依赖的小得多的jar被构建和发布。

Now when I execute gradle publish, a much smaller jar without dependencies gets build and published.

后面的步骤不会在后一种情况下执行。

Following steps are not executed in the latter case.

:myProject:bootRepackage
:myProject:assemble

如何确保正确的构建步骤是在发布时执行?

How can I make sure the correct build steps are executed when publishing?

推荐答案

我有点惊讶,发布来自 components.java 不会触发Java插件的 assemble 任务。 Spring Boot的 bootRepackage 任务设置为集合任务的依赖关系,因此您需要使 publish 来运行 assemble 。尝试将以下内容添加到 build.gradle 中:

I'm a little surprised that publishing from components.java doesn't trigger the Java plugin's assemble task. Spring Boot's bootRepackage task is setup as a dependency of the assemble task so you'll need to cause publish to run assemble. Try adding the following to your build.gradle:

publish {
    dependsOn assemble
}

这篇关于Gradle maven-publish不会构建独立的spring-boot应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 15:00