gradle其他模块
实际开发中有用的案例:
android {
compileSdkVersion 27
defaultConfig {
}
buildTypes {
}
sourceSets {
main {
//修改so库存放位置
jniLibs.srcDirs = ['libs']
}
}
sourceSets {
main {
//让res-ad,res-player成为和res一样的资源文件夹
res.srcDirs = ['src/main/res',
'res/main/res-ad',
'res/main/res-player']
}
}
}
this.android.sourceSets{
main {
//让res-ad,res-player成为和res一样的资源文件夹
res.srcDirs = ['src/main/res',
'res/main/res-ad',
'res/main/res-player']
}
}
public interface AndroidSourceSet
public interface AndroidSourceSet {
String getName();
AndroidSourceDirectorySet getResources();
AndroidSourceSet resources(Closure configureClosure);
AndroidSourceDirectorySet getJava();
AndroidSourceSet java(Closure configureClosure);
String getCompileConfigurationName();
String getPackageConfigurationName();
String getProvidedConfigurationName();
String getApiConfigurationName();
String getCompileOnlyConfigurationName();
String getImplementationConfigurationName();
...
/**
* Returns the name of this source set.
*
* @return The name. Never returns null.
*/
@NonNull
String getName();
/**
* Returns the Java resources which are to be copied into the javaResources output directory.
*
* @return the java resources. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getResources();
/**
* Configures the Java resources for this set.
*
* The given closure is used to configure the {@link AndroidSourceDirectorySet} which
* contains the java resources.
*
* @param configureClosure The closure to use to configure the javaResources.
* @return this
*/
@NonNull
AndroidSourceSet resources(Closure configureClosure);
/**
* Returns the Java source which is to be compiled by the Java compiler into the class output
* directory.
*
* @return the Java source. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getJava();
/**
* Configures the Java source for this set.
*
*
The given closure is used to configure the {@link AndroidSourceDirectorySet} which
* contains the Java source.
*
* @param configureClosure The closure to use to configure the Java source.
* @return this
*/
@NonNull
AndroidSourceSet java(Closure configureClosure);
/**
* Returns the name of the compile configuration for this source set.
*
* @deprecated use {@link #getImplementationConfigurationName()}
*/
@NonNull
@Deprecated
String getCompileConfigurationName();
/**
* Returns the name of the runtime configuration for this source set.
*
* @deprecated use {@link #getRuntimeOnlyConfigurationName()}
*/
@NonNull
@Deprecated
String getPackageConfigurationName();
/**
* Returns the name of the compiled-only configuration for this source set.
*
* @deprecated use {@link #getCompileOnlyConfigurationName()}
*/
@NonNull
@Deprecated
String getProvidedConfigurationName();
/** Returns the name of the api configuration for this source set. */
@NonNull
String getApiConfigurationName();
/**
* Returns the name of the compileOnly configuration for this source set.
*/
@NonNull
String getCompileOnlyConfigurationName();
/**
* Returns the name of the implemenation configuration for this source set.
*/
@NonNull
String getImplementationConfigurationName();
/**
* Returns the name of the implemenation configuration for this source set.
*/
@NonNull
String getRuntimeOnlyConfigurationName();
/**
* Returns the name of the wearApp configuration for this source set.
*/
@NonNull
String getWearAppConfigurationName();
/**
* Returns the name of the annotation processing tool classpath for this source set.
*/
@NonNull
String getAnnotationProcessorConfigurationName();
/**
* The Android Manifest file for this source set.
*
* @return the manifest. Never returns null.
*/
@NonNull
AndroidSourceFile getManifest();
/**
* Configures the location of the Android Manifest for this set.
*
*
The given closure is used to configure the {@link AndroidSourceFile} which contains the
* manifest.
*
* @param configureClosure The closure to use to configure the Android Manifest.
* @return this
*/
@NonNull
AndroidSourceSet manifest(Closure configureClosure);
/**
* The Android Resources directory for this source set.
*
* @return the resources. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getRes();
/**
* Configures the location of the Android Resources for this set.
*
*
The given closure is used to configure the {@link AndroidSourceDirectorySet}
* which contains the resources.
*
* @param configureClosure The closure to use to configure the Resources.
* @return this
*/
@NonNull
AndroidSourceSet res(Closure configureClosure);
/**
* The Android Assets directory for this source set.
*
* @return the assets. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getAssets();
/**
* Configures the location of the Android Assets for this set.
*
*
The given closure is used to configure the {@link AndroidSourceDirectorySet}
* which contains the assets.
*
* @param configureClosure The closure to use to configure the Assets.
* @return this
*/
@NonNull
AndroidSourceSet assets(Closure configureClosure);
/**
* The Android AIDL source directory for this source set.
*
* @return the source. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getAidl();
/**
* Configures the location of the Android AIDL source for this set.
*
*
The given closure is used to configure the {@link AndroidSourceDirectorySet}
* which contains the AIDL source.
*
* @param configureClosure The closure to use to configure the AIDL source.
* @return this
*/
@NonNull
AndroidSourceSet aidl(Closure configureClosure);
/**
* The Android RenderScript source directory for this source set.
*
* @return the source. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getRenderscript();
/**
* Configures the location of the Android RenderScript source for this set.
*
*
The given closure is used to configure the {@link AndroidSourceDirectorySet}
* which contains the Renderscript source.
*
* @param configureClosure The closure to use to configure the Renderscript source.
* @return this
*/
@NonNull
AndroidSourceSet renderscript(Closure configureClosure);
/**
* The Android JNI source directory for this source set.
*
* @return the source. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getJni();
/**
* Configures the location of the Android JNI source for this set.
*
*
The given closure is used to configure the {@link AndroidSourceDirectorySet}
* which contains the JNI source.
*
* @param configureClosure The closure to use to configure the JNI source.
* @return this
*/
@NonNull
AndroidSourceSet jni(Closure configureClosure);
/**
* The Android JNI libs directory for this source set.
*
* @return the libs. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getJniLibs();
/**
* Configures the location of the Android JNI libs for this set.
*
*
The given closure is used to configure the {@link AndroidSourceDirectorySet}
* which contains the JNI libs.
*
* @param configureClosure The closure to use to configure the JNI libs.
* @return this
*/
@NonNull
AndroidSourceSet jniLibs(Closure configureClosure);
/**
* The Android shaders directory for this source set.
*
* @return the shaders. Never returns null.
*/
@NonNull
AndroidSourceDirectorySet getShaders();
/**
* Configures the location of the Android shaders for this set.
*
*
The given closure is used to configure the {@link AndroidSourceDirectorySet}
* which contains the shaders.
*
* @param configureClosure The closure to use to configure the shaders.
* @return this
*/
@NonNull
AndroidSourceSet shaders(Closure configureClosure);
/**
* Sets the root of the source sets to a given path.
*
* All entries of the source set are located under this root directory.
*
* @param path the root directory.
* @return this
*/
@NonNull
AndroidSourceSet setRoot(String path);
}