Issue
This question explains what the "safeUnbox warning" is.
I have the following in my build.gradle:
lintOptions {
quiet false
abortOnError true
warningsAsErrors true
baseline file("lint-baseline.xml")
}
and later:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = "1.8"
allWarningsAsErrors = true
}
}
But data-binding safeUnbox warnings don't fail the build process. The output has complains about warnings and that warnings was turned to errors:
w: warning: viewModel.doorsState.getValue().first is a boxed field but needs to be un-boxed to execute android:text. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap viewModel.doorsState.getValue().first with safeUnbox() to prevent the warning
file:///.../app/src/debug/res/layout/activity_car_connection_debug.xml Line:75
e: warnings found and -Werror specified
But at the very end of the building process I have:
BUILD SUCCESSFUL in 46s
Is there any way to make the whole build process unsuccessful upon "safeUnbox warning"?
Solution
I have found the solution, Yay!
Putting the following spell to the root gradle.build
solves the problem.
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("kotlin-kapt")) {
kapt {
javacOptions {
option("-Xmaxerrs", 1000)
option("-Werror")
}
}
}
}
}
Also the spell increases the limit of how many errors are being logged (default value: 100) which is useful if DataBinding is used.
Answered By - Alexander Skvortsov Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.