tl;dr
build.gradle:
...
configurations {
bootRunOnly
}
depencencies {
...
bootRunOnly group: 'org.bouncycastle', name: 'bc-fips', version: '2.0.0'
bootRunOnly group: 'org.bouncycastle', name: 'bcpkix-fips', version: '2.0.7'
}
bootRun {
classpath = sourceSets.main.runtimeClasspath + configurations.bootRunOnly
}
Background
We’ve got a project requiring FIPS compliant crypto, so, instead of having to wrangle java.secrity
files and the related JARs on each project, we created a base image that contains these depencencies.
However, we still need to be able to run the projects locally (not necessarially in FIPS mode), but we don’t want any conflicting JARs to end up in the final Immage.
If this were a WAR project we could use the providedRuntime
dependency scope, but that doesn’t exist for the executable JAR.
The above change makes a custom scope, and we use that for the bootRun
Gradle task.