use of org.gradle.internal.component.local.model.DefaultProjectComponentSelector in project gradle by gradle.
the class ComponentSelectorSerializer method read.
@Override
public ComponentSelector read(Decoder decoder) throws IOException {
byte id = decoder.readByte();
if (Implementation.ROOT_PROJECT.getId() == id) {
BuildIdentifier buildIdentifier = buildIdentifierSerializer.read(decoder);
String projectName = decoder.readString();
return new DefaultProjectComponentSelector(buildIdentifier, Path.ROOT, Path.ROOT, projectName, readAttributes(decoder), readCapabilities(decoder));
} else if (Implementation.ROOT_BUILD_PROJECT.getId() == id) {
BuildIdentifier buildIdentifier = buildIdentifierSerializer.read(decoder);
Path projectPath = Path.path(decoder.readString());
return new DefaultProjectComponentSelector(buildIdentifier, projectPath, projectPath, projectPath.getName(), readAttributes(decoder), readCapabilities(decoder));
} else if (Implementation.OTHER_BUILD_ROOT_PROJECT.getId() == id) {
BuildIdentifier buildIdentifier = buildIdentifierSerializer.read(decoder);
Path identityPath = Path.path(decoder.readString());
return new DefaultProjectComponentSelector(buildIdentifier, identityPath, Path.ROOT, identityPath.getName(), readAttributes(decoder), readCapabilities(decoder));
} else if (Implementation.OTHER_BUILD_PROJECT.getId() == id) {
BuildIdentifier buildIdentifier = buildIdentifierSerializer.read(decoder);
Path identityPath = Path.path(decoder.readString());
Path projectPath = Path.path(decoder.readString());
return new DefaultProjectComponentSelector(buildIdentifier, identityPath, projectPath, projectPath.getName(), readAttributes(decoder), readCapabilities(decoder));
} else if (Implementation.MODULE.getId() == id) {
return DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(decoder.readString(), decoder.readString()), readVersionConstraint(decoder), readAttributes(decoder), readCapabilities(decoder));
} else if (Implementation.LIBRARY.getId() == id) {
return new DefaultLibraryComponentSelector(decoder.readString(), decoder.readNullableString(), decoder.readNullableString());
}
throw new IllegalArgumentException("Unable to find component selector with id: " + id);
}
use of org.gradle.internal.component.local.model.DefaultProjectComponentSelector in project gradle by gradle.
the class ComponentSelectorSerializer method write.
@Override
public void write(Encoder encoder, ComponentSelector value) throws IOException {
if (value == null) {
throw new IllegalArgumentException("Provided component selector may not be null");
}
Implementation implementation = resolveImplementation(value);
encoder.writeByte(implementation.getId());
if (implementation == Implementation.MODULE) {
ModuleComponentSelector moduleComponentSelector = (ModuleComponentSelector) value;
encoder.writeString(moduleComponentSelector.getGroup());
encoder.writeString(moduleComponentSelector.getModule());
VersionConstraint versionConstraint = moduleComponentSelector.getVersionConstraint();
writeVersionConstraint(encoder, versionConstraint);
writeAttributes(encoder, moduleComponentSelector.getAttributes());
writeCapabilities(encoder, moduleComponentSelector.getRequestedCapabilities());
} else if (implementation == Implementation.ROOT_PROJECT) {
DefaultProjectComponentSelector projectComponentSelector = (DefaultProjectComponentSelector) value;
buildIdentifierSerializer.write(encoder, projectComponentSelector.getBuildIdentifier());
encoder.writeString(projectComponentSelector.getProjectName());
writeAttributes(encoder, projectComponentSelector.getAttributes());
writeCapabilities(encoder, projectComponentSelector.getRequestedCapabilities());
} else if (implementation == Implementation.ROOT_BUILD_PROJECT) {
DefaultProjectComponentSelector projectComponentSelector = (DefaultProjectComponentSelector) value;
buildIdentifierSerializer.write(encoder, projectComponentSelector.getBuildIdentifier());
encoder.writeString(projectComponentSelector.getProjectPath());
writeAttributes(encoder, projectComponentSelector.getAttributes());
writeCapabilities(encoder, projectComponentSelector.getRequestedCapabilities());
} else if (implementation == Implementation.OTHER_BUILD_ROOT_PROJECT) {
DefaultProjectComponentSelector projectComponentSelector = (DefaultProjectComponentSelector) value;
buildIdentifierSerializer.write(encoder, projectComponentSelector.getBuildIdentifier());
encoder.writeString(projectComponentSelector.getIdentityPath().getPath());
writeAttributes(encoder, projectComponentSelector.getAttributes());
writeCapabilities(encoder, projectComponentSelector.getRequestedCapabilities());
} else if (implementation == Implementation.OTHER_BUILD_PROJECT) {
DefaultProjectComponentSelector projectComponentSelector = (DefaultProjectComponentSelector) value;
buildIdentifierSerializer.write(encoder, projectComponentSelector.getBuildIdentifier());
encoder.writeString(projectComponentSelector.getIdentityPath().getPath());
encoder.writeString(projectComponentSelector.getProjectPath());
writeAttributes(encoder, projectComponentSelector.getAttributes());
writeCapabilities(encoder, projectComponentSelector.getRequestedCapabilities());
} else if (implementation == Implementation.LIBRARY) {
LibraryComponentSelector libraryComponentSelector = (LibraryComponentSelector) value;
encoder.writeString(libraryComponentSelector.getProjectPath());
encoder.writeNullableString(libraryComponentSelector.getLibraryName());
encoder.writeNullableString(libraryComponentSelector.getVariant());
} else {
throw new IllegalStateException("Unsupported implementation type: " + implementation);
}
}
use of org.gradle.internal.component.local.model.DefaultProjectComponentSelector in project gradle by gradle.
the class AttributeDesugaring method desugarSelector.
public ComponentSelector desugarSelector(ComponentSelector selector) {
if (selector instanceof ModuleComponentSelector) {
ModuleComponentSelector module = (ModuleComponentSelector) selector;
AttributeContainer moduleAttributes = module.getAttributes();
if (!moduleAttributes.isEmpty()) {
ImmutableAttributes attributes = ((AttributeContainerInternal) moduleAttributes).asImmutable();
return DefaultModuleComponentSelector.newSelector(module.getModuleIdentifier(), module.getVersionConstraint(), desugar(attributes), module.getRequestedCapabilities());
}
}
if (selector instanceof DefaultProjectComponentSelector) {
DefaultProjectComponentSelector project = (DefaultProjectComponentSelector) selector;
AttributeContainer projectAttributes = project.getAttributes();
if (!projectAttributes.isEmpty()) {
ImmutableAttributes attributes = ((AttributeContainerInternal) projectAttributes).asImmutable();
return new DefaultProjectComponentSelector(project.getBuildIdentifier(), project.getIdentityPath(), project.projectPath(), project.getProjectName(), desugar(attributes), project.getRequestedCapabilities());
}
}
return selector;
}
Aggregations