When gradlew is packaged, System.getProperty cannot obtain the configuration

25 views Asked by At

When I use ./gradlew build -Dquarkus.package.type=uber-jar to create an executable package, an error will be reported and I cannot continue packaging.

class EncryptConfigInterceptor : ConfigSourceInterceptor {

    override fun getValue(context: ConfigSourceInterceptorContext, name: String): ConfigValue? {
        val key = System.getProperty("gs4k")
        val ePrefix = System.getProperty("gs4kp")
        if (key.isEmpty() || ePrefix.isEmpty()) {
            throw RuntimeException("key or prefix is null")
        }
        val config: ConfigValue? = context.proceed(name)
        return config?.value?.let { value ->
            if (value.startsWith(ePrefix)) {
                val encryptValue = value.removePrefix(ePrefix)
                val decryptedValue = SM4Utils.decryptCbc(key, encryptValue)
                config.withValue(decryptedValue)
            } else {
                config
            }
        } ?: config
    }
}

I use ./gradlew build -Dgs4k=xxx -Dgs4kp=xxx -Dquarkus.package.type=uber-jar to set system properties and package, System.getProperty cannot obtain the configuration,But I use environment variables, which can be obtained through System.getEnv. Now I use System.getProperty to report an error and cannot package it.

0

There are 0 answers