Home > other >  How to build a gradle project without a specific subfolder?
How to build a gradle project without a specific subfolder?

Time:01-11

I have a Kotlin project in Gradle with 3 main folders: myorg.folder1, myorg.folder2, and myorg.folder3. Due to project constraints I cannot change this structure. As part of the project, I would like to have two different jar distributions: One containing all 3 folders, and one that only contains folder1 and folder2. The project has been set up so that these folders can operate independently of folder3 without errors. How can I do this?

CodePudding user response:

In order to do this, (following broot's advice, thanks), I was able to find that I needed to use a sourceSet to make this work.

sourceSets {
    noFolder3
        kotlin {
            exclude "myorg/folder3/**"
        }
    }
}

Then, I can build with all 3 folders using build, and without folder3 using build noFolder3.

One extra note is that since I was using Intellij IDEA, all of my code was stored in the directory src/main/kotlin, so I also added the following line inside the kotlin {} block:

srcDirs  = "src/main/kotlin"
  •  Tags:  
  • Related