Class Signature

  • All Implemented Interfaces:
    PublishArtifact, Buildable, org.gradle.api.internal.artifacts.PublishArtifactInternal

    public class Signature
    extends org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact
    A digital signature file artifact.

    A signature file is always generated from another file, which may be a PublishArtifact.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Signature.Generator
      Configuration-cache compatible signature generator.
    • Constructor Summary

      Constructors 
      Constructor Description
      Signature​(Closure<java.io.File> toSign, Closure<java.lang.String> classifier, SignatureSpec signatureSpec, java.lang.Object... tasks)
      Creates a signature artifact for the file returned by the toSign closure.
      Signature​(java.io.File toSign, java.lang.String classifier, SignatureSpec signatureSpec, java.lang.Object... tasks)
      Creates a signature artifact for the given file, with the given classifier.
      Signature​(java.io.File toSign, SignatureSpec signatureSpec, java.lang.Object... tasks)
      Creates a signature artifact for the given file.
      Signature​(java.util.concurrent.Callable<java.io.File> toSign, java.util.concurrent.Callable<java.lang.String> classifier, SignatureSpec signatureSpec, java.lang.Object... tasks)
      Creates a signature artifact for the file returned by the toSign closure.
      Signature​(PublishArtifact toSign, SignatureSpec signatureSpec, java.lang.Object... tasks)
      Creates a signature artifact for the given public artifact.
    • Constructor Detail

      • Signature

        public Signature​(PublishArtifact toSign,
                         SignatureSpec signatureSpec,
                         java.lang.Object... tasks)
        Creates a signature artifact for the given public artifact.

        The file to sign will be the file of the given artifact and the classifier of this signature artifact will default to the classifier of the given artifact to sign.

        The artifact to sign may change after being used as the source for this signature.

        Parameters:
        toSign - The artifact that is to be signed
        signatureSpec - The specification of how the artifact is to be signed
        tasks - The task(s) that will invoke generate() on this signature (optional)
      • Signature

        public Signature​(java.io.File toSign,
                         SignatureSpec signatureSpec,
                         java.lang.Object... tasks)
        Creates a signature artifact for the given file.
        Parameters:
        toSign - The file that is to be signed
        signatureSpec - The specification of how the artifact is to be signed
        tasks - The task(s) that will invoke generate() on this signature (optional)
      • Signature

        public Signature​(java.io.File toSign,
                         java.lang.String classifier,
                         SignatureSpec signatureSpec,
                         java.lang.Object... tasks)
        Creates a signature artifact for the given file, with the given classifier.
        Parameters:
        toSign - The file that is to be signed
        classifier - The classifier to assign to the signature (should match the files)
        signatureSpec - The specification of how the artifact is to be signed
        tasks - The task(s) that will invoke generate() on this signature (optional)
      • Signature

        public Signature​(Closure<java.io.File> toSign,
                         Closure<java.lang.String> classifier,
                         SignatureSpec signatureSpec,
                         java.lang.Object... tasks)
        Creates a signature artifact for the file returned by the toSign closure.

        The closures will be “evaluated” on demand whenever the value is needed (e.g. at generation time)

        Parameters:
        toSign - A closure that produces a File for the object to sign (non File return values will be used as the path to the file)
        classifier - A closure that produces the classifier to assign to the signature artifact on demand
        signatureSpec - The specification of how the artifact is to be signed
        tasks - The task(s) that will invoke generate() on this signature (optional)
      • Signature

        public Signature​(java.util.concurrent.Callable<java.io.File> toSign,
                         java.util.concurrent.Callable<java.lang.String> classifier,
                         SignatureSpec signatureSpec,
                         java.lang.Object... tasks)
        Creates a signature artifact for the file returned by the toSign closure.

        The closures will be “evaluated” on demand whenever the value is needed (e.g. at generation time)

        Parameters:
        toSign - A closure that produces a File for the object to sign (non File return values will be used as the path to the file)
        classifier - A closure that produces the classifier to assign to the signature artifact on demand
        signatureSpec - The specification of how the artifact is to be signed
        tasks - The task(s) that will invoke generate() on this signature (optional)
    • Method Detail

      • getToSign

        @PathSensitive(NONE)
        @InputFile
        public java.io.File getToSign()
        The file that is to be signed.
        Returns:
        The file. May be null if unknown at this time.
      • setName

        public void setName​(java.lang.String name)
      • getName

        @Internal
        public java.lang.String getName()
        The name of the signature artifact.

        Defaults to the name of the signature file.

        Returns:
        The name. May be null if unknown at this time. FIXME Nullability consistency with superclass.
      • setExtension

        public void setExtension​(java.lang.String extension)
      • getExtension

        @Internal
        public java.lang.String getExtension()
        The extension of the signature artifact.

        Defaults to the specified file extension of the signature type.

        Returns:
        The extension. May be null if unknown at this time. FIXME Nullability consistency with superclass.
      • setType

        public void setType​(java.lang.String type)
      • getType

        @Internal
        public java.lang.String getType()
        The type of the signature artifact.

        Defaults to the extension of the file to sign plus the extension of the signature type. For example, when signing the file ‘my.zip’ with a signature type with extension ‘sig’, the default type is ‘zip.sig’.

        Returns:
        The type. May be null if the file to sign or signature type are unknown at this time. FIXME Nullability consistency with superclass.
      • setClassifier

        public void setClassifier​(java.lang.String classifier)
      • getClassifier

        @Internal
        public java.lang.String getClassifier()
        The classifier of the signature artifact.

        Defaults to the classifier of the source artifact (if signing an artifact) or the given classifier at construction (if given).

        Returns:
        The classifier. May be null if unknown at this time.
      • setDate

        public void setDate​(java.util.Date date)
      • getDate

        @Internal
        public java.util.Date getDate()
        The date of the signature artifact.

        Defaults to the last modified time of the signature file (if exists)

        Returns:
        The date of the signature. May be null if unknown at this time.
      • getSignatory

        @Internal("already tracked as part of the Sign task")
        public Signatory getSignatory()
        The signatory of this signature file.
        Returns:
        The signatory. May be null if unknown at this time.
      • getSignatureType

        @Internal("already tracked as part of the Sign task")
        public SignatureType getSignatureType()
        The file representation type of the signature.
        Returns:
        The signature type. May be null if unknown at this time.
      • setSignatureSpec

        public void setSignatureSpec​(SignatureSpec signatureSpec)
      • getBuildDependencies

        @Internal
        public TaskDependency getBuildDependencies()
        Description copied from interface: Buildable
        Returns a dependency which contains the tasks which build this artifact. All Buildable implementations must ensure that the returned dependency object is live, so that it tracks changes to the dependencies of this buildable.
        Specified by:
        getBuildDependencies in interface Buildable
        Overrides:
        getBuildDependencies in class org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact
        Returns:
        The dependency. Never returns null. Returns an empty dependency when this artifact is not built by any tasks.
      • shouldBePublished

        public boolean shouldBePublished()