@@ -186,7 +186,7 @@ public Configuration createRemappingConfiguration(Configuration parent) {
186186 });
187187 } else if (dep instanceof ProjectDependency projectDependency ) {
188188 project .getDependencies ().constraints (constraints -> {
189- constraints .add (parent .getName (), projectDependency . getDependencyProject ( ), c -> {
189+ constraints .add (parent .getName (), getProjectDependencyProject ( project , projectDependency ), c -> {
190190 c .attributes (a -> a .attribute (MinecraftMappings .ATTRIBUTE , namedMappings ));
191191 });
192192 });
@@ -198,4 +198,21 @@ public Configuration createRemappingConfiguration(Configuration parent) {
198198
199199 return remappingConfig ;
200200 }
201+
202+ private static Project getProjectDependencyProject (Project project , ProjectDependency projectDependency ) {
203+ // Gradle 9 requires using getPath(), but it was only added in 8.11, and we currently target 8.9
204+ try {
205+ var clazz = ProjectDependency .class ;
206+ try {
207+ var getPathMethod = clazz .getMethod ("getPath" );
208+ var path = (String ) getPathMethod .invoke (projectDependency );
209+ return project .project (path );
210+ } catch (NoSuchMethodException ignored ) {
211+ var getDependencyProjectMethod = clazz .getMethod ("getDependencyProject" );
212+ return (Project ) getDependencyProjectMethod .invoke (projectDependency );
213+ }
214+ } catch (ReflectiveOperationException exception ) {
215+ throw new RuntimeException ("Failed to access project of ProjectDependency" , exception );
216+ }
217+ }
201218}
0 commit comments