Skip to content

Unable to exclude a specific dependency from spring boot dependencies in gradle #29189

Closed
@voduku

Description

@voduku

I would like to know how to exclude a specific dependency from spring boot dependencies in gradle. I am asking this because due to internal restriction and licensing, I can't pull com.oracle.database.jdbc:ojdbc-bom. Despite trying all exclusion recommendation out there, including instruction from spring boot gradle plugin page, none of them seems to be able to alter detachedConfiguration. I get this error no matter what.

Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':detachedConfiguration24'.
   > Could not find com.oracle.database.jdbc:ojdbc-bom:21.3.0.0.

My build.gradle:

plugins {
    id 'org.springframework.boot' version '2.6.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = ''
version = '1.0.0'
sourceCompatibility = '17'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

configurations.all {
    exclude group: 'com.oracle.database.jdbc', module: 'ojdbc-bom'
}

repositories {
    ... // some internal repo that mimic mavenCentral() but with licensing restriction
}

bootJar {
    enabled = false
}

jar {
    enabled = true
}


dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-r2dbc'
    implementation 'io.r2dbc:r2dbc-postgresql'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
}

test {
    useJUnitPlatform()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.com

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions