Gradle exclude module for Copy task

前端 未结 2 1535
误落风尘
误落风尘 2021-01-23 04:00

I have a Copy task set as follow:

task copyToLib( type: Copy ) {
   into \"$buildDir/myapp/lib\"
   from configurations.runtime

   // We only want jars files to         


        
2条回答
  •  孤街浪徒
    2021-01-23 04:11

    Exclude by group: exclude group: org.slf4j

    Exclude by module: exclude module: slf4j-api

    Exclude by file name: exclude { it.file.name.contains('slf4j-api') }

    Exclude a file: exclude "slf4j-api.jar"

    You can exclude by group and module but it needs to go into configurations exclude like this. Then it's gonna restrict the configuration before copying.

    task copyToLib( type: Copy ) {
        into "$buildDir/myapp/lib"
        from configurations.runtime {
            exclude group: 'org.slf4j'
        }
    
        // We only want jars files to go in lib folder
        exclude "*.exe"
        exclude "*.bat"
        exclude "*.cmd"
        exclude "*.dll"
    
    }
    

    And remember to make sure that the directory exists $buildDir/myapp/lib

    And maybe instead of excluding all other files just include jars?

提交回复
热议问题