I have spring boot based multi module project, which was defined in sourcesets. We are upgrade from java11 to java 17 and gradle 6.9 to 7.2. It was defined using sourcesets, where we are seggregating into multi module project. We got it working most of it except publishing bootJar from service application.
Structure is
- rootProject
-----build.gradle
-----library1
-----build.gradle
-----library2
-----build.gradle
-----Service
-----build.gradle.
Only service project bootjar is not publishing, other libraries are publishing successfully.
All publishing module is in rootProject. And I have disable jar in service as it is not geenrating fatjar or bootjar. So when I do that, it is skipping publishing as well.
Any solution that can help me with able to build all modules and publishing all modules. And have to generate bootjar / fatjar and then publish it from service file.
If enable jar task, then it is publishing that, but there is no use of that jar as it is not bootjar.
Rootproject-build.gradle
import com.github.jk1.license.LicenseReportPlugin
buildscript {
ext {
springBootVersion = '2.7.0'
springCloudVersion = '2021.0.3'
logStashLogbackEncoderVersion = '7.0'
}
repositories {
mavenLocal()
gradlePluginPortal()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE")
classpath("com.github.jk1:gradle-license-report:1.17")
classpath("org.owasp:dependency-check-gradle:7.3.0")
classpath "com.gorylenko.gradle-git-properties:gradle-git-properties:2.4.1"
}
}
plugins {
id("org.sonarqube") version "4.3.1.3277"
id("checkstyle")
}
allprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply plugin: LicenseReportPlugin
apply plugin: 'org.owasp.dependencycheck'
apply plugin: 'eclipse'
group = 'com.example'
version = '1.6.0-SNAPSHOT'
sourceCompatibility = sourceJavaVersion
checkstyle {
toolVersion '10.9.3'
maxWarnings = 0
ignoreFailures false
}
repositories {
mavenLocal()
mavenCentral()
}
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
}
configurations {
implementation.exclude module: 'spring-boot-starter-tomcat'
implementation.exclude group: 'org.apache.tomcat'
compile.exclude module: 'javax.persistence'
compile.exclude module: 'spring-boot-starter-reactor-netty'
}
test {
finalizedBy jacocoTestReport
useJUnitPlatform()
}
subprojects {
publishing {
publications {
mavenJava(org.gradle.api.publish.maven.MavenPublication) {
groupId = "${group}"
artifactId = "${artifactId}"
version = "${version}"
from components.java
}
}
}
}
And service project build.gradle looks like this: I left the commented out lines, so you can see what are the other thinsg I have tried
plugins {
id 'java'
id("org.springframework.boot")
}
apply plugin: 'maven-publish'
bootJar {
enabled = true
}
group = 'com.example'
version = '1.6.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation("net.jodah:expiringmap:0.5.8")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-undertow")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-aop:${springBootVersion}")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation('org.springframework.boot:spring-boot-starter-json')
implementation('org.springframework.boot:spring-boot-starter-validation')
implementation("org.springframework.cloud:spring-cloud-starter-config")
implementation("org.springframework.cloud:spring-cloud-stream-binder-kafka")
implementation("org.springframework.kafka:spring-kafka")
implementation("org.springframework.cloud:spring-cloud-stream")
implementation("org.springframework.cloud:spring-cloud-starter-sleuth")
implementation('org.hibernate:hibernate-java8:5.6.15.Final')
implementation('org.hibernate:hibernate-envers:5.6.15.Final')
implementation('org.hibernate:hibernate-core:5.6.15.Final')
implementation("org.hibernate.validator:hibernate-validator")
implementation("javax.xml.bind:jaxb-api:2.3.0")
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("commons-io:commons-io:2.11.0")
implementation("io.springfox:springfox-swagger2:2.8.0")
implementation("org.eclipse.persistence:eclipselink:2.7.1")
implementation("net.logstash.logback:logstash-logback-encoder:$logStashLogbackEncoderVersion")
implementation 'org.flywaydb:flyway-core:8.4.4'
implementation 'org.flywaydb:flyway-mysql:8.4.4'
implementation("org.modelmapper:modelmapper:2.1.0")
implementation("org.mariadb.jdbc:mariadb-java-client:2.7.3")
implementation('org.springdoc:springdoc-openapi-webmvc-core:1.8.0')
implementation("org.springframework.retry:spring-retry:1.2.5.RELEASE")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation('org.keycloak:keycloak-spring-boot-starter:13.0.1')
implementation('org.keycloak:keycloak-spring-security-adapter')
implementation('com.sun.xml.ws:jaxws-ri:2.3.7')
testImplementation('org.junit.jupiter:junit-jupiter:5.4.2')
testImplementation("org.springframework.cloud:spring-cloud-stream-test-support")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly('com.h2database:h2:2.2.224')
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
//task createBootJar(type: Jar) {
// archiveBaseName = 'flexifin-bankaccount-verification-service'
// archiveClassifier = 'plain'
// manifest {
// attributes 'Main-Class': 'com.example.SpringBootApplication'
// }
// from {
// // Configure the task to include necessary files
// }
//}
//publish.dependsOn(bootJar)
jar {
enabled = false
}
//bootJar {
// enabled = true
//// archiveClassifier = 'plain'
//}
test {
useJUnitPlatform()
}
project.tasks.publish.dependsOn bootJar
project.tasks.publishMavenJavaPublicationToMavenLocal.dependsOn bootJar