0

I'm working on Gradle 7 able run my spring-boot app with eclipse and trying to create executable jar with all dependencies to run with java -jar command but I'm not able to achieve it and I'm new to gradle.What is needed to be added or changed in my build.gradle to do so.I had attached the snapshot of my build.gradle below.

project structure: c-viewer +----c-app,build.gradle +------c-app-ui,build.gradle

build.gradle of c-app

println "Main deploy folder: ${appDeployFolder}"
subprojects{
apply plugin: 'io.spring.dependency-management'
apply plugin: "java"
apply from: "${project(':c-app').projectDir}/copyStatic.gradle"
apply from: "${project(':c-app').projectDir}/deployApp.gradle"
deployApp.enabled = true
copyStaticHtml.enabled = false
//findMainClass.enabled = true
dependencies{
implementation project(":chv-lib:chv-lib-config")
implementation("de.codecentric:spring-boot-admin-starter-client")
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'  
implementation 'org.springframework.boot:spring-boot-starter' //added dependency
}
bootJar {
enabled = true
mainClassName = 'com.am.c.Application'
}
}
  • What command are you running to build your jar and what do `copyStatic.gradle` and `deployApp.gradle` do? – Andy Wilkinson Jul 10 '23 at 15:07
  • I'm using gradle clean build on root folder, also those files contain some gradle tasks to create a deployable environment. – THULASI RAM S Jul 10 '23 at 16:02
  • `build` should be fine as it should run the `bootJar` task. You could use `--console=plain` and check the output to confirm that it has been run. Other than that, it will be hard to help you without a [minimal, reproducible example](/help/mcve). There are a lot of unknowns in the information that you have shared so far. – Andy Wilkinson Jul 10 '23 at 16:33
  • I compared with the working version(Spring1.4.0 and gradle 7.0.1) ,using the above command I could see bootJar runs and jar tasks are skipped: > Task :chv-app:chv-app-ui:bootJar > Task :chv-app:chv-app-ui:setJarFileName > Task :chv-app:chv-app-ui:jar SKIPPED What do I need to add any tasks in my build.gradle to enable this? Attached the snapshot of working version some tasks- :chv-app:chv-app-ui:findMainClass :chv-app:chv-app-ui:setJarFileName :chv-app:chv-app-ui:jar :chv-app:chv-app-ui:bootRepackage – THULASI RAM S Jul 11 '23 at 07:30

0 Answers0