Class ArtifactMetadataTransform

java.lang.Object
com.konfigyr.gradle.ArtifactMetadataTransform
All Implemented Interfaces:
org.gradle.api.artifacts.transform.TransformAction<com.konfigyr.gradle.ArtifactMetadataTransform.Parameters>

@NullMarked public abstract class ArtifactMetadataTransform extends Object implements org.gradle.api.artifacts.transform.TransformAction<com.konfigyr.gradle.ArtifactMetadataTransform.Parameters>
A Gradle TransformAction that processes each JAR on the runtimeClasspath and produces a self-describing output file containing the PropertyDescriptor metadata. This transform action would create a custom ClassLoader using the current artifact and its dependencies to resolve the Spring Boot configuration metadata files and generate the property descriptors.

The resulting artifacts can be looked up using a custom ArtifactView where the artifactType is set to konfigyr-metadata. Artifacts that do not contain Spring Boot configuration metadata would not be included in the view.

The transform is annotated CacheableTransform. Gradle will cache the output directory keyed on the JAR's content hash. A JAR that has not changed between builds will never be re-processed; the cached output directory is reused directly, making incremental builds extremely fast.

Since:
1.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.provider.Provider<org.gradle.api.file.FileSystemLocation>
    The location of the artifact file being transformed.
    abstract org.gradle.api.file.FileCollection
    The file collection containing the dependencies of the artifact being transformed.
    void
    transform(org.gradle.api.artifacts.transform.TransformOutputs outputs)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.artifacts.transform.TransformAction

    getParameters
  • Constructor Details

    • ArtifactMetadataTransform

      public ArtifactMetadataTransform()
  • Method Details

    • getArtifact

      @InputArtifact @CompileClasspath public abstract org.gradle.api.provider.Provider<org.gradle.api.file.FileSystemLocation> getArtifact()
      The location of the artifact file being transformed.

      @Classpath annotation here tells Gradle to derive the cache key from the artifacts content hash rather than its path. This is essential for correctness in reproducible and relocatable builds.

      Returns:
      the artifact file, never null.
    • getDependencies

      @CompileClasspath @InputArtifactDependencies public abstract org.gradle.api.file.FileCollection getDependencies()
      The file collection containing the dependencies of the artifact being transformed.

      This collection is used to create a custom ClassLoader that can resolve the Java types from the Spring Boot configuration metadata files to resolve the JsonSchema for each property.

      Returns:
      the dependencies of the artifact, never null.
    • transform

      public void transform(org.gradle.api.artifacts.transform.TransformOutputs outputs)
      Specified by:
      transform in interface org.gradle.api.artifacts.transform.TransformAction<com.konfigyr.gradle.ArtifactMetadataTransform.Parameters>