use of org.gradle.api.publish.Publication in project spring-security by spring-projects.
the class SpringSigningPlugin method sign.
private void sign(Project project) {
SigningExtension signing = project.getExtensions().findByType(SigningExtension.class);
signing.setRequired(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return project.getGradle().getTaskGraph().hasTask("publishArtifacts");
}
});
String signingKeyId = (String) project.findProperty("signingKeyId");
String signingKey = (String) project.findProperty("signingKey");
String signingPassword = (String) project.findProperty("signingPassword");
if (signingKeyId != null) {
signing.useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword);
} else {
signing.useInMemoryPgpKeys(signingKey, signingPassword);
}
project.getPlugins().withType(PublishAllJavaComponentsPlugin.class).all(new Action<PublishAllJavaComponentsPlugin>() {
@Override
public void execute(PublishAllJavaComponentsPlugin publishingPlugin) {
PublishingExtension publishing = project.getExtensions().findByType(PublishingExtension.class);
Publication maven = publishing.getPublications().getByName("mavenJava");
signing.sign(maven);
}
});
}
use of org.gradle.api.publish.Publication in project gradle by gradle.
the class Sign method sign.
/**
* Configures the task to sign every artifact of the given publications
*
* @since 4.8
*/
public void sign(Publication... publications) {
for (Publication publication : publications) {
PublicationInternal<?> publicationInternal = (PublicationInternal<?>) publication;
dependsOn((Callable<Set<? extends PublicationArtifact>>) () -> {
return publicationInternal.getPublishableArtifacts().matching(this::isNoSignatureArtifact);
});
publicationInternal.allPublishableArtifacts(artifact -> {
if (isNoSignatureArtifact(artifact)) {
addSignature(new Signature(artifact, artifact::getFile, null, null, this, this));
}
});
publicationInternal.whenPublishableArtifactRemoved(this::removeSignature);
}
}
Aggregations