use of org.gradle.api.file.FileCollection in project atlas by alibaba.
the class AwoJavaCompileConfigAction method execute.
/**
* Awb的编译,暂不支持instantRun
*
* @param javacTask
*/
@Override
public void execute(JavaCompile javacTask) {
// libVariantContext.setJavacTask(javacTask);
javacTask.setSource(libVariantContext.getSourceOutputDir());
ConventionMappingHelper.map(javacTask, "classpath", new Callable<FileCollection>() {
@Override
public FileCollection call() {
FileCollection classpath = scope.getJavaClasspath();
return classpath;
}
});
javacTask.setDestinationDir(libVariantContext.getJavaCDir());
javacTask.setDependencyCacheDir(new File(scope.getGlobalScope().getIntermediatesDir(), "/awb-dependency-cache/" + scope.getVariantConfiguration().getFullName() + "/" + awbBundle.getName()));
CompileOptions compileOptions = scope.getGlobalScope().getExtension().getCompileOptions();
AbstractCompilesUtil.configureLanguageLevel(javacTask, compileOptions, scope.getGlobalScope().getExtension().getCompileSdkVersion(), false);
javacTask.getOptions().setEncoding(compileOptions.getEncoding());
javacTask.getOptions().setBootClasspath(Joiner.on(File.pathSeparator).join(scope.getGlobalScope().getAndroidBuilder().getBootClasspathAsStrings(false)));
GlobalScope globalScope = scope.getGlobalScope();
Project project = globalScope.getProject();
boolean incremental;
if (compileOptions.getIncremental() != null) {
incremental = compileOptions.getIncremental();
} else {
// if (globalScope.getExtension().getDataBinding().isEnabled()
// || project.getPlugins().hasPlugin("com.neenbedankt.android-apt")
// || project.getPlugins().hasPlugin("me.tatarka.retrolambda")) {
// incremental = false;
// } else {
// For now, default to false, irrespective of Instant Run.
incremental = false;
// }
}
if (AndroidGradleOptions.isJavaCompileIncrementalPropertySet(project)) {
scope.getGlobalScope().getAndroidBuilder().getErrorReporter().handleSyncError(null, SyncIssue.TYPE_GENERIC, String.format("The %s property has been replaced by a DSL property. Please add the " + "following to your build.gradle instead:\n" + "android {\n" + " compileOptions.incremental = false\n" + "}", AndroidGradleOptions.PROPERTY_INCREMENTAL_JAVA_COMPILE));
}
if (incremental) {
LOG.info("Using incremental javac compilation.");
} else {
LOG.info("Not using incremental javac compilation.");
}
javacTask.getOptions().setIncremental(incremental);
}
use of org.gradle.api.file.FileCollection in project atlas by alibaba.
the class AwbJavaCompileConfigAction method execute.
/**
* Awb的编译,暂不支持instantRun
*
* @param javacTask
*/
@Override
public void execute(JavaCompile javacTask) {
appVariantOutputContext.getAwbJavacTasks().put(awbBundle.getName(), javacTask);
ProcessAwbAndroidResources processAwbAndroidResources = appVariantOutputContext.getAwbAndroidResourcesMap().get(awbBundle.getName());
assert null != processAwbAndroidResources;
javacTask.source(processAwbAndroidResources.getSourceOutputDir());
if (scope.getGlobalScope().getExtension().getDataBinding().isEnabled()) {
javacTask.source(appVariantOutputContext.getVariantContext().getAwbClassOutputForDataBinding(awbBundle));
}
ConventionMappingHelper.map(javacTask, "classpath", new Callable<FileCollection>() {
@Override
public FileCollection call() {
FileCollection classpath = scope.getVariantScope().getJavaClasspath();
Set<File> dependencies = new HashSet<File>();
dependencies.addAll(classpath.getFiles());
//增加awb的依赖
dependencies.addAll(awbBundle.getLibraryJars());
FileCollection allClassPatch = appVariantOutputContext.getVariantContext().getProject().files(dependencies);
return allClassPatch;
}
});
javacTask.setDestinationDir(appVariantOutputContext.getJAwbavaOutputDir(awbBundle));
javacTask.setDependencyCacheDir(appVariantOutputContext.getAwbJavaDependencyCache(awbBundle));
CompileOptions compileOptions = scope.getGlobalScope().getExtension().getCompileOptions();
AbstractCompilesUtil.configureLanguageLevel(javacTask, compileOptions, scope.getGlobalScope().getExtension().getCompileSdkVersion(), false);
javacTask.getOptions().setEncoding(compileOptions.getEncoding());
javacTask.getOptions().setBootClasspath(Joiner.on(File.pathSeparator).join(scope.getGlobalScope().getAndroidBuilder().getBootClasspathAsStrings(false)));
GlobalScope globalScope = scope.getGlobalScope();
Project project = globalScope.getProject();
boolean incremental;
if (compileOptions.getIncremental() != null) {
incremental = compileOptions.getIncremental();
} else {
// if (globalScope.getExtension().getDataBinding().isEnabled()
// || project.getPlugins().hasPlugin("com.neenbedankt.android-apt")
// || project.getPlugins().hasPlugin("me.tatarka.retrolambda")) {
// incremental = false;
// } else {
// For now, default to false, irrespective of Instant Run.
incremental = false;
// }
}
if (AndroidGradleOptions.isJavaCompileIncrementalPropertySet(project)) {
scope.getGlobalScope().getAndroidBuilder().getErrorReporter().handleSyncError(null, SyncIssue.TYPE_GENERIC, String.format("The %s property has been replaced by a DSL property. Please add the " + "following to your build.gradle instead:\n" + "android {\n" + " compileOptions.incremental = false\n" + "}", AndroidGradleOptions.PROPERTY_INCREMENTAL_JAVA_COMPILE));
}
if (incremental) {
LOG.info("Using incremental javac compilation.");
} else {
LOG.info("Not using incremental javac compilation.");
}
javacTask.getOptions().setIncremental(incremental);
}
Aggregations