From a535ecb1ceef3f5e5a497d60c21260f94fc9d66a Mon Sep 17 00:00:00 2001 From: Olli Vuolteenaho Date: Wed, 2 Jul 2025 13:36:02 +0300 Subject: Improve QtGP error messages for nonexisting directories With the current implementation the error messages for typoing the three user-defined paths in gradle.properties are terrible. If the user sets qt.path to a nonexisting directory: * What went wrong: Execution failed for task ':app:QtBuildTask'. > No Qt for Android kit found from: This is the best one, as at least it shows that something is wrong finding Q4A. For a wrong qt.abiPath the abiPath is ignored and a normal multi-ABI build is started instead without showing any error. Probably not the desired course of action. And if qt.projectPath is wrong: * What went wrong: A problem occurred configuring project ':app'. > Could not create task ':app:QtBuildTask'. > Cannot cast object '' with class 'java.lang.String' to class 'java.io.File' This all stems from the getAbsolutePath function returning an empty string if the path doesn't exist. By removing that we can get better error messages from later down in the chain or from gradle: * What went wrong: Execution failed for task ':app:QtBuildTask'. > No Qt for Android kit found from: /Users/ollivuolteenaho/Qt/not-here * What went wrong: Execution failed for task ':app:QtBuildTask'. > No Core.json file found under /Users/ollivuolteenaho/Qt/not-here/ android_arm64_v8a/modules/Core.json. * What went wrong: A problem was found with the configuration of task ':app:QtBuildTask' (type 'QtBuildTask'). - In plugin 'org.qtproject.qt.gradleplugin' type 'org.qtproject.qt.gradleplugin.QtBuildTask' property 'projectPath' specifies directory '/Users/ollivuolteenaho/Qt/Examples/Qt-6.9.1/ platforms/android/doesnt-exist' which doesn't exist. We could also raise an error QtGradlePlugin.yaml:buildTask but a problem with that approach is that it also blocks "gradle clean", because the error is in the plugin configuration stage at that point. So this seems like the simple quick fix to make everything more sensible and future improvements can be handled through QTTA-342. Fixes: QTTA-357 Change-Id: I469cb64cb9e9f07a408886747cbbb2a6274578d4 Reviewed-by: Assam Boudjelthia --- src/main/groovy/org/qtproject/qt/gradleplugin/Utils.groovy | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/main') diff --git a/src/main/groovy/org/qtproject/qt/gradleplugin/Utils.groovy b/src/main/groovy/org/qtproject/qt/gradleplugin/Utils.groovy index 5dd77c7..8eecdc8 100644 --- a/src/main/groovy/org/qtproject/qt/gradleplugin/Utils.groovy +++ b/src/main/groovy/org/qtproject/qt/gradleplugin/Utils.groovy @@ -49,8 +49,6 @@ class Utils { static getAbsolutePath(String path, Project project) { def file = new File(path) - if (!file.exists()) - return "" if (!file.isAbsolute()) file = project.rootProject.file(path) -- cgit v1.2.3