Gradle 1.2: Exclude directory under resources sourceSets

前端 未结 3 828
一个人的身影
一个人的身影 2020-12-01 21:23

I have development related directory src/main/resources/certs/test which is needed for one external library. This has some cert files which are not needed in pr

相关标签:
3条回答
  • 2020-12-01 21:48

    A common projet layout is to put test files under the test source set, this way you don't have to exclude them from the main source set.

    From the Gradle documentation, the default project layout is like this:

    src/main/java       Production Java source
    src/main/resources  Production resources
    src/test/java       Test Java source
    src/test/resources  Test resources
    
    0 讨论(0)
  • 2020-12-01 21:51

    Using Gradle 1.1, this works for me:

    apply plugin: 'war'
    
    sourceSets {
        main {
            resources {
                exclude '**/test/*'
                exclude 'certs/test'
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-01 22:09

    I had a similar problem with production files in a JAR file (though mine were not test files). I solved it with the following:

    jar {
        exclude ("DIRECTORY-TO-EXCLUDE/**")
    }
    

    e.g.

    jar {
        exclude ("test/**")
    }
    
    0 讨论(0)
提交回复
热议问题