use of org.gradle.plugins.signing.type.SignatureType in project gradle by gradle.
the class Signature method getFile.
/**
* The file for the generated signature, which may not yet exist.
*
* <p>The file will be placed alongside the {@link #getToSign() file to sign} with the extension of the {@link #getSignatureType() signature type}.
*
* @return The signature file. May be {@code null} if unknown at this time.
* @see SignatureType#fileFor(File)
*/
@Override
@OutputFile
public File getFile() {
File toSign = getToSign();
SignatureType signatureType = getSignatureType();
return toSign != null && signatureType != null ? signatureType.fileFor(toSign) : null;
}
use of org.gradle.plugins.signing.type.SignatureType in project gradle by gradle.
the class Signature method generate.
/**
* Generates the signature file.
*
* <p>In order to generate the signature, the {@link #getToSign() file to sign}, {@link #getSignatory() signatory} and {@link #getSignatureType() signature type} must be known (i.e. non {@code
* null}).</p>
*
* @throws InvalidUserDataException if the there is insufficient information available to generate the signature.
*/
public void generate() {
File toSign = getToSign();
if (toSign == null) {
if (signatureSpec.isRequired()) {
throw new InvalidUserDataException("Unable to generate signature as the file to sign has not been specified");
} else {
return;
}
}
Signatory signatory = getSignatory();
if (signatory == null) {
if (signatureSpec.isRequired()) {
throw new InvalidUserDataException("Unable to generate signature for \'" + toSign + "\' as no signatory is available to sign");
} else {
return;
}
}
SignatureType signatureType = getSignatureType();
if (signatureType == null) {
if (signatureSpec.isRequired()) {
throw new InvalidUserDataException("Unable to generate signature for \'" + toSign + "\' as no signature type has been configured");
} else {
return;
}
}
signatureType.sign(signatory, toSign);
}
use of org.gradle.plugins.signing.type.SignatureType in project gradle by gradle.
the class Signature method defaultFile.
@Nullable
private File defaultFile() {
File toSign = getToSign();
SignatureType signatureType = getSignatureType();
return toSign != null && signatureType != null ? signatureType.fileFor(toSign) : null;
}
use of org.gradle.plugins.signing.type.SignatureType in project gradle by gradle.
the class Signature method defaultType.
@Nullable
private String defaultType() {
File toSign = getToSign();
SignatureType signatureType = getSignatureType();
return toSign != null && signatureType != null ? signatureType.combinedExtension(toSign) : null;
}
use of org.gradle.plugins.signing.type.SignatureType in project gradle by gradle.
the class SigningExtension method addSignatureSpecConventions.
/**
* Adds conventions to the given spec, using this settings object's default signatory and signature type as the default signatory and signature type for the spec.
*/
protected void addSignatureSpecConventions(SignatureSpec spec) {
if (!(spec instanceof IConventionAware)) {
throw new InvalidUserDataException("Cannot add conventions to signature spec \'" + String.valueOf(spec) + "\' as it is not convention aware");
}
ConventionMapping conventionMapping = ((IConventionAware) spec).getConventionMapping();
conventionMapping.map("signatory", new Callable<Signatory>() {
@Override
public Signatory call() {
return getSignatory();
}
});
conventionMapping.map("signatureType", new Callable<SignatureType>() {
@Override
public SignatureType call() {
return getSignatureType();
}
});
conventionMapping.map("required", new Callable<Boolean>() {
@Override
public Boolean call() {
return isRequired();
}
});
}
Aggregations