DEV Community

Query Filter
Query Filter

Posted on

dupl8

// 1. Define where the "clean" JAR will live
def strippedLibDir = file("$buildDir/stripped-libs")

// 2. Task to perform the "surgery" on the JAR
task stripMessageTypeConstant(type: Copy) {
    doFirst {
        // Create a detached configuration to avoid locking the main build
        def detached = configurations.detachedConfiguration(
            dependencies.create("com.citigroup:EQRioINtf:1.3_D5")
        )
        def oldJarFile = detached.resolve().find { it.name.contains("EQRioINtf") }

        if (oldJarFile) {
            from zipTree(oldJarFile)
            into strippedLibDir
            // EXCLUDE: Physically remove the conflicting constant class
            exclude "com/citigroup/get/zcc/intf/MessageTypeConstant.class"
        }
    }
}

// 3. Update dependencies to use the result
dependencies {
    // Force OESIntf to be the source of truth for the constants
    implementation 'com.citigroup:OESIntf3_8:3.8_A29-SNAPSHOT'

    // Use the stripped directory as a dependency
    // This provides all other classes from EQRioINtf except the constant
    implementation files(strippedLibDir) {
        builtBy stripMessageTypeConstant
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)