@@ -6,6 +6,7 @@ import com.sun.jdi.*
6
6
import kotlinx.coroutines.CoroutineScope
7
7
import kotlinx.coroutines.Dispatchers
8
8
import kotlinx.coroutines.launch
9
+ import org.gradle.tooling.BuildCancelledException
9
10
import org.gradle.tooling.BuildLauncher
10
11
import org.gradle.tooling.GradleConnector
11
12
import org.gradle.tooling.events.ProgressListener
@@ -29,6 +30,7 @@ class GradleJob{
29
30
NONE ,
30
31
BUILDING ,
31
32
RUNNING ,
33
+ ERROR ,
32
34
DONE
33
35
}
34
36
@@ -64,7 +66,31 @@ class GradleJob{
64
66
run ()
65
67
}
66
68
}catch (e: Exception ){
67
- Messages .log(" Error while running: ${e.message} ${e.cause?.message} " )
69
+ val causesList = mutableListOf<Throwable >()
70
+ var cause: Throwable ? = e
71
+ while (cause != null && cause.cause != cause) {
72
+ causesList.add(cause)
73
+ cause = cause.cause
74
+ }
75
+
76
+ val errors = causesList.joinToString(" \n " ) { it.message ? : " Unknown error" }
77
+
78
+ val skip = listOf (BuildCancelledException ::class )
79
+
80
+ if (skip.any { it.isInstance(e) }) {
81
+ Messages .log(" Gradle job error: $errors " )
82
+ return @launch
83
+ }
84
+
85
+ if (state.value != State .BUILDING ){
86
+ Messages .log(" Gradle job error: $errors " )
87
+ return @launch
88
+ }
89
+
90
+ // An error occurred during the build process
91
+
92
+ System .err.println (errors)
93
+ service?.editor?.statusError(cause?.message)
68
94
}finally {
69
95
state.value = State .DONE
70
96
vm.value = null
@@ -94,30 +120,40 @@ class GradleJob{
94
120
}
95
121
96
122
when (event.descriptor.name){
97
- " :jar" -> {
98
- state.value = State .NONE
99
- Messages .log(" Jar finished" )
100
- }
101
123
" :run" -> {
102
- state.value = State .NONE
124
+ state.value = State .DONE
103
125
service?.editor?.toolbar?.deactivateRun()
104
126
service?.editor?.toolbar?.deactivateStop()
105
127
}
106
128
}
107
129
}
108
130
if (event is DefaultSingleProblemEvent ) {
109
- /*
110
- We have 6 lines to display the error in the editor.
111
- */
112
131
113
- if (event.definition.severity == Severity . ADVICE ) return @ProgressListener
132
+
114
133
problems.add(event)
115
134
135
+ val skip = listOf (
136
+ " mutating-the-dependencies-of-configuration-implementation-after-it-has-been-resolved-or-consumed-this-behavior-has-been-deprecated" ,
137
+ " mutating-the-dependencies-of-configuration-runtimeonly-after-it-has-been-resolved-or-consumed-this-behavior-has-been-deprecated"
138
+ )
139
+ if (skip.any { event.definition.id.name.contains(it) }) {
140
+ Messages .log(event.toString())
141
+ return @ProgressListener
142
+ }
143
+
144
+ if (event.definition.severity == Severity .ADVICE ) {
145
+ Messages .log(event.toString())
146
+ return @ProgressListener
147
+ }
116
148
// TODO: Show the error on the location if it is available
149
+ /*
150
+ We have 6 lines to display the error in the editor.
151
+ */
117
152
118
153
val error = event.definition.id.displayName
119
154
service?.editor?.statusError(error)
120
155
System .err.println (" Problem: $error " )
156
+ state.value = State .ERROR
121
157
122
158
val message = """
123
159
Context: ${event.contextualLabel.contextualLabel}
0 commit comments