"Cannot get private data" error with custom model and cpp-plugin

(Peter Lamberg) #1


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:

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


// Model item to declare which binary should be stored and where
trait StoredExecutable {
    void setExecutable(NativeExecutableBinarySpec exeBinSpec) {}
    NativeExecutableBinarySpec getExecutable() {}

class FiskhamnPlugin extends RuleSource {

    void storedExecutables(ModelMap<StoredExecutable> storedExecutables){}

    // Create task based on configuration in StoredExecutable
    void createStoreNativeExeTask(ModelMap<Task> tasks, ModelMap<StoredExecutable> exes) {
        for (exe in exes) {
            println("createStoreNativeExeTask here $exe")


apply plugin: 'cpp'
apply plugin: FiskhamnPlugin

model {
    buildTypes {

    platforms {
        x64 {
            architecture "x86_64"

    components {

    storedExe(StoredExecutable) {
        executable = $.components.testexe.binaries.releaseExecutable

(Peter Lamberg) #3


I’m thinking about submitting this as a bug. I just can’t decide whether the primary problem is the error message or the fact that cpp-plugin does not allow accessing the models for the binaries via a path expression…