use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class JvmLocalLibraryMetaDataAdapter method createResolvedMetaData.
private DefaultLibraryLocalComponentMetadata createResolvedMetaData(BinarySpecInternal selectedBinary, String projectPath, EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage, EnumMap<UsageKind, List<PublishArtifact>> artifacts) {
final DefaultLibraryLocalComponentMetadata metadata = newResolvedLibraryMetadata(selectedBinary.getId(), toStringMap(dependenciesPerUsage), projectPath);
for (Map.Entry<UsageKind, List<PublishArtifact>> entry : artifacts.entrySet()) {
UsageKind usage = entry.getKey();
final List<PublishArtifact> publishArtifacts = entry.getValue();
metadata.addArtifacts(usage.getConfigurationName(), publishArtifacts);
metadata.addVariant(usage.getConfigurationName(), new OutgoingVariant() {
@Override
public DisplayName asDescribable() {
return Describables.of(metadata.getId());
}
@Override
public AttributeContainerInternal getAttributes() {
return ImmutableAttributes.EMPTY;
}
@Override
public Set<? extends PublishArtifact> getArtifacts() {
return new LinkedHashSet<PublishArtifact>(publishArtifacts);
}
@Override
public Set<? extends OutgoingVariant> getChildren() {
return ImmutableSet.of();
}
});
}
return metadata;
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class ModuleMetadataFileGenerator method writeArtifacts.
private void writeArtifacts(PublicationInternal publication, UsageContext variant, JsonWriter jsonWriter) throws IOException {
if (variant.getArtifacts().isEmpty()) {
return;
}
jsonWriter.name("files");
jsonWriter.beginArray();
for (PublishArtifact artifact : variant.getArtifacts()) {
writeArtifact(publication, artifact, jsonWriter);
}
jsonWriter.endArray();
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class JvmLocalLibraryMetaDataAdapter method addArtifact.
private static void addArtifact(UsageKind usage, Set<File> directories, EnumMap<UsageKind, List<PublishArtifact>> artifacts, JvmAssembly assembly) {
List<PublishArtifact> publishArtifacts = artifacts.get(usage);
for (File dir : directories) {
DefaultPublishArtifact publishArtifact = new DefaultPublishArtifact("assembly", "", "", "", new Date(dir.lastModified()), dir);
publishArtifact.builtBy(assembly);
publishArtifacts.add(publishArtifact);
}
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultIvyModulePublishMetadata method addArtifacts.
@Override
public void addArtifacts(String configuration, Iterable<? extends PublishArtifact> artifacts) {
for (PublishArtifact artifact : artifacts) {
DefaultIvyArtifactName ivyName = DefaultIvyArtifactName.forPublishArtifact(artifact);
DefaultIvyModuleArtifactPublishMetadata ivyArtifact = getOrCreate(ivyName);
ivyArtifact.setFile(artifact.getFile());
ivyArtifact.addConfiguration(configuration);
}
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultArtifactPomTest method pomWithMainArtifactAndMetadataArtifacts.
@Test
public void pomWithMainArtifactAndMetadataArtifacts() {
Artifact mainArtifact = createTestArtifact("someName", null, "mainPackaging");
File mainFile = new File("someFile");
File metadataFile = new File("someMetadataFile");
Artifact metadataArtifact = createTestArtifact("otherName", null, "sometype");
artifactPom.addArtifact(mainArtifact, mainFile);
artifactPom.addArtifact(metadataArtifact, metadataFile);
assertThat(artifactPom.getArtifact().getName(), equalTo("someName"));
assertThat(artifactPom.getArtifact().getExtension(), equalTo("mainPackaging"));
assertThat(artifactPom.getArtifact().getType(), equalTo("mainPackaging"));
assertThat(artifactPom.getArtifact().getClassifier(), nullValue());
assertThat(artifactPom.getArtifact().getFile(), equalTo(mainFile));
PublishArtifact artifact = singleItem(artifactPom.getAttachedArtifacts());
assertThat(artifact.getName(), equalTo("someName"));
assertThat(artifact.getExtension(), equalTo("sometype"));
assertThat(artifact.getType(), equalTo("sometype"));
assertThat(artifact.getClassifier(), nullValue());
assertThat(artifact.getFile(), equalTo(metadataFile));
assertThat(artifactPom.getPom().getGroupId(), equalTo("org"));
assertThat(artifactPom.getPom().getArtifactId(), equalTo("someName"));
assertThat(artifactPom.getPom().getVersion(), equalTo("1.0"));
assertThat(artifactPom.getPom().getPackaging(), equalTo("mainPackaging"));
}
Aggregations