문제

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