Relax error reporting on script dependencies resolving
to avoid exceptions reported on the gradle model problems, e.g. missing dependencies
This commit is contained in:
+9
-4
@@ -126,7 +126,7 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
|
|||||||
|
|
||||||
fun makeScriptContents() = BasicScriptContents(file, getAnnotations = {
|
fun makeScriptContents() = BasicScriptContents(file, getAnnotations = {
|
||||||
val classLoader = template.java.classLoader
|
val classLoader = template.java.classLoader
|
||||||
takeUnlessError {
|
takeUnlessError(reportError = false) {
|
||||||
getAnnotationEntries(file, project)
|
getAnnotationEntries(file, project)
|
||||||
.mapNotNull { psiAnn ->
|
.mapNotNull { psiAnn ->
|
||||||
// TODO: consider advanced matching using semantic similar to actual resolving
|
// TODO: consider advanced matching using semantic similar to actual resolving
|
||||||
@@ -138,7 +138,7 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
|
|||||||
?: emptyList()
|
?: emptyList()
|
||||||
})
|
})
|
||||||
|
|
||||||
return takeUnlessError {
|
return takeUnlessError(reportError = false) {
|
||||||
val fileDeps = resolver?.resolve(makeScriptContents(), environment, ::logScriptDefMessage, previousDependencies)
|
val fileDeps = resolver?.resolve(makeScriptContents(), environment, ::logScriptDefMessage, previousDependencies)
|
||||||
// TODO: use it as a Future
|
// TODO: use it as a Future
|
||||||
fileDeps?.get()
|
fileDeps?.get()
|
||||||
@@ -177,12 +177,17 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
|
|||||||
override val annotationsForSamWithReceivers: List<String>
|
override val annotationsForSamWithReceivers: List<String>
|
||||||
get() = samWithReceiverAnnotations ?: super.annotationsForSamWithReceivers
|
get() = samWithReceiverAnnotations ?: super.annotationsForSamWithReceivers
|
||||||
|
|
||||||
private inline fun<T> takeUnlessError(body: () -> T?): T? =
|
private inline fun<T> takeUnlessError(reportError: Boolean = true, body: () -> T?): T? =
|
||||||
try {
|
try {
|
||||||
body()
|
body()
|
||||||
}
|
}
|
||||||
catch (ex: Throwable) {
|
catch (ex: Throwable) {
|
||||||
log.error("Invalid script template: ${template.qualifiedName}", ex)
|
if (reportError) {
|
||||||
|
log.error("Invalid script template: " + template.qualifiedName, ex)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.warn("Invalid script template: " + template.qualifiedName, ex)
|
||||||
|
}
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user