@Override public void execute(MergeResources mergeResourcesTask) { final BaseVariantData<? extends BaseVariantOutputData> variantData = scope.getVariantData(); mergeResourcesTask.setAndroidBuilder(scope.getGlobalScope().getAndroidBuilder()); mergeResourcesTask.setIncrementalFolder( new File( scope.getGlobalScope().getBuildDir() + "/" + AndroidProject.FD_INTERMEDIATES + "/incremental/" + taskNamePrefix + "Resources" + variantData.getVariantConfiguration().getDirName())); mergeResourcesTask.process9Patch = process9Patch; mergeResourcesTask.crunchPng = scope.getGlobalScope().getExtension().getAaptOptions().getCruncherEnabled(); mergeResourcesTask.normalizeResources = scope .getGlobalScope() .getExtension() .getBuildToolsRevision() .compareTo(NORMALIZE_RESOURCES_BUILD_TOOLS) < 0; ConventionMappingHelper.map( mergeResourcesTask, "useNewCruncher", new Callable<Boolean>() { @Override public Boolean call() throws Exception { return scope.getGlobalScope().getExtension().getAaptOptions().getUseNewCruncher(); } }); ConventionMappingHelper.map( mergeResourcesTask, "inputResourceSets", new Callable<List<ResourceSet>>() { @Override public List<ResourceSet> call() throws Exception { List<File> generatedResFolders = Lists.newArrayList( scope.getRenderscriptResOutputDir(), scope.getGeneratedResOutputDir()); if (variantData.getExtraGeneratedResFolders() != null) { generatedResFolders.addAll(variantData.getExtraGeneratedResFolders()); } if (variantData.generateApkDataTask != null && variantData.getVariantConfiguration().getBuildType().isEmbedMicroApp()) { generatedResFolders.add(variantData.generateApkDataTask.getResOutputDir()); } return variantData .getVariantConfiguration() .getResourceSets(generatedResFolders, includeDependencies); } }); ConventionMappingHelper.map( mergeResourcesTask, "outputDir", new Callable<File>() { @Override public File call() throws Exception { return outputLocation != null ? outputLocation : scope.getDefaultMergeResourcesOutputDir(); } }); variantData.mergeResourcesTask = mergeResourcesTask; }
@Override public void execute(@NonNull final AndroidJavaCompile javacTask) { final BaseVariantData testedVariantData = scope.getTestedVariantData(); scope.getVariantData().javacTask = javacTask; javacTask.mBuildContext = scope.getInstantRunBuildContext(); javacTask.setSource(scope.getVariantData().getJavaSources()); ConventionMappingHelper.map( javacTask, "classpath", new Callable<FileCollection>() { @Override public FileCollection call() { FileCollection classpath = scope.getJavaClasspath(); Project project = scope.getGlobalScope().getProject(); if (testedVariantData != null) { // For libraries, the classpath from androidBuilder includes the library // output (bundle/classes.jar) as a normal dependency. In unit tests we // don't want to package the jar at every run, so we use the *.class // files instead. if (!testedVariantData.getType().equals(LIBRARY) || scope.getVariantData().getType().equals(UNIT_TEST)) { classpath = classpath.plus( project.files( testedVariantData.getScope().getJavaClasspath(), testedVariantData.getScope().getJavaOutputDir(), testedVariantData.getScope().getJavaDependencyCache())); } if (scope.getVariantData().getType().equals(UNIT_TEST) && testedVariantData.getType().equals(LIBRARY)) { // The bundled classes.jar may exist, but it's probably old. Don't // use it, we already have the *.class files in the classpath. LibraryDependency libraryDependency = testedVariantData.getVariantConfiguration().getOutput(); if (libraryDependency != null) { File jarFile = libraryDependency.getJarFile(); classpath = classpath.minus(project.files(jarFile)); } } } return classpath; } }); javacTask.setDestinationDir(scope.getJavaOutputDir()); javacTask.setDependencyCacheDir(scope.getJavaDependencyCache()); CompileOptions compileOptions = scope.getGlobalScope().getExtension().getCompileOptions(); AbstractCompilesUtil.configureLanguageLevel( javacTask, compileOptions, scope.getGlobalScope().getExtension().getCompileSdkVersion()); javacTask.getOptions().setEncoding(compileOptions.getEncoding()); javacTask .getOptions() .setBootClasspath( Joiner.on(File.pathSeparator) .join(scope.getGlobalScope().getAndroidBuilder().getBootClasspathAsStrings(false))); }