use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.
the class ComponentIdentifierSerializer method write.
public void write(Encoder encoder, ComponentIdentifier value) throws IOException {
if (value == null) {
throw new IllegalArgumentException("Provided component identifier may not be null");
}
Implementation implementation = resolveImplementation(value);
encoder.writeByte(implementation.getId());
if (implementation == Implementation.MODULE) {
ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) value;
encoder.writeString(moduleComponentIdentifier.getGroup());
encoder.writeString(moduleComponentIdentifier.getModule());
encoder.writeString(moduleComponentIdentifier.getVersion());
} else if (implementation == Implementation.SNAPSHOT) {
MavenUniqueSnapshotComponentIdentifier snapshotIdentifier = (MavenUniqueSnapshotComponentIdentifier) value;
encoder.writeString(snapshotIdentifier.getGroup());
encoder.writeString(snapshotIdentifier.getModule());
encoder.writeString(snapshotIdentifier.getVersion());
encoder.writeString(snapshotIdentifier.getTimestamp());
} else if (implementation == Implementation.BUILD) {
ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) value;
BuildIdentifier build = projectComponentIdentifier.getBuild();
buildIdentifierSerializer.write(encoder, build);
encoder.writeString(projectComponentIdentifier.getProjectPath());
} else if (implementation == Implementation.LIBRARY) {
LibraryBinaryIdentifier libraryIdentifier = (LibraryBinaryIdentifier) value;
encoder.writeString(libraryIdentifier.getProjectPath());
encoder.writeString(libraryIdentifier.getLibraryName());
encoder.writeString(libraryIdentifier.getVariant());
} else {
throw new IllegalStateException("Unsupported implementation type: " + implementation);
}
}
use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.
the class ProjectDependencyResolver method resolve.
@Override
public void resolve(DependencyMetadata dependency, ResolvedVersionConstraint versionConstraint, BuildableComponentIdResolveResult result) {
if (dependency.getSelector() instanceof ProjectComponentSelector) {
ProjectComponentSelector selector = (ProjectComponentSelector) dependency.getSelector();
ProjectComponentIdentifier project = componentIdentifierFactory.createProjectComponentIdentifier(selector);
LocalComponentMetadata componentMetaData = localComponentRegistry.getComponent(project);
if (componentMetaData == null) {
result.failed(new ModuleVersionResolveException(selector, project + " not found."));
} else {
result.resolved(componentMetaData);
}
}
}
use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.
the class DefaultComponentSelectorConverter method getSelector.
@Override
public ModuleVersionSelector getSelector(ComponentSelector selector) {
if (selector instanceof ModuleComponentSelector) {
return DefaultModuleVersionSelector.newSelector((ModuleComponentSelector) selector);
}
if (selector instanceof ProjectComponentSelector) {
ProjectComponentSelector projectSelector = (ProjectComponentSelector) selector;
ProjectComponentIdentifier projectId = componentIdentifierFactory.createProjectComponentIdentifier(projectSelector);
LocalComponentMetadata projectComponent = localComponentRegistry.getComponent(projectId);
if (projectComponent != null) {
ModuleVersionIdentifier moduleVersionId = projectComponent.getModuleVersionId();
return DefaultModuleVersionSelector.newSelector(moduleVersionId.getGroup(), moduleVersionId.getName(), moduleVersionId.getVersion());
}
}
if (selector instanceof LibraryComponentSelector) {
LibraryComponentSelector libraryComponentSelector = (LibraryComponentSelector) selector;
String libraryName = GUtil.elvis(libraryComponentSelector.getLibraryName(), "");
return DefaultModuleVersionSelector.newSelector(libraryComponentSelector.getProjectPath(), libraryName, "undefined");
}
return UNKNOWN_MODULE_VERSION_SELECTOR;
}
use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.
the class DefaultIncludedBuildRegistry method registerProjects.
private void registerProjects(Path rootPath, BuildIdentifier buildIdentifier, Set<DefaultProjectDescriptor> allProjects, boolean isImplicitBuild) {
for (DefaultProjectDescriptor project : allProjects) {
Path projectIdentityPath = rootPath.append(project.path());
ProjectComponentIdentifier projectComponentIdentifier = DefaultProjectComponentIdentifier.newProjectId(buildIdentifier, project.getPath());
projectRegistry.add(projectIdentityPath, project.getName(), projectComponentIdentifier, isImplicitBuild);
}
}
use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.
the class IncludedBuildDependencyMetadataBuilder method registerProject.
private void registerProject(Map<ProjectComponentIdentifier, RegisteredProject> registeredProjects, IncludedBuildInternal build, ProjectInternal project) {
LocalComponentRegistry localComponentRegistry = project.getServices().get(LocalComponentRegistry.class);
ProjectComponentIdentifier originalIdentifier = newProjectId(project);
DefaultLocalComponentMetadata originalComponent = (DefaultLocalComponentMetadata) localComponentRegistry.getComponent(originalIdentifier);
ProjectComponentIdentifier componentIdentifier = build.idForProjectInThisBuild(project.getPath());
LocalComponentMetadata compositeComponent = createCompositeCopy(build.getModel(), componentIdentifier, originalComponent);
registeredProjects.put(componentIdentifier, new RegisteredProject(compositeComponent));
}
Aggregations