use of org.gradle.api.publish.maven.MavenPublication in project build-info by JFrogDev.
the class TaskHelperPublications method getArtifactDeployDetails.
public Set<GradleDeployDetails> getArtifactDeployDetails() {
Set<GradleDeployDetails> deployDetails = Sets.newLinkedHashSet();
if (!hasPublications()) {
log.info("No publications to publish for project '{}'.", getProject().getPath());
return deployDetails;
}
for (IvyPublication ivyPublication : ivyPublications) {
String publicationName = ivyPublication.getName();
if (!(ivyPublication instanceof IvyPublicationInternal)) {
// TODO: Check how the descriptor file can be extracted without using asNormalisedPublication
log.warn("Ivy publication name '{}' is of unsupported type '{}'!", publicationName, ivyPublication.getClass());
continue;
}
IvyPublicationInternal ivyPublicationInternal = (IvyPublicationInternal) ivyPublication;
IvyNormalizedPublication ivyNormalizedPublication = ivyPublicationInternal.asNormalisedPublication();
IvyPublicationIdentity projectIdentity = ivyNormalizedPublication.getProjectIdentity();
Map<QName, String> extraInfo = ivyPublication.getDescriptor().getExtraInfo().asMap();
// First adding the Ivy descriptor (if the build is configured to add it):
if (isPublishIvy()) {
File file = getIvyDescriptorFile(ivyNormalizedPublication);
DeployDetails.Builder builder = createBuilder(file, publicationName);
if (builder != null) {
PublishArtifactInfo artifactInfo = new PublishArtifactInfo(projectIdentity.getModule(), "xml", "ivy", null, extraInfo, file);
addIvyArtifactToDeployDetails(deployDetails, publicationName, projectIdentity, builder, artifactInfo);
}
}
IvyArtifactSet artifacts = ivyPublication.getArtifacts();
for (IvyArtifact artifact : artifacts) {
File file = artifact.getFile();
DeployDetails.Builder builder = createBuilder(file, publicationName);
if (builder == null)
continue;
PublishArtifactInfo artifactInfo = new PublishArtifactInfo(artifact.getName(), artifact.getExtension(), artifact.getType(), artifact.getClassifier(), extraInfo, file);
addIvyArtifactToDeployDetails(deployDetails, publicationName, projectIdentity, builder, artifactInfo);
}
}
for (MavenPublication mavenPublication : mavenPublications) {
String publicationName = mavenPublication.getName();
if (!(mavenPublication instanceof MavenPublicationInternal)) {
// TODO: Check how the descriptor file can be extracted without using asNormalisedPublication
log.warn("Maven publication name '{}' is of unsupported type '{}'!", publicationName, mavenPublication.getClass());
continue;
}
MavenPublicationInternal mavenPublicationInternal = (MavenPublicationInternal) mavenPublication;
MavenNormalizedPublication mavenNormalizedPublication = mavenPublicationInternal.asNormalisedPublication();
MavenProjectIdentity projectIdentity = mavenNormalizedPublication.getProjectIdentity();
// First adding the Maven descriptor (if the build is configured to add it):
if (isPublishMaven()) {
File file = mavenNormalizedPublication.getPomFile();
DeployDetails.Builder builder = createBuilder(file, publicationName);
if (builder != null) {
PublishArtifactInfo artifactInfo = new PublishArtifactInfo(projectIdentity.getArtifactId(), "pom", "pom", null, file);
addMavenArtifactToDeployDetails(deployDetails, publicationName, projectIdentity, builder, artifactInfo);
}
}
MavenArtifactSet artifacts = mavenPublication.getArtifacts();
for (MavenArtifact artifact : artifacts) {
File file = artifact.getFile();
DeployDetails.Builder builder = createBuilder(file, publicationName);
if (builder == null)
continue;
PublishArtifactInfo artifactInfo = new PublishArtifactInfo(projectIdentity.getArtifactId(), artifact.getExtension(), artifact.getExtension(), artifact.getClassifier(), file);
addMavenArtifactToDeployDetails(deployDetails, publicationName, projectIdentity, builder, artifactInfo);
}
}
return deployDetails;
}
use of org.gradle.api.publish.maven.MavenPublication in project build-info by JFrogDev.
the class TaskHelperPublications method checkDependsOnArtifactsToPublish.
public void checkDependsOnArtifactsToPublish() {
// If no publications in the list
if (!hasPublications()) {
// If some were declared => Warning
if (publishPublicationsSpecified) {
log.warn("None of the specified publications matched for project '{}' - nothing to publish.", getProject().getPath());
} else {
log.debug("No publications specified for project '{}'", getProject().getPath());
}
return;
}
for (IvyPublication ivyPublication : ivyPublications) {
if (!(ivyPublication instanceof IvyPublicationInternal)) {
// TODO: Check how the output files can be extracted without using getPublishableFiles
log.warn("Ivy publication name '{}' is of unsupported type '{}'!", ivyPublication.getName(), ivyPublication.getClass());
continue;
}
dependsOn(((IvyPublicationInternal) ivyPublication).getPublishableFiles());
String capitalizedPublicationName = ivyPublication.getName().substring(0, 1).toUpperCase() + ivyPublication.getName().substring(1);
dependsOn(String.format("%s:generateDescriptorFileFor%sPublication", getProject().getPath(), capitalizedPublicationName));
}
for (MavenPublication mavenPublication : mavenPublications) {
if (!(mavenPublication instanceof MavenPublicationInternal)) {
// TODO: Check how the output files can be extracted without using getPublishableFiles
log.warn("Maven publication name '{}' is of unsupported type '{}'!", mavenPublication.getName(), mavenPublication.getClass());
continue;
}
dependsOn(((MavenPublicationInternal) mavenPublication).getPublishableFiles());
String capitalizedPublicationName = mavenPublication.getName().substring(0, 1).toUpperCase() + mavenPublication.getName().substring(1);
dependsOn(String.format("%s:generatePomFileFor%sPublication", getProject().getPath(), capitalizedPublicationName));
}
}
use of org.gradle.api.publish.maven.MavenPublication in project spring-security by spring-projects.
the class PublishAllJavaComponentsPlugin method apply.
@Override
public void apply(Project project) {
project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.getPublications().create("mavenJava", MavenPublication.class, new Action<MavenPublication>() {
@Override
public void execute(MavenPublication maven) {
project.getPlugins().withType(JavaPlugin.class, (plugin) -> {
maven.from(project.getComponents().getByName("java"));
});
project.getPlugins().withType(JavaPlatformPlugin.class, (plugin) -> {
maven.from(project.getComponents().getByName("javaPlatform"));
});
}
});
});
}
use of org.gradle.api.publish.maven.MavenPublication in project coffeenet-starter by coffeenet.
the class DeployedPlugin method apply.
@Override
public void apply(Project project) {
project.getPlugins().apply(MavenPublishPlugin.class);
// Create a new Maven publication
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class);
mavenPublication.suppressAllPomMetadataWarnings();
// Publish all Java artifacts and the platform BOMs
// J-
// @formatter:off
project.getPlugins().withType(JavaPlugin.class).all((plugin) -> project.getComponents().matching((component) -> component.getName().equals("java")).all(mavenPublication::from));
project.getPlugins().withType(JavaPlatformPlugin.class).all((plugin) -> project.getComponents().matching((component) -> component.getName().equals("javaPlatform")).all(mavenPublication::from));
if (project.hasProperty(SIGN_GPG_PROPERTY_NAME)) {
applyGpgSigning(project, mavenPublication);
}
// @formatter:on
// J+
}
use of org.gradle.api.publish.maven.MavenPublication in project spring-boot by spring-projects.
the class MavenPublishingConventions method apply.
void apply(Project project) {
project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
if (project.hasProperty("deploymentRepository")) {
publishing.getRepositories().maven((mavenRepository) -> {
mavenRepository.setUrl(project.property("deploymentRepository"));
mavenRepository.setName("deployment");
});
}
publishing.getPublications().withType(MavenPublication.class).all((mavenPublication) -> customizeMavenPublication(mavenPublication, project));
project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
extension.withJavadocJar();
extension.withSourcesJar();
});
});
}
Aggregations