# Class Signature

java.lang.Object
org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact
org.gradle.plugins.signing.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`.

Since:
  1.0

- ## 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<File> toSign, Closure<String> classifier, SignatureSpec signatureSpec, Object... tasks)`
  Deprecated.
  This constructor will be deprecated in Gradle 10.
  `Signature(File toSign, String classifier, SignatureSpec signatureSpec, Object... tasks)`
  Deprecated.
  This constructor will be deprecated in Gradle 10.
  `Signature(File toSign, SignatureSpec signatureSpec, Object... tasks)`
  Deprecated.
  This constructor will be deprecated in Gradle 10.
  `Signature(Callable<File> toSign, Callable<String> classifier, SignatureSpec signatureSpec, Object... tasks)`
  Deprecated.
  This constructor will be deprecated in Gradle 10.
  `Signature(PublishArtifact toSign, SignatureSpec signatureSpec, Object... tasks)`
  Deprecated.
  This constructor will be deprecated in Gradle 10.
  `Signature(Buildable source, Callable<File> toSign, Callable<String> classifier, Callable<String> name, SignatureSpec signatureSpec, Object... tasks)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact`
  `builtBy(Object... tasks)`
  Deprecated.
  This method will be removed in Gradle 10.
  `void`
  `generate()`
  Generates the signature file.
  `TaskDependency`
  `getBuildDependencies()`
  Deprecated.
  This method will be removed in Gradle 10.
  `String`
  `getClassifier()`
  Deprecated.
  This method will be removed in Gradle 10.
  `Date`
  `getDate()`
  Deprecated.
  This method will be removed in Gradle 10.
  `String`
  `getExtension()`
  Deprecated.
  This method will be removed in Gradle 10.
  `File`
  `getFile()`
  The file for the generated signature, which may not yet exist.
  `(package private) @Nullable Signature.Generator`
  `getGenerator()`
  `String`
  `getName()`
  Deprecated.
  This method will be removed in Gradle 10.
  `Signatory`
  `getSignatory()`
  The signatory of this signature file.
  `SignatureSpec`
  `getSignatureSpec()`
  Returns the signature spec.
  `SignatureType`
  `getSignatureType()`
  The file representation type of the signature.
  `(package private) Buildable`
  `getSource()`
  `File`
  `getToSign()`
  The file that is to be signed.
  `String`
  `getType()`
  Deprecated.
  This method will be removed in Gradle 10.
  `void`
  `setClassifier(String classifier)`
  Deprecated.
  This method will be removed in Gradle 10.
  `void`
  `setDate(Date date)`
  Deprecated.
  This method will be removed in Gradle 10.
  `void`
  `setExtension(String extension)`
  Deprecated.
  This method will be removed in Gradle 10.
  `void`
  `setName(String name)`
  Deprecated.
  This method will be removed in Gradle 10.
  `void`
  `setSignatureSpec(SignatureSpec signatureSpec)`
  Sets the signature spec.
  `void`
  `setType(String type)`
  Deprecated.
  This method will be removed in Gradle 10.
  `boolean`
  `shouldBePublished()`
  Deprecated.
  This method will be removed in Gradle 10.

  ### Methods inherited from class org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact

  `toString`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### Signature

    @Deprecated public Signature(PublishArtifact toSign, SignatureSpec signatureSpec, Object... tasks)
    Deprecated.
    This constructor will be deprecated in Gradle 10.
    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)
    Since:
      1.0

  - ### Signature

    Signature(Buildable source, Callable<File> toSign, Callable<String> classifier, Callable<String> name, SignatureSpec signatureSpec, Object... tasks)

  - ### Signature

    @Deprecated public Signature(File toSign, SignatureSpec signatureSpec, Object... tasks)
    Deprecated.
    This constructor will be deprecated in Gradle 10.
    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)
    Since:
      1.0

  - ### Signature

    @Deprecated public Signature(File toSign, String classifier, SignatureSpec signatureSpec, Object... tasks)
    Deprecated.
    This constructor will be deprecated in Gradle 10.
    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)
    Since:
      1.0

  - ### Signature

    @Deprecated public Signature(Closure<File> toSign, Closure<String> classifier, SignatureSpec signatureSpec, Object... tasks)
    Deprecated.
    This constructor will be deprecated in Gradle 10.
    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)
    Since:
      1.0

  - ### Signature

    @Deprecated public Signature(Callable<File> toSign, Callable<String> classifier, SignatureSpec signatureSpec, Object... tasks)
    Deprecated.
    This constructor will be deprecated in Gradle 10.
    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)
    Since:
      3.0

