I have a strange problem. I have tried phrasing what I trying to do in a couple of slightly different ways but it fails to work as I expect it to.
I have a native project that has x86 and x64 targetPlatforms set. When I run the install task I want to run a pre-step that will copy over the additional files and resources needed by one of the Prebuilt Dependencies (CEF3 in this case).
The task itself runs because I see it in the output but on the first run of the install task (any of these actually) it fails to copy the files. When I rerun the install task where most of the steps are UP-TO-DATE the files are actually getting copied into the install output directory.
Here is the task I am creating (I create one for each platform / configuration and hook it into the install’s task as dependency since there are also prebuilt dll’s not only shared resources):
// Copy over CEF3 additional dependencies and resources
tasks.withType(InstallExecutable) { installTask ->
def taskName = "copyCef" + (installTask.name - "install" - "Executable") + "Data"
def cefDir = "../dependencies/cef/lib"
//def arch = installTask.targetPlatform.name <- this returns 'targetPlatform' why? It should return something like 'x86' 'x64' right?
//def outputDir = installTask.destinationDir.getAbsolutePath(); <- destinationDir is null why?
task(taskName, type: Copy) {
def arch = name.contains("X86") ? "x86" : "x64"
def configuration = name.contains("Debug") ? "debug" : "release"
def libDir = "${cefDir}/${arch}/${configuration}"
def resDir = "${cefDir}/resources"
from("${cefDir}/${arch}/${configuration}") {
include "*.bin"
include "wow_helper.exe"
include "widevinecdmadapter.dll"
include "d3dcompiler_43.dll"
include "d3dcompiler_47.dll"
}
from "${cefDir}/resources"
into {
def outputDir = file("build/install/editor/${arch}/${configuration}/lib");
outputDir
}
installTask.dependsOn name
// Moving the task later in the chain does not help
def exeTask = installTask.name - "install"
exeTask = exeTask[0].toLowerCase() + exeTask.substring(1)
dependsOn exeTask
}
}
Thing to note: the last lines were added to move the task to later stage when the ‘exe’ is built I thought maybe that was the problem but nope. Also the commented lines are suspicious - usually this worked when I tried to access the installTask destinationDir but for some reason it was null I guess because InstallTask was not yet configured? Is there a way to defer configuration of this task but keep the execution before install task?