dupl8

Published: (February 5, 2026 at 03:06 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Gradle script to strip MessageTypeConstant from a JAR

// 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
    }
}
Back to Blog

Related posts

Read more »

Switch case

Overview - A switch case is a control statement that lets you run different blocks of code based on the value of a variable or expression. - It is often cleane...