Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid Gradle internal API CompositeProjectComponentArtifactMetadata #29622

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.compile.AbstractCompile;
import org.gradle.composite.internal.CompositeProjectComponentArtifactMetadata;
import org.gradle.internal.composite.IncludedBuildInternal;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aloubyansky @glefloch isn't this class internal too? Wondering if there are alternatives.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. It's not obvious how to avoid it for me. Ideally, we don't want to rely on internal API. @glefloch if you have some time to research this one, it'd be very much appreciated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I will have a look on it.

import org.gradle.language.jvm.tasks.ProcessResources;
import org.gradle.tooling.provider.model.ParameterizedToolingModelBuilder;
Expand Down Expand Up @@ -170,11 +169,10 @@ private void collectExtensionDependencies(Project project, Configuration deploym
if (a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) {
ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) a.getId()
.getComponentIdentifier();
var includedBuild = ToolingUtils.includedBuild(project, projectComponentIdentifier);
Project projectDep = null;
if (a.getId() instanceof CompositeProjectComponentArtifactMetadata) {
projectDep = ToolingUtils.includedBuildProject(
(IncludedBuildInternal) Objects
.requireNonNull(ToolingUtils.includedBuild(project, projectComponentIdentifier)),
if (includedBuild != null) {
projectDep = ToolingUtils.includedBuildProject((IncludedBuildInternal) includedBuild,
projectComponentIdentifier);
} else {
projectDep = project.getRootProject().findProject(projectComponentIdentifier.getProjectPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.UnknownDomainObjectException;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.component.ProjectComponentIdentifier;
import org.gradle.api.attributes.Category;
Expand Down Expand Up @@ -41,11 +40,13 @@ public static boolean isEnforcedPlatform(ModuleDependency module) {

public static IncludedBuild includedBuild(final Project project,
final ProjectComponentIdentifier projectComponentIdentifier) {
try {
return project.getRootProject().getGradle().includedBuild(projectComponentIdentifier.getBuild().getName());
} catch (UnknownDomainObjectException e) {
return null;
final String name = projectComponentIdentifier.getBuild().getName();
for (IncludedBuild ib : project.getRootProject().getGradle().getIncludedBuilds()) {
if (ib.getName().equals(name)) {
return ib;
}
}
return null;
}

public static Project includedBuildProject(IncludedBuildInternal includedBuild,
Expand Down