I wrote a spring-boot application with gradle and it runs properly.
I build a fat jar using bootRepackage, I added the maven plugin so I can install the jars.
The problem is that I can't install the fat jar to the maven repository.
Here's my gradle script for the base project, note that I'm still trying to install to my local repository (we're a new company and we're still building a remote repository)
subprojects {
group 'myGroup'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
sourceCompatibility = 1.8
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:0.5.6.RELEASE'
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE'
classpath 'com.bmuschko:gradle-tomcat-plugin:2.0'
}
}
repositories {
jcenter()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'org.mockito:mockito-all:1.8.4'
compile 'ch.qos.logback:logback-classic:1.1.7'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
}
Gradle script for the module:
apply plugin: "io.spring.dependency-management"
apply plugin: "spring-boot"
repositories {
jcenter()
}
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:2.0.3.RELEASE'
}
}
dependencies {
compile "org.springframework:spring-web"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile 'com.netflix.feign:feign-okhttp:8.16.2'
}
You need ensure that the bootRepackage
task runs before install
. A crude way to do that is to specify both on the command line:
./gradlew bootRepackage install
A better approach is to configure the install
task to depend on the bootRepackage
task. You can do so by adding the following to your build.gradle
:
install {
dependsOn bootRepackage
}
With this configuration in place, Gradle will automatically run bootRepackage
when you run install
. For example:
$ ./gradlew install
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:jar
:bootRepackage
:install
BUILD SUCCESSFUL
Total time: 5.487 secs