aboutsummaryrefslogtreecommitdiffstats
diff options
authorTero Koponen <tero.koponen@qt.io>2025-05-06 15:48:40 +0300
committerTero Koponen <tero.koponen@qt.io>2025-05-08 14:48:35 +0300
commit134038daeab1a28c497292f46ccce0a11f1dc154 (patch)
treef6f81b61844e51d015473a3ba829093b3bb35cf5
parent1b41c68f5ae7904ba7c1a85f46f580d51c9313d0 (diff)
Add comments to explain programming choicesHEADdev
Added comments for commonly asked questions in the code. Change-Id: Iaf75f68a6a90a01d52b056a7397a5b330ca0582d Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
-rw-r--r--src/main/groovy/org/qtproject/qt/gradleplugin/QtBuildTask.groovy11
-rw-r--r--src/main/groovy/org/qtproject/qt/gradleplugin/QtGradlePlugin.groovy1
2 files changed, 11 insertions, 1 deletions
diff --git a/src/main/groovy/org/qtproject/qt/gradleplugin/QtBuildTask.groovy b/src/main/groovy/org/qtproject/qt/gradleplugin/QtBuildTask.groovy
index b7d7232..dc2de81 100644
--- a/src/main/groovy/org/qtproject/qt/gradleplugin/QtBuildTask.groovy
+++ b/src/main/groovy/org/qtproject/qt/gradleplugin/QtBuildTask.groovy
@@ -16,6 +16,8 @@ import org.gradle.api.tasks.TaskAction
import java.util.jar.Manifest
class QtBuildTask extends DefaultTask {
+ // qtPath and qtKitDir are taken as @Input instead of @InputDirectory to reduce the amount of
+ // up-to-date checks that could happen because changes in these folders.
@Input
String qtPath
@Optional @Input
@@ -69,7 +71,7 @@ class QtBuildTask extends DefaultTask {
exec configCommand()
createEmptySettingsGradle()
exec buildCommand()
- addDependency()
+ addDependency() // needs to be called after buildCommand() to "load" the AAR content to the IDE.
}
def addDependency() {
@@ -79,6 +81,8 @@ class QtBuildTask extends DefaultTask {
include: ["${targetName}.aar"]))
}
+ // Declared as @Internal so gradle will ignore this path when checking if the task is
+ // up-to-date or not.
@Internal
def getQtCMakeWrapperPath() {
def qtCMakeWrapperPath = "$qtKitDir/bin/qt-cmake"
@@ -132,6 +136,11 @@ class QtBuildTask extends DefaultTask {
return System.properties['os.name'].contains('Windows')
}
+ // This empty settings.gradle file prevents Gradle from misinterpreting the build structure.
+ // Without it, Gradle would find the parent project's settings.gradle file,
+ // which does not define this Android subproject. This leads to an error.
+ // To avoid this, we place an empty settings.gradle here so Gradle treats this directory as
+ // a standalone build root and does not try to reuse the parent's settings file.
def createEmptySettingsGradle() {
def targetName = Utils.getAndroidBuildTargetName(buildDirectory)
def settingsGradle = new File("${buildDirectory}/android-build-${targetName}/settings.gradle")
diff --git a/src/main/groovy/org/qtproject/qt/gradleplugin/QtGradlePlugin.groovy b/src/main/groovy/org/qtproject/qt/gradleplugin/QtGradlePlugin.groovy
index a176157..7a4c852 100644
--- a/src/main/groovy/org/qtproject/qt/gradleplugin/QtGradlePlugin.groovy
+++ b/src/main/groovy/org/qtproject/qt/gradleplugin/QtGradlePlugin.groovy
@@ -7,6 +7,7 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
class QtPluginExtension {
+ // qtPath and qtKitDir kept as File to avoid breaking the public API, even though they are used as strings later.
File qtPath
File qtKitDir
File projectPath