use of org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal in project gradle by gradle.
the class IvyPluginPublishingRules method createIvyMarkerPublication.
private void createIvyMarkerPublication(PluginDeclaration declaration, final IvyPublication mainPublication, PublicationContainer publications) {
String pluginId = declaration.getId();
IvyPublicationInternal publication = (IvyPublicationInternal) publications.create(declaration.getName() + "PluginMarkerIvy", IvyPublication.class);
publication.setAlias(true);
publication.setOrganisation(pluginId);
publication.setModule(pluginId + PLUGIN_MARKER_SUFFIX);
publication.descriptor(new Action<IvyModuleDescriptorSpec>() {
@Override
public void execute(IvyModuleDescriptorSpec descriptor) {
descriptor.withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
Element root = xmlProvider.asElement();
Document document = root.getOwnerDocument();
Node dependencies = root.getElementsByTagName("dependencies").item(0);
Node dependency = dependencies.appendChild(document.createElement("dependency"));
Attr org = document.createAttribute("org");
org.setValue(mainPublication.getOrganisation());
dependency.getAttributes().setNamedItem(org);
Attr name = document.createAttribute("name");
name.setValue(mainPublication.getModule());
dependency.getAttributes().setNamedItem(name);
Attr rev = document.createAttribute("rev");
rev.setValue(mainPublication.getRevision());
dependency.getAttributes().setNamedItem(rev);
}
});
}
});
}
use of org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal 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.ivy.internal.publication.IvyPublicationInternal 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.ivy.internal.publication.IvyPublicationInternal in project gradle by gradle.
the class IvyPublishPlugin method createTasksLater.
private void createTasksLater(final Project project, final PublishingExtension publishingExtension, final DirectoryProperty buildDir) {
final TaskContainer tasks = project.getTasks();
final NamedDomainObjectSet<IvyPublicationInternal> publications = publishingExtension.getPublications().withType(IvyPublicationInternal.class);
final NamedDomainObjectList<IvyArtifactRepository> repositories = publishingExtension.getRepositories().withType(IvyArtifactRepository.class);
repositories.all(repository -> tasks.register(publishAllToSingleRepoTaskName(repository), publish -> {
publish.setDescription("Publishes all Ivy publications produced by this project to the " + repository.getName() + " repository.");
publish.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
}));
publications.all(publication -> {
final String publicationName = publication.getName();
createGenerateIvyDescriptorTask(tasks, publicationName, publication, buildDir);
createGenerateMetadataTask(tasks, publication, publications, buildDir, repositories);
createPublishTaskForEachRepository(tasks, publication, publicationName, repositories);
});
}
use of org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal in project gradle by gradle.
the class IvyPluginPublishingPlugin method createIvyMarkerPublication.
private void createIvyMarkerPublication(final PluginDeclaration declaration, final IvyPublication mainPublication, PublicationContainer publications) {
String pluginId = declaration.getId();
IvyPublicationInternal publication = (IvyPublicationInternal) publications.create(declaration.getName() + "PluginMarkerIvy", IvyPublication.class);
publication.setAlias(true);
publication.setOrganisation(pluginId);
publication.setModule(pluginId + PLUGIN_MARKER_SUFFIX);
publication.descriptor(new Action<IvyModuleDescriptorSpec>() {
@Override
public void execute(IvyModuleDescriptorSpec descriptor) {
descriptor.description(new Action<IvyModuleDescriptorDescription>() {
@Override
public void execute(IvyModuleDescriptorDescription description) {
description.getText().set(declaration.getDescription());
}
});
descriptor.withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
Element root = xmlProvider.asElement();
Document document = root.getOwnerDocument();
Node dependencies = root.getElementsByTagName("dependencies").item(0);
Node dependency = dependencies.appendChild(document.createElement("dependency"));
Attr org = document.createAttribute("org");
org.setValue(mainPublication.getOrganisation());
dependency.getAttributes().setNamedItem(org);
Attr name = document.createAttribute("name");
name.setValue(mainPublication.getModule());
dependency.getAttributes().setNamedItem(name);
Attr rev = document.createAttribute("rev");
rev.setValue(mainPublication.getRevision());
dependency.getAttributes().setNamedItem(rev);
}
});
}
});
}
Aggregations