Class OnePasswordGradlePropertiesPlugin
java.lang.Object
io.github.arve0.onepassword.properties.OnePasswordGradlePropertiesPlugin
- All Implemented Interfaces:
org.gradle.api.Plugin<org.gradle.api.Project>
public final class OnePasswordGradlePropertiesPlugin
extends Object
implements org.gradle.api.Plugin<org.gradle.api.Project>
A Gradle plugin that resolves
op:// project properties via the 1Password CLI and
exposes them as lazy Provider<String> extra properties.
At plugin init, every project property whose value starts with op:// is registered
as a lazy Provider<String> in extra properties.
Plain string properties are left unchanged. The onePassword extension is then
registered to give build scripts a typed API for accessing any property as a provider.
Usage, build.gradle.kts:
plugins {
id("io.github.arve0.onepassword.properties")
}
tasks.register("printSecret") {
val secret: Provider<String> = onePassword.property("MY_SECRET")
doLast {
println("Secret is: ${secret.get()}")
}
}
Configuration Cache
Whether the secret ends up in the configuration cache depends on when the caller calls
.get() on the provider:
- Execution time (e.g. inside
doLast): secret is NOT stored in the cache;opis called once per build at execution time. - Configuration time (e.g. for repository credentials): Gradle fingerprints
the value and stores it in the cache;
opis called on every build for fingerprint validation.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
OnePasswordGradlePropertiesPlugin
public OnePasswordGradlePropertiesPlugin()
-
-
Method Details
-
apply
public void apply(org.gradle.api.Project project) - Specified by:
applyin interfaceorg.gradle.api.Plugin<org.gradle.api.Project>
-