This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new a1abbda4f6 Fix GradleReport Notification and potential NPE on Gradle
earlier, than 6.8 (#3994)
a1abbda4f6 is described below
commit a1abbda4f653c801d475b5fed987ba5df7e3a35e
Author: Laszlo Kishalmi <[email protected]>
AuthorDate: Sun Apr 17 20:49:37 2022 -0700
Fix GradleReport Notification and potential NPE on Gradle earlier, than 6.8
(#3994)
* Add meaningful toString() method for GradleReport
* Fix potential UnsupportedOperationException with project using Gradle
earlier than version 6.8
---
.../netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java | 9 +++++++--
.../gradle/src/org/netbeans/modules/gradle/GradleReport.java | 6 ++++++
.../netbeans/modules/gradle/loaders/LegacyProjectLoader.java | 10 ++++++----
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git
a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
index 802608855a..bc3c26203f 100644
---
a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
+++
b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
@@ -445,9 +445,14 @@ class NbProjectInfoBuilder {
// do not bother with components that only
select a variant, which is itself a component
// TODO: represent as a special component type
so the IDE shows it, but the IDE knows it is an abstract
// intermediate with no artifact(s).
- if (rdr.getResolvedVariant() == null ||
-
!rdr.getResolvedVariant().getExternalVariant().isPresent()) {
+ if (rdr.getResolvedVariant() == null) {
componentIds.add(rdr.getSelected().getId().toString());
+ } else {
+ sinceGradle("6.8", () -> {
+ if
(!rdr.getResolvedVariant().getExternalVariant().isPresent()) {
+
componentIds.add(rdr.getSelected().getId().toString());
+ }
+ });
}
}
}
diff --git a/extide/gradle/src/org/netbeans/modules/gradle/GradleReport.java
b/extide/gradle/src/org/netbeans/modules/gradle/GradleReport.java
index b26ffe4905..97eeb8d0c5 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/GradleReport.java
+++ b/extide/gradle/src/org/netbeans/modules/gradle/GradleReport.java
@@ -107,6 +107,11 @@ public final class GradleReport {
return Objects.equals(this.location, other.location);
}
+ @Override
+ public String toString() {
+ return formatReportForHintOrProblem(true, null);
+ }
+
@NbBundle.Messages({
"# {0} - previous part",
"# {1} - appended part",
@@ -119,6 +124,7 @@ public final class GradleReport {
"# {1} - the file",
"FMT_MessageWithLocationNoLine={0} ({1})"
})
+
/**
* Formats the report for simple viewing. The function concatenates report
messages, starting from
* outer Report. If `includeLocation` is true, script name + line is
printed at the end.
diff --git
a/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
b/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
index 4496ab9e2c..b4c82ef7cc 100644
---
a/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
+++
b/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
@@ -175,7 +175,7 @@ public class LegacyProjectLoader extends
AbstractProjectLoader {
errors.openNotification(
TIT_LOAD_ISSUES(base.getProjectDir().getName()),
TIT_LOAD_ISSUES(base.getProjectDir().getName()),
-
GradleProjectErrorNotifications.bulletedList(info.getProblems()));
+
GradleProjectErrorNotifications.bulletedList(info.getProblems()));
}
if (!info.hasException()) {
if (!info.getProblems().isEmpty() ||
!info.getReports().isEmpty()) {
@@ -373,9 +373,11 @@ public class LegacyProjectLoader extends
AbstractProjectLoader {
if (e.getClass().getName().endsWith("LocationAwareException")) { //
NOI18N
String rawLoc = getLocation(e);
- Matcher m = FILE_PATH_FROM_LOCATION.matcher(rawLoc);
- loc = m.matches() ? m.group(1) : rawLoc;
- line = getLineNumber(e);
+ if (rawLoc != null) {
+ Matcher m = FILE_PATH_FROM_LOCATION.matcher(rawLoc);
+ loc = m.matches() ? m.group(1) : rawLoc;
+ line = getLineNumber(e);
+ }
reported = e.getCause();
} else {
reported = e;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists