C plugin error in 2.4

Hi, I tried to move my build to gradle 2.4, and I get the following error when I try to run any task:

Cannot add Mutate rule 'org.gradle.language.base.plugins.ComponentModelBasePlugin$Rules#closeSourcesForBinaries(org.gradle.platform.base.BinaryContainer, org.gradle.language.base.ProjectSourceSet)' for model element 'binaries' when element is in state GraphClosed.

It happens when it parses the part related to the build of a C program, which is in a separate file. If I comment the binaries.all section nothing changes. Do you know what that error means?
The offending file is something like this:

apply plugin: 'c'
model {
    components {
        mylib(NativeLibrarySpec) {
            sources.c {
                source {
                    srcDir "src/main/c/mylib"
                    include "**/*.c"
                exportedHeaders {
                    srcDir "src/main/c/mylib"
                    include "**/*.h"
        myprogram(NativeExecutableSpec) {
            sources.c {
                lib library: 'mylib', linkage: 'static'
                source {
                    srcDir "src/main/c/myprogram"
                    include "**/*.c"
            binaries.all {
                    cCompiler.args "-I/opt/local/include"
                    linker.args "-lm"

The error is coming out of the native component plugin (that’s used by the ‘c’ plugin). It has something to do with Gradle thinking that the ‘binaries’ container has been configured and something is trying to add another bit of code that will modify the binaries container again.

This seems to work for me by itself (just what you’ve posted), what’s happening before the c related parts and are there any other plugins applied?

I import that file in build.gradle using "apply from:…"
If I move it at the beginning of the file the C part works, but I get weird errors during compileGroovy

This is what I apply before the c plugin (it’s a griffon project):

apply plugin: 'groovy'
apply plugin: 'org.codehaus.griffon.griffon'
apply plugin: 'idea'
apply from: 'gradle/publishing.gradle' 
apply from: 'gradle/code-coverage.gradle' 
apply from: 'gradle/code-quality.gradle'
apply from: 'gradle/integration-test.gradle'
apply from: 'gradle/package.gradle'
apply from: 'gradle/docs.gradle'
apply plugin: 'com.github.johnrengelman.shadow' 
apply plugin: 'org.kordamp.gradle.stats'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.github.kt3k.coveralls'

I fixed it by removing gradle/package.gradle, which comes from the lazybones template.
This is the content, I don’t know what is tripping gradle off:

import org.apache.tools.ant.filters.ReplaceTokens

apply plugin: 'izpack'
if (macosx) apply plugin: 'com.github.cr0.macappbundle'

dependencies {
    izpack 'org.codehaus.izpack:izpack-standalone-compiler:4.3.5'

task prepareIzpack(type: Copy, dependsOn: installApp) {
    destinationDir = file("$buildDir/install/izpack")
    from('src/main/izpack/resources') {
        into 'resources'
        filter(ReplaceTokens, tokens: ['griffon.version': griffon.version])
    into('binary') {
        from installApp.destinationDir

izPackCreateInstaller.dependsOn prepareIzpack
izPackCreateInstaller.doFirst {
    ant.chmod(dir: "$buildDir/install/izpack/binary/bin", excludes: '*.bat', perm: 'ugo+x')

izpack {
    baseDir = file("$buildDir/install/izpack")
    installFile = file('src/main/izpack/install.xml')
    outputFile = file("$buildDir/distributions/${project.name}-${version}-installer.jar")
    compression = 'deflate'
    compressionLevel = 9
    appProperties = [
        'app.group'       : 'Applications',
        'app.name'        : project.name,
        'app.title'       : project.name,
        'app.version'     : project.version,
        'app.subpath'     : "${project.name}-${project.version}",
        'app.binary'      : project.name,
        'app.java.version': targetCompatibility

if (macosx) {
    macAppBundle {
        mainClassName = project.mainClassName
        icon = 'src/media/griffon.icns'
        javaProperties.put('apple.laf.useScreenMenuBar', 'true')

apply plugin: 'de.gliderpilot.jnlp'

if (!project.hasProperty('keyAlias')) ext.keyAlias = ''
if (!project.hasProperty('keystorePwd')) ext.keystorePwd = ''

jnlp {
    useVersions = true
    withXml {
        information {
            title project.name
            vendor project.group ?: project.name
        security {
    signJarParams = [alias: keyAlias, storepass: keystorePwd]