use of org.gradle.api.component.ComponentWithCoordinates 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();
}
}
Aggregations