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 exposes 1Password secret references as lazy Provider<String> properties. 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; op is called once per build at execution time.
  • Configuration time (e.g. for repository credentials): Gradle fingerprints the value and stores it in the cache; op is called on every build for fingerprint validation.
  • Constructor Details

    • OnePasswordGradlePropertiesPlugin

      public OnePasswordGradlePropertiesPlugin()
  • Method Details

    • apply

      public void apply(org.gradle.api.Project project)
      Specified by:
      apply in interface org.gradle.api.Plugin<org.gradle.api.Project>