49
49
import java .util .Optional ;
50
50
import java .util .Set ;
51
51
import java .util .function .Consumer ;
52
+ import java .util .function .Function ;
52
53
import java .util .function .Supplier ;
53
54
import java .util .regex .Pattern ;
54
55
import java .util .stream .Collectors ;
@@ -1562,6 +1563,23 @@ private void detectDependencies(NbProjectInfoModel model) {
1562
1563
boolean ignoreUnresolvable = (project .getPlugins ().hasPlugin ("java-platform" ) &&
1563
1564
Boolean .TRUE .equals (getProperty (project , "javaPlatform" , "allowDependencies" )));
1564
1565
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
+
1565
1583
visibleConfigurations .forEach (it -> {
1566
1584
String propBase = "configuration_" + it .getName () + "_" ;
1567
1585
model .getInfo ().put (propBase + "non_resolving" , !resolvable (it ));
@@ -1660,7 +1678,7 @@ private void detectDependencies(NbProjectInfoModel model) {
1660
1678
String a ;
1661
1679
if (d instanceof ProjectDependency ) {
1662
1680
sb .append ("*project:" ); // NOI18N
1663
- Project other = ((ProjectDependency )d ). getDependencyProject ( );
1681
+ Project other = projDependencyToProject . apply ((ProjectDependency ) d );
1664
1682
g = other .getGroup ().toString ();
1665
1683
a = other .getName ();
1666
1684
} else {
@@ -1679,7 +1697,7 @@ private void detectDependencies(NbProjectInfoModel model) {
1679
1697
long time_project_deps = System .currentTimeMillis ();
1680
1698
model .registerPerf (depPrefix + "module" , time_project_deps - time_inspect_conf );
1681
1699
it .getDependencies ().withType (ProjectDependency .class ).forEach (it2 -> {
1682
- Project prj = it2 . getDependencyProject ( );
1700
+ Project prj = projDependencyToProject . apply ( it2 );
1683
1701
projects .put (prj .getPath (), prj .getProjectDir ());
1684
1702
projectNames .add (prj .getPath ());
1685
1703
});
0 commit comments