Skip to content

Commit

Permalink
Simplify dynamic project dependency handling
Browse files Browse the repository at this point in the history
  • Loading branch information
breskeby committed Nov 22, 2024
1 parent 8a43818 commit 7add102
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.internal.artifacts.dependencies.ProjectDependencyInternal;
import org.gradle.api.plugins.BasePluginExtension;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.tasks.javadoc.Javadoc;
Expand Down Expand Up @@ -88,7 +87,8 @@ private void configureJavadocForConfiguration(Project project, boolean shadow, C

private void configureDependency(Project project, boolean shadowed, ProjectDependency dep) {
// we should use variant aware dependency management to resolve artifacts required for javadoc here
Project upstreamProject = project.project(((ProjectDependencyInternal) dep).getIdentityPath().getPath());
String buildTreePath = dep.getPath();
Project upstreamProject = project.project(buildTreePath);
if (upstreamProject == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.attributes.Attribute;
import org.gradle.api.attributes.LibraryElements;
import org.gradle.api.internal.artifacts.dependencies.ProjectDependencyInternal;
import org.gradle.api.plugins.ExtraPropertiesExtension;
import org.gradle.api.tasks.Copy;
import org.gradle.api.tasks.SourceSetContainer;
Expand Down Expand Up @@ -69,9 +68,7 @@ private static void addPluginResources(final Project project, final ProjectDepen
project.getObjects().named(LibraryElements.class, LibraryElements.RESOURCES)
);
DependencyHandler dependencyHandler = project.getDependencies();
ProjectDependencyInternal pluginProject = (ProjectDependencyInternal) projectDependency;

String path = pluginProject.getIdentityPath().getPath();
String path = projectDependency.getPath();
Dependency pluginMetadataDependency = dependencyHandler.project(Map.of("path", path));
dependencyHandler.add(metadataConfiguration, pluginMetadataDependency);
project.getTasks().register(taskName, Copy.class, copy -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private void copyDependencies(Project project, DependencySet dependencies, Confi
configuration.getDependencies()
.stream()
.filter(d -> d instanceof ProjectDependency)
.map(d -> project.getDependencies().project(Map.of("path", ((ProjectDependencyInternal) d).getIdentityPath().getPath())))
.map(d -> project.getDependencies().project(Map.of("path", ((ProjectDependencyInternal) d).getPath())))
.forEach(dependencies::add);
}

Expand Down Expand Up @@ -331,9 +331,7 @@ private Configuration createPluginConfiguration(Project project, String name, bo
Dependency dependency = iterator.next();
// this logic of relying on other projects metadata should probably live in a build service
if (dependency instanceof ProjectDependency projectDependency) {
Project dependencyProject = project.project(
((ProjectDependencyInternal) projectDependency).getIdentityPath().getPath()
);
Project dependencyProject = project.project(((ProjectDependencyInternal) projectDependency).getPath());
List<String> extendedPlugins = dependencyProject.getExtensions()
.getByType(PluginPropertiesExtension.class)
.getExtendedPlugins();
Expand Down

0 comments on commit 7add102

Please sign in to comment.