From dd61abe122d7cf0c49eede66eaadf7593abdfe30 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sun, 11 Aug 2024 22:18:21 -0500 Subject: [PATCH 1/3] Make new utilities not completely bypass capabilities --- .../SourceSetDependencyExtensionImpl.java | 14 ++++++-------- .../SourceSetInheritanceExtensionImpl.java | 12 ++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetDependencyExtensionImpl.java b/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetDependencyExtensionImpl.java index 10156e696..5cab21e11 100644 --- a/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetDependencyExtensionImpl.java +++ b/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetDependencyExtensionImpl.java @@ -43,15 +43,13 @@ public void on(SourceSet sourceSet) { final SourceSetInheritanceExtension sourceSetInheritanceExtension = target.getExtensions().getByType(SourceSetInheritanceExtension.class); sourceSetInheritanceExtension.from(sourceSet); - target.setCompileClasspath( - target.getCompileClasspath().plus( - sourceSet.getOutput() - ) + project.getDependencies().add( + target.getCompileClasspathConfigurationName(), + sourceSet.getOutput() ); - target.setRuntimeClasspath( - target.getRuntimeClasspath().plus( - sourceSet.getOutput() - ) + project.getDependencies().add( + target.getRuntimeClasspathConfigurationName(), + sourceSet.getOutput() ); } } diff --git a/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetInheritanceExtensionImpl.java b/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetInheritanceExtensionImpl.java index b4ce6bcd5..39ed390ac 100644 --- a/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetInheritanceExtensionImpl.java +++ b/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetInheritanceExtensionImpl.java @@ -39,15 +39,11 @@ public void from(SourceSet sourceSet) { ); } - target.setCompileClasspath( - target.getCompileClasspath().plus( - sourceSet.getCompileClasspath() - ) + project.getConfigurations().getByName(target.getCompileClasspathConfigurationName()).extendsFrom( + project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()) ); - target.setRuntimeClasspath( - target.getRuntimeClasspath().plus( - sourceSet.getRuntimeClasspath() - ) + project.getConfigurations().getByName(target.getRuntimeClasspathConfigurationName()).extendsFrom( + project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName()) ); } } From 59fc72d6d8e2ceddc793c09b848edba452a6d202 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sun, 11 Aug 2024 22:24:55 -0500 Subject: [PATCH 2/3] Use implementation instead of adding to wrong configurations --- .../sourcesets/SourceSetDependencyExtensionImpl.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetDependencyExtensionImpl.java b/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetDependencyExtensionImpl.java index 5cab21e11..56e40cbd5 100644 --- a/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetDependencyExtensionImpl.java +++ b/common/src/main/java/net/neoforged/gradle/common/extensions/sourcesets/SourceSetDependencyExtensionImpl.java @@ -44,11 +44,7 @@ public void on(SourceSet sourceSet) { sourceSetInheritanceExtension.from(sourceSet); project.getDependencies().add( - target.getCompileClasspathConfigurationName(), - sourceSet.getOutput() - ); - project.getDependencies().add( - target.getRuntimeClasspathConfigurationName(), + target.getImplementationConfigurationName(), sourceSet.getOutput() ); } From 746d814771ac974326f0a1948ed903039c7fc06a Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sun, 11 Aug 2024 22:53:24 -0500 Subject: [PATCH 3/3] Make test match documented behavior "Makes this source set inherit the dependencies of the provided source set" --- .../groovy/net/neoforged/gradle/userdev/SourceSetTests.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/SourceSetTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/SourceSetTests.groovy index 60fdcf01b..c0365f591 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/SourceSetTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/SourceSetTests.groovy @@ -102,7 +102,6 @@ class SourceSetTests extends BuilderBasedTestSpecification { then: run.getOutput().contains("com.google.code.gson/gson/2.11.0") || run.getOutput().contains("com.google.code.gson\\gson\\2.11.0") - run.getOutput().contains("inheriting_sourcesets_runtime/build/classes/java/main") || run.getOutput().contains("inheriting_sourcesets_runtime\\build\\classes\\java\\main") } def "depending on a sourceset adds the compile dependencies"() {