javaspringspring-bootgradle

build/lib not generated by gradle build


I am working on the spring-boot project from Magnus Larsson's 2nd edition book with gradle 8.11.

I have a multi project structure and I build the jars by running ./gradlew clean build -x test in the topmost directory. This generates jars for all sub-modules (sub-projects?) in their respective build/lib directories.

The problem is I added a new sub-project authorization-server which uses springboot 2.4.4 whereas rest of the projects use springboot 2.6.7.

Now, when I am running the above command, I don't see any build/lib directory inside the sub-project authorization-server. I have the sub-project included in the top-level settings.gradle file with the line include ':spring-cloud:authorization-server'.

As a result, I don't have any jar created for this sub-project.


Can the different spring boot version be an issue?


I have been stuck with this since quite a long time. I am quite new to gradle - so, I am unsure what I am doing wrong. Please help me in solving the same.

Following is my settings.gradle content inside authorization-server:

rootProject.name = 'authorization-server'

And following is my build.gradle content inside authorization-server:

plugins {
    // Can't upgrade to Spring Boot 2.5.x until fixes for the following issues are released:
    // 1. https://github.com/spring-projects-experimental/spring-authorization-server/issues/305
    // 2. https://github.com/spring-projects/spring-security/issues/9787
    id 'java'
    id 'org.springframework.boot' version '2.4.4'
//    id 'io.spring.dependency-management' version '1.1.5'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}

group = 'com.abc.xyz.practice.springcloud'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = '1.8'

//java {
//    toolchain {
//        languageVersion = JavaLanguageVersion.of(8)
//    }
//}
//
//jar {
//    enabled = false
//}

ext {
    set('springCloudVersion', "2020.0.2")
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    implementation 'org.springframework.security.experimental:spring-security-oauth2-authorization-server:0.1.0'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

test {
    useJUnitPlatform()
}

Edit:

  1. I can see the rest of the sub-folders like classes, generated etc. inside the build directory of the authorization-server project - only the libs directory is missing.
  2. Also, the command ./gradlew clean build -x test runs successfully
  3. Jars for the remaining sub-projects are being generated, as usual.

Solution

  • OP has confirmed that the following command builds the missing JAR-file:

    ./gradlew -p spring-cloud/authorization-server bootJar
    

    I could not reproduce the issue with a multimodule Spring Boot project on my computer, so the solution was to add

    tasks.named("build") {
        dependsOn("bootJar")
    }
    

    in order to force execution of target bootJar.