# How would you create the model-component closure in a custom plugin since the 2.3 native-component changes?

**URL:** <https://discuss.gradle.org/t/how-would-you-create-the-model-component-closure-in-a-custom-plugin-since-the-2-3-native-component-changes/4247>\
**Category:** Old Forum Archive\
**Created:** [February 4, 2015, 9:54pm UTC](https://discuss.gradle.org/t/how-would-you-create-the-model-component-closure-in-a-custom-plugin-since-the-2-3-native-component-changes/4247 "2015-02-04T21:54:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eman3488](https://avatars.discourse-cdn.com/v4/letter/e/dec6dc/32.png) [@eman3488](https://discuss.gradle.org/u/eman3488)\
**Post date:** [February 4, 2015, 9:54pm UTC](https://discuss.gradle.org/t/how-would-you-create-the-model-component-closure-in-a-custom-plugin-since-the-2-3-native-component-changes/4247/1 "2015-02-04T21:54:00Z")

</div>

How can I recreate the new 2.3-rc-2 “model” closure which contains a CppSourceSet inside my plugin? I used to be able to do something like project.libraries.create but I’m not sure how to create or access the components piece.

This boils down to how do you add a sourceset to a component container? Im trying to do something like the following:

```gradle
project.model {
    project.extensions.rs.libs.each { l ->
        components.create(
            l.name, NativeLibrarySpec.class, {
                 sources {
                    l.sources(project)
                }
            }
        )
    }
}

```

or

```gradle
project.model {
    project.extensions.rs.libs.each { l ->
        components {
            l.name(NativeLibrarySpec) {
                 sources {
                    l.sources(project)
                }
            }
        )
    }
}

```

where [l.name](http://l.name) is just the string name of the binary and sources(project) will return the sourceset.

---

<div class="post-metadata">

**Author:** ![erdi](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/erdi/32/24_2.png) [@erdi](https://discuss.gradle.org/u/erdi)\
**Post date:** [February 6, 2015, 1:52pm UTC](https://discuss.gradle.org/t/how-would-you-create-the-model-component-closure-in-a-custom-plugin-since-the-2-3-native-component-changes/4247/2 "2015-02-06T13:52:00Z")

</div>

This is all very much work in progress and is undocumented. It will also require quite a lot of effort on your side to implement it and you will have to get your hands dirty with going through a lot of Gradle source and tests to understand the mechanisms. It’s also very probable that it will change slightly for the next (2.4) release and you will have to rework it again.

Please confirm that you are still interested in this before I invest my time in outlining how to approach this.
