jib icon indicating copy to clipboard operation
jib copied to clipboard

Exclude `developmentOnly` dependency by default

Open CoderYellow opened this issue 2 years ago • 3 comments

just like testImplementation and other non production dependency configuration

CoderYellow avatar Nov 22 '23 13:11 CoderYellow

Hi @CoderYellow, would you mind adding a bit more of context to this request (why do we need this, where exactly)? I see that the micronaut example is the place that declares a developmentOnly dependency configuration (used only in the test classpath). It seems to me that this cold be a more general request, so I need to confirm. Thanks in advance!

diegomarquezp avatar Nov 23 '23 16:11 diegomarquezp

Sorry for replying late. Actually, the Spring Boot Gradle plugin also has a developmentOnly extension. It would be helpful to have a configuration option to exclude specific dependency extensions.

CoderYellow avatar Jan 15 '24 14:01 CoderYellow

currently i have to config like this

configure<com.google.cloud.tools.jib.gradle.JibExtension> {
    pluginExtensions {
        pluginExtension {
            implementation = "com.google.cloud.tools.jib.gradle.extension.layerfilter.JibLayerFilterExtension"
            configuration(Action<Configuration> {
                filters {
                    configurations["developmentOnly"]
                        .resolvedConfiguration
                        .firstLevelModuleDependencies
                        .flatMap { dependency ->
                            dependency.moduleArtifacts.map { artifact ->
                                artifact.file
                            }
                        }.forEach {
                            filter {
                                glob = "/app/libs/${it.name}"
                            }
                        }
                }
            })
        }
    }
}

CoderYellow avatar Jan 15 '24 14:01 CoderYellow