Gradle: How to exclude a particular package from a jar?

后端 未结 3 438
甜味超标
甜味超标 2020-12-01 12:56

We have a package that is related to some requirements that were removed, but we don\'t want to necessarily delete the code because there\'s a possibility it will be needed

3条回答
  •  不思量自难忘°
    2020-12-01 13:18

    In 2018:

    You may also use a closure or Spec to specify which files to include or exclude. The closure or Spec is passed a FileTreeElement, and must return a boolean value.

    jar {
      exclude {
        FileSystems.getDefault()
          .getPathMatcher("glob:com/ourcompany/someotherpackage/polling/**")
          .matches(it.file.toPath())
      }
    }
    

    See Jar.exclude, FileTreeElement and Finding Files.

提交回复
热议问题