Hello
I’m building a custom plugin for processing native binaries built with the Gradle native plugin.
I get a “Cannot get private data” error when trying to refer to a specific native binary from my own
model using the path expression: $.components.testexe.binaries.releaseExecutable
I can’t understand the error message or what I’m doing wrong.
Most likely I’m misunderstanding something about the path syntax, custom models
or the native plugin, but I’m a bit lost. Of course I could just get all binaries and loop
through them and match the one that I want with a name string or something, but that
seems to go against the idea of the Gradle model.
I got pretty far relatively easily with the fine and well written documentation at:
https://docs.gradle.org/current/userguide/software_model.html
Together with the gradle-3.0/samples/modelRules/modelDsl/build.gradle
Here is the full error and a Gradle 3.0 file that gives the error for example when running “gradle model”
FAILURE: Build failed with an exception.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':model'.
> Exception thrown while executing model rule: BinaryBasePlugin.Rules#defineBuildLifecycleTask(BinarySpecInternal, ITaskFactory)
> Cannot get private data 'executable 'testexe:release:executable'' of type 'org.gradle.nativeplatform.NativeExecutableBinarySpec' as type 'org.gradle.nativeplatform.internal.DefaultNativeExecutableBinarySpec
build.gradle:
// Model item to declare which binary should be stored and where
@Managed
trait StoredExecutable {
void setExecutable(NativeExecutableBinarySpec exeBinSpec) {}
NativeExecutableBinarySpec getExecutable() {}
}
class FiskhamnPlugin extends RuleSource {
@Model
void storedExecutables(ModelMap<StoredExecutable> storedExecutables){}
// Create task based on configuration in StoredExecutable
@Mutate
void createStoreNativeExeTask(ModelMap<Task> tasks, ModelMap<StoredExecutable> exes) {
for (exe in exes) {
println("createStoreNativeExeTask here $exe")
}
}
}
apply plugin: 'cpp'
apply plugin: FiskhamnPlugin
model {
buildTypes {
debug
release
}
platforms {
x64 {
architecture "x86_64"
}
}
components {
testexe(NativeExecutableSpec)
}
storedExe(StoredExecutable) {
executable = $.components.testexe.binaries.releaseExecutable
}
}