Signature (Gradle API 2.14.1)

org.gradle.plugins.signing

## Class Signature

- java.lang.Object
- - org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact
  - - org.gradle.plugins.signing.Signature

- All Implemented Interfaces:
    GroovyObject, PublishArtifact, Buildable

      public class Signature
      extends org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact
      implements GroovyObject

  A digital signature file artifact.

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Signature(Closure<File> toSign, Closure<String> classifier, SignatureSpec signatureSpec, Object... tasks)` Creates a signature artifact for the file returned by the `toSign` closure.
    `Signature(File toSign, SignatureSpec signatureSpec, Object... tasks)` Creates a signature artifact for the given file.
    `Signature(File toSign, String classifier, SignatureSpec signatureSpec, Object... tasks)` Creates a signature artifact for the given file, with the given classifier.
    `Signature(PublishArtifact toSign, SignatureSpec signatureSpec, Object... tasks)` Creates a signature artifact for the given public artifact.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `generate()` Generates the signature file.
    `String` | `getClassifier()` The classifier of the signature artifact.
    `Date` | `getDate()` The date of the signature artifact.
    `String` | `getExtension()` The extension of the signature artifact.
    `File` | `getFile()` The file for the generated signature, which may not yet exist.
    `MetaClass` | `getMetaClass()`
    `String` | `getName()` The name of the signature artifact.
    `Object` | `getProperty(String property)`
    `Signatory` | `getSignatory()` The signatory of this signature file.
    `SignatureSpec` | `getSignatureSpec()`
    `SignatureType` | `getSignatureType()` The file representation type of the signature.
    `File` | `getToSign()` The file that is to be signed.
    `PublishArtifact` | `getToSignArtifact()`
    `String` | `getType()` The type of the signature artifact.
    `Object` | `invokeMethod(String name, Object args)`
    `void` | `setClassifier(String classifier)`
    `void` | `setDate(Date date)`
    `void` | `setExtension(String extension)`
    `void` | `setFile(File file)`
    `void` | `setMetaClass(MetaClass metaClass)`
    `void` | `setName(String name)`
    `void` | `setProperty(String property, Object newValue)`
    `void` | `setSignatureSpec(SignatureSpec signatureSpec)`
    `void` | `setType(String type)`

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

      `builtBy, getBuildDependencies, toString`

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### Signature

          public Signature(PublishArtifact toSign,
                   SignatureSpec signatureSpec,
                   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(File toSign,
                   SignatureSpec signatureSpec,
                   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(File toSign,
                   String classifier,
                   SignatureSpec signatureSpec,
                   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<File> toSign,
                   Closure<String> classifier,
                   SignatureSpec signatureSpec,
                   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

    - #### getProperty

          public Object getProperty(String property)

      Specified by:
        `getProperty` in interface `GroovyObject`

    - #### setProperty

          public void setProperty(String property,
                         Object newValue)

      Specified by:
        `setProperty` in interface `GroovyObject`

    - #### invokeMethod

          public Object invokeMethod(String name,
                            Object args)

      Specified by:
        `invokeMethod` in interface `GroovyObject`

    - #### getMetaClass

          public MetaClass getMetaClass()

      Specified by:
        `getMetaClass` in interface `GroovyObject`

    - #### setMetaClass

          public void setMetaClass(MetaClass metaClass)

      Specified by:
        `setMetaClass` in interface `GroovyObject`

    - #### getToSign

          public File getToSign()

      The file that is to be signed.
      Returns:
        The file. May be `null` if unknown at this time.

    - #### setName

          public void setName(String name)

    - #### getName

          public String getName()

      The name of the signature artifact.

      Defaults to the name of the signature `file`.

      Specified by:
        `getName` in interface `PublishArtifact`
      Returns:
        The name. May be `null` if unknown at this time.

    - #### setExtension

          public void setExtension(String extension)

    - #### getExtension

          public String getExtension()

      The extension of the signature artifact.

      Defaults to the specified file extension of the `signature type`.

      Specified by:
        `getExtension` in interface `PublishArtifact`
      Returns:
        The extension. May be `null` if unknown at this time.

    - #### setType

          public void setType(String type)

    - #### getType

          public 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’.

      Specified by:
        `getType` in interface `PublishArtifact`
      Returns:
        The type. May be `null` if the file to sign or signature type are unknown at this time.

    - #### setClassifier

          public void setClassifier(String classifier)

    - #### getClassifier

          public 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).

      Specified by:
        `getClassifier` in interface `PublishArtifact`
      Returns:
        The classifier. May be `null` if unknown at this time.

    - #### setDate

          public void setDate(Date date)

    - #### getDate

          public Date getDate()

      The date of the signature artifact.

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

      Specified by:
        `getDate` in interface `PublishArtifact`
      Returns:
        The date of the signature. May be `null` if unknown at this time.

    - #### setFile

          public void setFile(File file)

    - #### getFile

          public File getFile()

      The file for the generated signature, which may not yet exist.

      Defaults to a file alongside the `file to sign` with the extension of the `signature type`.

      Specified by:
        `getFile` in interface `PublishArtifact`
      Returns:
        The signature file. May be `null` if unknown at this time.

    - #### getSignatory

          public Signatory getSignatory()

      The signatory of this signature file.
      Returns:
        The signatory. May be `null` if unknown at this time.

    - #### getSignatureType

          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)

    - #### getSignatureSpec

          public SignatureSpec getSignatureSpec()

    - #### getToSignArtifact

          public final PublishArtifact getToSignArtifact()

    - #### 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.