- ## Method Details

  - ### getToSign

    @PathSensitive(NONE) @InputFile public File getToSign()
    The file that is to be signed.
    Returns:
      The file. May be `null` if unknown at this time.
    Since:
      1.0

  - ### setName

    @Deprecated public void setName(String name)
    Deprecated.
    This method will be removed in Gradle 10.
    Set the name returned by `getName()`.
    Since:
      1.0

  - ### getName

    @Internal @Deprecated public String getName()
    Deprecated.
    This method will be removed in Gradle 10.
    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.

  - ### setExtension

    @Deprecated public void setExtension(String extension)
    Deprecated.
    This method will be removed in Gradle 10.
    Set the extension returned by `getExtension()`.
    Since:
      1.0

  - ### getExtension

    @Internal @Deprecated public String getExtension()
    Deprecated.
    This method will be removed in Gradle 10.
    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.

  - ### setType

    @Deprecated public void setType(String type)
    Deprecated.
    This method will be removed in Gradle 10.
    Set the type returned by `getType()`.
    Since:
      1.0

  - ### getType

    @Internal @Deprecated public String getType()
    Deprecated.
    This method will be removed in Gradle 10.
    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.

  - ### setClassifier

    @Deprecated public void setClassifier(String classifier)
    Deprecated.
    This method will be removed in Gradle 10.
    Set the classifier returned by `getClassifier()`.
    Since:
      1.0

  - ### getClassifier

    @Internal @Deprecated public String getClassifier()
    Deprecated.
    This method will be removed in Gradle 10.
    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

    @Deprecated public void setDate(Date date)
    Deprecated.
    This method will be removed in Gradle 10.
    Set the date returned by `getDate()`.
    Since:
      1.0

  - ### getDate

    @Internal @Deprecated public Date getDate()
    Deprecated.
    This method will be removed in Gradle 10.
    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.

  - ### getFile

    @OutputFile public File getFile()
    The file for the generated signature, which may not yet exist.

    The file will be placed alongside the `file to sign` with the extension of the `signature type`.

    Returns:
      The signature file. May be `null` if unknown at this time.
    See Also:
      - FIXME Nullability consistency with superclass.

  - ### 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.
    Since:
      1.0

  - ### 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.
    Since:
      1.0

  - ### setSignatureSpec

    public void setSignatureSpec(SignatureSpec signatureSpec)
    Sets the signature spec.
    Since:
      1.0

  - ### getSignatureSpec

    @Internal public SignatureSpec getSignatureSpec()
    Returns the signature spec.
    Since:
      1.0

  - ### getSource

    @Internal Buildable getSource()

  - ### getBuildDependencies

    @Internal @Deprecated public TaskDependency getBuildDependencies()
    Deprecated.
    This method will be removed in Gradle 10.
    Get the build dependencies of this signature.
    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.

  - ### builtBy

    @Deprecated public org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact builtBy(Object... tasks)
    Deprecated.
    This method will be removed in Gradle 10.
    Add build dependencies to this signature.
    Overrides:
      `builtBy` in class `org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact`

  - ### shouldBePublished

    @Deprecated public boolean shouldBePublished()
    Deprecated.
    This method will be removed in Gradle 10.
    Return if this signature should be published.

  - ### generate

    public void generate()
    Generates the signature file.

    In order to generate the signature, the `file to sign`, `signatory` and `signature type` must be known (i.e. non `null`).

    Throws:
      `InvalidUserDataException` - if the there is insufficient information available to generate the signature.
    Since:
      1.0

  - ### getGenerator

    @Nullable Signature.Generator getGenerator()