4949import java .util .Optional ;
5050import java .util .Set ;
5151import java .util .function .Consumer ;
52+ import java .util .function .Function ;
5253import java .util .function .Supplier ;
5354import java .util .regex .Pattern ;
5455import java .util .stream .Collectors ;
@@ -1562,6 +1563,23 @@ private void detectDependencies(NbProjectInfoModel model) {
15621563boolean ignoreUnresolvable = (project .getPlugins ().hasPlugin ("java-platform" ) &&
15631564Boolean .TRUE .equals (getProperty (project ,"javaPlatform" ,"allowDependencies" )));
15641565
1566+ // https://github.com/apache/netbeans/issues/8764
1567+ Function <ProjectDependency ,Project >projDependencyToProject =
1568+ sinceGradleOrDefault (
1569+ "9.0" ,
1570+ () -> {
1571+ Method getPath =ProjectDependency .class .getMethod ("getPath" );
1572+ return dep -> {
1573+ try {
1574+ String path = (String )getPath .invoke (dep );
1575+ return project .findProject (path );
1576+ }catch (ReflectiveOperationException e ) {
1577+ throw new UnsupportedOperationException (e );
1578+ }
1579+ };
1580+ },
1581+ () ->ProjectDependency ::getDependencyProject );// removed in Gradle 9
1582+
15651583visibleConfigurations .forEach (it -> {
15661584String propBase ="configuration_" +it .getName () +"_" ;
15671585model .getInfo ().put (propBase +"non_resolving" , !resolvable (it ));
@@ -1660,7 +1678,7 @@ private void detectDependencies(NbProjectInfoModel model) {
16601678String a ;
16611679if (d instanceof ProjectDependency ) {
16621680sb .append ("*project:" );// NOI18N
1663- Project other = ((ProjectDependency )d ). getDependencyProject ( );
1681+ Project other =projDependencyToProject . apply ((ProjectDependency )d );
16641682g =other .getGroup ().toString ();
16651683a =other .getName ();
16661684 }else {
@@ -1679,7 +1697,7 @@ private void detectDependencies(NbProjectInfoModel model) {
16791697long time_project_deps =System .currentTimeMillis ();
16801698model .registerPerf (depPrefix +"module" ,time_project_deps -time_inspect_conf );
16811699it .getDependencies ().withType (ProjectDependency .class ).forEach (it2 -> {
1682- Project prj =it2 . getDependencyProject ( );
1700+ Project prj =projDependencyToProject . apply ( it2 );
16831701projects .put (prj .getPath (),prj .getProjectDir ());
16841702projectNames .add (prj .getPath ());
16851703 });