# How to declare a dependency to a native subproject form a Java project

**URL:** <https://discuss.gradle.org/t/how-to-declare-a-dependency-to-a-native-subproject-form-a-java-project/41071>\
**Category:** Help/Discuss\
**Created:** [September 27, 2021, 12:30pm UTC](https://discuss.gradle.org/t/how-to-declare-a-dependency-to-a-native-subproject-form-a-java-project/41071 "2021-09-27T12:30:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bric3](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bric3/32/9458_2.png) [@bric3](https://discuss.gradle.org/u/bric3)\
**Post date:** [September 27, 2021, 12:30pm UTC](https://discuss.gradle.org/t/how-to-declare-a-dependency-to-a-native-subproject-form-a-java-project/41071/1 "2021-09-27T12:30:39Z")

</div>

I’m setting up a project that relies on native code written in both C and swift. Which is more or less shaped this way :

```gradle
├── cpp-subproject
│ └── build.gradle.kts
├── java-library
│ └── build.gradle.kts
├── swift-subproject
│ └── build.gradle.kts
├── build.gradle.kts
└── settings.gradle.kts

```

I’d like to use the native library (`.dylib` / `.so`) produced in `cpp-subproject` and `swift-subproject` as dependency to `java-library`.

For now I’m using a dumb approach using a relative path. But I would like to use something using the Gradle API. E.g.

```gradle
dependencies {
  api(project(":cpp-subproject"))
  api(project(":swift-subproject"))
}

```

Thank in advance for any advise.

* * *

For reference I tried to depend on the task `project(":swift-subproject").tasks.named("linkRelease")` but gradle is not happy because it doesn’t find the `linkRelease` task.

And I didn’t yet look at getting the cpp library yet.
