# Native: how declare a module that only exports headers?

**URL:** <https://discuss.gradle.org/t/native-how-declare-a-module-that-only-exports-headers/23707>\
**Category:** Help/Discuss\
**Tags:** native\
**Created:** [August 11, 2017, 8:28pm UTC](https://discuss.gradle.org/t/native-how-declare-a-module-that-only-exports-headers/23707 "2017-08-11T20:28:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zosrothko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zosrothko/32/5438_2.png) [@zosrothko](https://discuss.gradle.org/u/zosrothko)\
**Post date:** [August 11, 2017, 8:28pm UTC](https://discuss.gradle.org/t/native-how-declare-a-module-that-only-exports-headers/23707/1 "2017-08-11T20:28:46Z")

</div>

Hi

I have a module that contains only includes files and would like to export them to be consumed by the other modules. So, the build.gradle would be like

```gradle
model {
	components {
		assert(NativeLibrarySpec) {
                    sources {
                        cpp {
                            exportedHeaders {
                              srcDirs "include"
                            } 
                       }
                   }
	      }
	}
}

```

but the build fails with a closure exception

```gradle
A problem occurred configuring project ':libs:assert'.
> Exception thrown while executing model rule: components { ... } @ libs\assert\build.gradle line 2, column 2
   > Cannot cast object 'build_74j8sva4y7dbyjzuvyl68onma$_run_closure1$_closure2$_closure3@50cb21' with class 'build_74j8sva4y7dbyjzuvyl68onma$_run_closure1$_closure2$_closure3' to class 'org.gradle.nativeplatform.NativeLibrarySpec'

```

How should be declared a include only module?

---

<div class="post-metadata">

**Author:** ![Alex\_Vol](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Alex\_Vol](https://discuss.gradle.org/u/Alex_Vol)\
**Post date:** [August 11, 2017, 8:47pm UTC](https://discuss.gradle.org/t/native-how-declare-a-module-that-only-exports-headers/23707/2 "2017-08-11T20:47:35Z")

</div>

I believe you are running into a known issue with Java/Groovy keywords mixed into Gradle DSL. “assert” is a keyword and should be placed in quotes to avoid confusing it with the keyword.

This would work:

```
model {
	components {
		"assert"(NativeLibrarySpec) {
                    sources {
                        cpp {
                            exportedHeaders {
                              srcDirs "include"
                            } 
                       }
                   }
	      }
	}
}

```

Note how the component name is in quotes.

---

<div class="post-metadata">

**Author:** ![zosrothko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zosrothko/32/5438_2.png) [@zosrothko](https://discuss.gradle.org/u/zosrothko)\
**Post date:** [August 11, 2017, 9:04pm UTC](https://discuss.gradle.org/t/native-how-declare-a-module-that-only-exports-headers/23707/3 "2017-08-11T21:04:56Z")

</div>

I am also wondering why the module should be a NativeLibrarySpec. Why a NativeComponentSpec does not work? THis module will never produce any NativeBinary but is somewhat a component part of the building process?

---

<div class="post-metadata">

**Author:** ![Alex\_Vol](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Alex\_Vol](https://discuss.gradle.org/u/Alex_Vol)\
**Post date:** [August 11, 2017, 9:10pm UTC](https://discuss.gradle.org/t/native-how-declare-a-module-that-only-exports-headers/23707/4 "2017-08-11T21:10:42Z")

</div>

A NativeLibrary is a component that supports exportedHeaders. NativeComponentSpec is a base class for all component types and does not have an exportedHeaders capability. Gradle will not build a native binary for such a library and when making a reference to such a library `linkage:` must be set to ‘api’ to signal that you are not expecting a library to link with, just new headers added to the include paths.
