use of org.gradle.api.component.SoftwareComponent in project gradle by gradle.
the class ModuleMetadataFileGenerator method writeVariants.
private void writeVariants(PublicationInternal publication, SoftwareComponent component, Map<SoftwareComponent, ComponentData> componentCoordinates, JsonWriter jsonWriter) throws IOException {
boolean started = false;
for (UsageContext usageContext : ((SoftwareComponentInternal) component).getUsages()) {
if (!started) {
jsonWriter.name("variants");
jsonWriter.beginArray();
started = true;
}
writeVariantHostedInThisModule(publication, usageContext, jsonWriter);
}
if (component instanceof ComponentWithVariants) {
for (SoftwareComponent childComponent : ((ComponentWithVariants) component).getVariants()) {
ModuleVersionIdentifier childCoordinates;
if (childComponent instanceof ComponentWithCoordinates) {
childCoordinates = ((ComponentWithCoordinates) childComponent).getCoordinates();
} else {
ComponentData componentData = componentCoordinates.get(childComponent);
childCoordinates = componentData == null ? null : componentData.coordinates;
}
assert childCoordinates != null;
if (childComponent instanceof SoftwareComponentInternal) {
for (UsageContext usageContext : ((SoftwareComponentInternal) childComponent).getUsages()) {
if (!started) {
jsonWriter.name("variants");
jsonWriter.beginArray();
started = true;
}
writeVariantHostedInAnotherModule(publication.getCoordinates(), childCoordinates, usageContext, jsonWriter);
}
}
}
}
if (started) {
jsonWriter.endArray();
}
}
use of org.gradle.api.component.SoftwareComponent in project shipkit by mockito.
the class AndroidPublishPlugin method apply.
public void apply(final Project project) {
final AndroidPublishConfiguration androidPublishConfiguration = project.getExtensions().create(ANDROID_PUBLISH_EXTENSION, AndroidPublishConfiguration.class);
final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
project.getPlugins().apply(LocalSnapshotPlugin.class);
Task snapshotTask = project.getTasks().getByName(LocalSnapshotPlugin.SNAPSHOT_TASK);
snapshotTask.dependsOn(MAVEN_LOCAL_TASK);
project.getPlugins().apply("maven-publish");
BintrayExtension bintray = project.getExtensions().getByType(BintrayExtension.class);
bintray.setPublications(PUBLICATION_NAME);
project.getPlugins().withId("com.android.library", plugin -> {
deferredConfiguration(project, () -> {
GradleDSLHelper.publications(project, publications -> {
MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, publication -> {
publication.setArtifactId(androidPublishConfiguration.getArtifactId());
SoftwareComponent releaseComponent = project.getComponents().findByName("release");
if (releaseComponent == null) {
throw new GradleException("'release' component not found in project. " + "Make sure you are using Android Gradle Plugin 3.6.0-beta05 or newer.");
}
publication.from(releaseComponent);
PomCustomizer.customizePom(project, conf, publication);
});
LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId());
});
});
// so that we flesh out problems with maven publication during the build process
project.getTasks().getByName("build").dependsOn(MAVEN_LOCAL_TASK);
});
}
Aggregations