I realize it is incubating, but I’ve discovered something in the configuration of my native C++ project:
I’m trying to do most of the configuration in a custom plugin/script and then have the ability to tweak options in the project build.gradle file. This was working with 2.3, but with 2.4-rc-1 gradle thinks I’m trying to re-declare my main library instead of just tweak some options on it.
Exception thrown while executing model rule: model.components
Cannot create ‘components.main’ using creation rule ‘model.components > create(main)’ as the rule ‘model.components > create(main)’ is already registered to create this model element.
The line it is complaining about is in a method of my plugin that is used to tweak the source folders:
public void withCppSource(def closure) {
project.model {
components {
main(NativeLibrarySpec) {
sources {
cpp {
source closure
}
}
}
}
}
}
I’m providing this utility method so my plugin keeps my main build.gradle file compatible with Gradle 2.2.1 and later versions (2.3+) where the structure of native C++ scripts has changed.
Looking closer at the release notes, I suspect this is not surprising behaviour (the notes state: “Using create syntax fails when the element already exists.”) . But I’m not sure how to fix my code to accommodate the delayed creation and still have a utility method to configure the C++ source files. What syntax should I be using?
Everything I’ve tried has failed with the message:
The following model rules are unbound:
model.main.sources.cpp
Mutable:
- main.sources.cpp (java.lang.Object)
(for main.sources, main.sources.cpp, main.sources.cpp.source ,etc.)
Which I think is related to the other note: “There are currently no query method on this interface.”