private final String typeName;
private final DomainObjectSet<BinarySpec> binaries = new DefaultDomainObjectSet<BinarySpec>(BinarySpec.class);
public static <T extends BaseComponentSpec> T create(Class<T> type, ComponentSpecIdentifier identifier, FunctionalSourceSet mainSourceSet, Instantiator instantiator) {
if (type.equals(BaseComponentSpec.class)) {
throw new ModelInstantiationException("Cannot create instance of abstract class BaseComponentSpec.");
}
nextComponentInfo.set(new ComponentInfo(identifier, type.getSimpleName(), mainSourceSet));
try {
try {
return instantiator.newInstance(type);
} catch (ObjectInstantiationException e) {
throw new ModelInstantiationException(String.format("Could not create component of type %s", type.getSimpleName()), e.getCause());
}
} finally {
nextComponentInfo.set(null);
}
}