Skip to content

Commit edf395c

Browse files
authored
Support Gradle's Isolated Projects feature in EnhancedPluginAdditions#rootProjectDirectory() (#30)
1 parent 38bad72 commit edf395c

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎gradleutils-shared/src/main/java/net/minecraftforge/gradleutils/shared/EnhancedPlugin.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private DirectoryProperty makeRootProjectDirectory() {
221221
try {
222222
var rootProjectDirectory = this.getObjects().directoryProperty();
223223
if (target instanceof Project project) {
224-
return rootProjectDirectory.value(project.getRootProject().getLayout().getProjectDirectory());
224+
return rootProjectDirectory.value(project.getIsolated().getRootProject().getProjectDirectory());
225225
} else if (target instanceof Settings) {
226226
return rootProjectDirectory.value(this.getBuildLayout().getRootDirectory());
227227
} else {

‎gradleutils-shared/src/main/java/net/minecraftforge/gradleutils/shared/EnhancedPluginAdditions.java‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ public sealed interface EnhancedPluginAdditions permits EnhancedPlugin, Enhanced
3838

3939
/// Gets the root project directory to be used for this plugin.
4040
///
41-
/// This directory is either the [org.gradle.api.file.ProjectLayout#getProjectDirectory()] of
42-
/// [org.gradle.api.Project#getRootProject()] or the [org.gradle.api.file.BuildLayout#getRootDirectory()] of the
43-
/// [org.gradle.api.initialization.Settings]. Attempting to call this when the plugin target is neither type will
44-
/// throw an exception.
41+
/// This directory is either the root project's [org.gradle.api.project.IsolatedProject#getProjectDirectory()]
42+
/// (via [org.gradle.api.Project#getIsolated()]) or the [org.gradle.api.file.BuildLayout#getRootDirectory()] of the
43+
/// [org.gradle.api.initialization.Settings]. The isolated view is used instead of
44+
/// [org.gradle.api.Project#getRootProject()] so this remains compatible with Isolated Projects without treating the
45+
/// settings directory as the root project directory. Attempting to call this when the plugin target is neither type
46+
/// will throw an exception.
4547
///
4648
/// @return The root project directory
4749
/// @throws RuntimeException If this plugin cannot access the root project directory (i.e. the target is not

0 commit comments

Comments
 (0)