Home > Blockchain >  Gradle: exclude build.gradle.kts in a subdirectory
Gradle: exclude build.gradle.kts in a subdirectory

Time:11-01

Is there a way to tell Gradle

"Hey, there's a build.gradle.kts in the directory some/subdir, but please act like it's not there and don't try to mess with it at all"?

I have to keep a non-Android Kotlin project in an Android repository with a build.gradle.kts-file in the repository root for ... reasons ... and it keeps breaking my build due to plugin version conflicts.

The hierarchy layout is as follows:

|-- build.gradle.kts
|-- settings.gradle.kts
|-- src/
    |-- android_project_a/
        |-- build.gradle.kts
    |-- android_project_b/
        |-- build.gradle.kts
|-- kotlin_project/
    |-- build.gradle.kts // This is what I need to exclude

CodePudding user response:

If you are using command line to build, You can execute subdir as following

gradle build -x kotlin_project:build

But this is not a nice way to have it done, I wanted to check your build.gradle and setting.gradle, As you can change that once and for all, If you change the sub-projects and implementation of your sub-projects.

This kotlin_project should be a part of your setting.gradle as its being build automatically when you trigger root dir build.

You can exclude it if you want, But you have to remove it as well from dependencies at your build.gradle

  • Related