Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle maven-publish does not build standalone spring-boot application

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.

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

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

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?

like image 461
bertvh Avatar asked Oct 06 '14 08:10

bertvh


1 Answers

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
} 
like image 187
Andy Wilkinson Avatar answered Oct 12 '22 05:10

Andy Wilkinson