use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultArtifactPomTest method writePom.
@Test
public void writePom() {
final MavenPom mavenPomMock = context.mock(MavenPom.class);
DefaultArtifactPom artifactPom = new DefaultArtifactPom(mavenPomMock);
final File somePomFile = new File(tmpDir.getTestDirectory(), "someDir/somePath");
context.checking(new Expectations() {
{
allowing(mavenPomMock).getArtifactId();
will(returnValue("artifactId"));
oneOf(mavenPomMock).writeTo(with(any(FileOutputStream.class)));
}
});
PublishArtifact artifact = artifactPom.writePom(somePomFile);
assertThat(artifact.getName(), equalTo("artifactId"));
assertThat(artifact.getType(), equalTo("pom"));
assertThat(artifact.getExtension(), equalTo("pom"));
assertThat(artifact.getClassifier(), nullValue());
assertThat(artifact.getFile(), equalTo(somePomFile));
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultArtifactPomTest method pomWithClassifierArtifactsOnly.
@Test
public void pomWithClassifierArtifactsOnly() {
File classifierFile = new File("someClassifierFile");
Artifact classifierArtifact = createTestArtifact("someName", "javadoc", "zip");
artifactPom.addArtifact(classifierArtifact, classifierFile);
assertThat(artifactPom.getArtifact(), nullValue());
PublishArtifact artifact = singleItem(artifactPom.getAttachedArtifacts());
assertThat(artifact.getName(), equalTo("someName"));
assertThat(artifact.getExtension(), equalTo("zip"));
assertThat(artifact.getType(), equalTo("zip"));
assertThat(artifact.getClassifier(), equalTo("javadoc"));
assertThat(artifact.getFile(), equalTo(classifierFile));
assertThat(artifactPom.getPom().getGroupId(), equalTo("org"));
assertThat(artifactPom.getPom().getArtifactId(), equalTo("someName"));
assertThat(artifactPom.getPom().getVersion(), equalTo("1.0"));
assertThat(artifactPom.getPom().getPackaging(), equalTo("jar"));
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultArtifactPublisher method addConfigurations.
private void addConfigurations(DefaultIvyModulePublishMetadata metaData, Collection<? extends ConfigurationInternal> configurations, boolean validateArtifacts) {
for (ConfigurationInternal configuration : configurations) {
BuildableLocalConfigurationMetadata configurationMetadata = addConfiguration(metaData, configuration);
dependenciesConverter.addDependenciesAndExcludes(configurationMetadata, configuration);
OutgoingVariant outgoingVariant = configuration.convertToOutgoingVariant();
for (PublishArtifact publishArtifact : outgoingVariant.getArtifacts()) {
if (!validateArtifacts || isValidToPublish(publishArtifact)) {
metaData.addArtifact(configuration.getName(), publishArtifact);
}
}
}
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultLocalComponentMetadata method addArtifacts.
@Override
public void addArtifacts(String configuration, Iterable<? extends PublishArtifact> artifacts) {
for (PublishArtifact artifact : artifacts) {
LocalComponentArtifactMetadata artifactMetadata = new PublishArtifactLocalArtifactMetadata(componentId, artifact);
allArtifacts.put(configuration, artifactMetadata);
}
}
use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.
the class DefaultLocalComponentMetadata method addVariant.
@Override
public void addVariant(String configuration, OutgoingVariant variant) {
List<LocalComponentArtifactMetadata> artifacts;
if (variant.getArtifacts().isEmpty()) {
artifacts = ImmutableList.of();
} else {
ImmutableList.Builder<LocalComponentArtifactMetadata> builder = ImmutableList.builder();
for (PublishArtifact artifact : variant.getArtifacts()) {
builder.add(new PublishArtifactLocalArtifactMetadata(componentId, artifact));
}
artifacts = builder.build();
}
allVariants.put(configuration, new DefaultVariantMetadata(variant.asDescribable(), variant.getAttributes().asImmutable(), artifacts, null));
}
Aggregations