GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.58k stars 1.43k forks source link

Exclude `developmentOnly` dependency by default #4147

Open CoderYellow opened 9 months ago

CoderYellow commented 9 months ago

just like testImplementation and other non production dependency configuration

diegomarquezp commented 9 months ago

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!

CoderYellow commented 7 months ago

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 commented 7 months ago

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}"
                            }
                        }
                }
            })
        }
    }
}