From 890b6d714750358849859613ba1faa03dad287fb Mon Sep 17 00:00:00 2001 From: Akshay CM Date: Wed, 3 Jun 2026 08:10:37 +0530 Subject: [PATCH 1/2] Use ExecOperations in CargoKit Gradle task --- .../cargokit/gradle/plugin.gradle | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/super_native_extensions/cargokit/gradle/plugin.gradle b/super_native_extensions/cargokit/gradle/plugin.gradle index fdf94c43..ffc13a78 100644 --- a/super_native_extensions/cargokit/gradle/plugin.gradle +++ b/super_native_extensions/cargokit/gradle/plugin.gradle @@ -1,5 +1,7 @@ import java.nio.file.Paths +import javax.inject.Inject import org.apache.tools.ant.taskdefs.condition.Os +import org.gradle.process.ExecOperations CargoKitPlugin.file = buildscript.sourceFile @@ -12,6 +14,9 @@ class CargoKitExtension { abstract class CargoKitBuildTask extends DefaultTask { + @Inject + abstract ExecOperations getExecOperations() + @Input String buildMode @@ -57,13 +62,13 @@ abstract class CargoKitBuildTask extends DefaultTask { def rootProjectDir = project.rootProject.projectDir if (!Os.isFamily(Os.FAMILY_WINDOWS)) { - project.exec { - commandLine 'chmod', '+x', path + execOperations.exec { + commandLine 'chmod', '+x', path.toString() } } - project.exec { - executable path + execOperations.exec { + executable path.toString() args "build-gradle" environment "CARGOKIT_ROOT_PROJECT_DIR", rootProjectDir environment "CARGOKIT_TOOL_TEMP_DIR", "${buildDir}/build_tool" From 8b45ffcf5bf907ee854e995e7ea31591d100aa51 Mon Sep 17 00:00:00 2001 From: Akshay CM Date: Wed, 3 Jun 2026 08:21:22 +0530 Subject: [PATCH 2/2] Avoid task project access in CargoKit --- .../cargokit/gradle/plugin.gradle | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/super_native_extensions/cargokit/gradle/plugin.gradle b/super_native_extensions/cargokit/gradle/plugin.gradle index ffc13a78..b5101c30 100644 --- a/super_native_extensions/cargokit/gradle/plugin.gradle +++ b/super_native_extensions/cargokit/gradle/plugin.gradle @@ -41,26 +41,20 @@ abstract class CargoKitBuildTask extends DefaultTask { @Input String pluginFile + @Input + String manifestDir + + @Input + String rootProjectDir + @Input List targetPlatforms @TaskAction def build() { - if (project.cargokit.manifestDir == null) { - throw new GradleException("Property 'manifestDir' must be set on cargokit extension"); - } - - if (project.cargokit.libname == null) { - throw new GradleException("Property 'libname' must be set on cargokit extension"); - } - def executableName = Os.isFamily(Os.FAMILY_WINDOWS) ? "run_build_tool.cmd" : "run_build_tool.sh" def path = Paths.get(new File(pluginFile).parent, "..", executableName); - def manifestDir = Paths.get(project.buildscript.sourceFile.parent, project.cargokit.manifestDir) - - def rootProjectDir = project.rootProject.projectDir - if (!Os.isFamily(Os.FAMILY_WINDOWS)) { execOperations.exec { commandLine 'chmod', '+x', path.toString() @@ -145,6 +139,14 @@ class CargoKitPlugin implements Plugin { // The task name depends on plugin properties, which are not available // at this point project.getGradle().afterProject { + if (project.cargokit.manifestDir == null) { + throw new GradleException("Property 'manifestDir' must be set on cargokit extension"); + } + + if (project.cargokit.libname == null) { + throw new GradleException("Property 'libname' must be set on cargokit extension"); + } + def taskName = "cargokitCargoBuild${project.cargokit.libname.capitalize()}${buildType.capitalize()}"; if (project.tasks.findByName(taskName)) { @@ -165,6 +167,8 @@ class CargoKitPlugin implements Plugin { compileSdkVersion = plugin.project.android.compileSdkVersion.substring(8) as int targetPlatforms = platforms pluginFile = CargoKitPlugin.file + manifestDir = Paths.get(project.buildscript.sourceFile.parent, project.cargokit.manifestDir).toString() + rootProjectDir = project.rootProject.projectDir.toString() } def onTask = { newTask -> if (newTask.name == "merge${buildType.capitalize()}NativeLibs") {