简体   繁体   中英

Is there a way to specify gradle source sets with a pattern?

I have the following structure in my project directory:

  • subfolder1/src/main/java/...
  • subfolder2/src/main/java/...
  • subfolder3/src/main/java/...
  • ...

Is there a way to tell gradle to look in any folder that matches "src/main/java" for the source directories? I'm trying the following, but it doesn't work:

sourceSets {
    main {
        java {
            srcDir '**/src/main/java'
        }
    }
}

Whilst this is completely whacky, you can likely use a FileTree for this.

sourceSets {
    main {
        java {
            srcDirs fileTree(projectDir).matching {
                include '**/src/main/java'
            }
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM