Basically, I'm using an open-source library in my main project. The library is included by compile project('<path-to-lib>'). The trouble is, there're a lot of files/classes/resources which I don't really need. I only need a small subset of those. Instead of deleting redundant parts, is there any way for me to write Groovy/Gradle script to pick only essential parts for building? This way, ideally, I can make minimal changes to the library.

没有正确的解决方案

其他提示

In the build file for the library you can tailor the source sets to your needs. In general you write something like this:

apply plugin: 'java'

sourceSets {
  main {
    java {
      exclude 'some/unwanted/package/**'
    }
  }
}

I'm assuming this is a plain Java library. If it's an Android library, the android-library plugin also supports exclude syntax in source sets.

Here's a SO question for reference:

Android Studio Exclude Class from build?

You can also read the Gradle docs for source sets at http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.SourceSet.html#org.gradle.api.tasks.SourceSet:java(groovy.lang.Closure) and the Java plugin at http://www.gradle.org/docs/current/userguide/java_plugin.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top