config.getLintOptions()); AaptOptions aaptOptions = AaptOptionsImpl.create(config.getAaptOptions()); List<String> flavorDimensionList = config.getFlavorDimensionList() != null ? config.getFlavorDimensionList() : Lists.newArrayList(); bootClasspath, frameworkSource, cloneSigningConfigs(config.getSigningConfigs()), aaptOptions, artifactMetaDataList, findUnresolvedDependencies(syncIssues), syncIssues, config.getCompileOptions(), lintOptions, project.getBuildDir(), config.getResourcePrefix(), ImmutableList.copyOf(toolchains.values()), config.getBuildToolsVersion(), projectType, Version.BUILDER_MODEL_API_VERSION,
int minSdk = variantData.getVariantConfiguration().getMinSdkVersion().getApiLevel(); if (extension.getPreprocessingOptions().getPreprocessResources() && minSdk < PreprocessResourcesTask.MIN_SDK) { checkArgument(extension.getBuildToolsRevision().compareTo( MergeResources.NORMALIZE_RESOURCES_BUILD_TOOLS) >= 0, "To preprocess resources, you have to use build tools >= %1$s",
@NonNull public File getMockableAndroidJarFile() { if (mockableAndroidJarFile == null) { // Since the file ends up in $rootProject.buildDir, it will survive clean // operations - projects generated by AS don't have a top-level clean task that // would delete the top-level build directory. This means that the name has to // encode all the necessary information, otherwise the task will be UP-TO-DATE // even if the file should be regenerated. That's why we put the SDK version and // "default-values" in there, so if one project uses the returnDefaultValues flag, // it will just generate a new file and not change the semantics for other // sub-projects. There's an implicit "v1" there as well, if we ever change the // generator logic, the names will have to be changed. String fileExt; if (getExtension().getTestOptions().getUnitTests().isReturnDefaultValues()) { fileExt = ".default-values.jar"; } else { fileExt = ".jar"; } File outDir = new File( getProject().getRootProject().getBuildDir(), AndroidProject.FD_GENERATED); CharMatcher safeCharacters = CharMatcher.JAVA_LETTER_OR_DIGIT.or(CharMatcher.anyOf("-.")); String sdkName = safeCharacters.negate().replaceFrom( getExtension().getCompileSdkVersion(), '-'); mockableAndroidJarFile = new File(outDir, "mockable-" + sdkName + fileExt); } return mockableAndroidJarFile; }
public VariantManager( @NonNull Project project, @NonNull AndroidBuilder androidBuilder, @NonNull AndroidConfig extension, @NonNull VariantFactory variantFactory, @NonNull TaskManager taskManager, @NonNull Instantiator instantiator) { this.extension = extension; this.androidBuilder = androidBuilder; this.project = project; this.variantFactory = variantFactory; this.taskManager = taskManager; this.instantiator = instantiator; DefaultAndroidSourceSet mainSourceSet = (DefaultAndroidSourceSet) extension.getSourceSets().getByName(extension.getDefaultConfig().getName()); DefaultAndroidSourceSet androidTestSourceSet = null; DefaultAndroidSourceSet unitTestSourceSet = null; if (variantFactory.hasTestScope()) { androidTestSourceSet = (DefaultAndroidSourceSet) extension.getSourceSets() .getByName(ANDROID_TEST.getPrefix()); unitTestSourceSet = (DefaultAndroidSourceSet) extension.getSourceSets() .getByName(UNIT_TEST.getPrefix()); } defaultConfigData = new ProductFlavorData<CoreProductFlavor>( extension.getDefaultConfig(), mainSourceSet, androidTestSourceSet, unitTestSourceSet, project); signingOverride = createSigningOverride(); }
if (globalScope.getExtension().getPublishNonDefault() || !variantName.equals(globalScope.getExtension().getDefaultPublishConfig())) { leaf = variantName; } else {
options.setJavaMaxHeapSize(globalScope.getExtension().getDexOptions().getJavaMaxHeapSize()); options.setJumboMode(globalScope.getExtension().getDexOptions().getJumboMode()); boolean isDebuggable = scope.getVariantConfiguration().getBuildType().isDebuggable(); options.setDebuggable(isDebuggable); options.setJackPluginNames(config.getJackOptions().getPluginNames()); CompileOptions compileOptions = scope.getGlobalScope().getExtension().getCompileOptions(); scope.getGlobalScope().getExtension().getCompileSdkVersion(), true /*jackEnabled*/); options.setSourceCompatibility(compileOptions.getSourceCompatibility().toString());
if (getExtension().getDefaultPublishConfig().equals(outputName)) { appTask.configure(tasks, new Action<Task>() { @Override if (getExtension().getPublishNonDefault()) { appTask.configure(tasks, new Action<Task>() { @Override if (getExtension().getLintOptions().isCheckReleaseBuilds()) { createLintVitalTask(variantData);
extension.getVariantFilter(); ignore = !extension.getPublishNonDefault() && !variantFilter.getName().equals(extension.getDefaultPublishConfig()); } else if (projectMatch) {
CompileOptions compileOptions = scope.getGlobalScope().getExtension().getCompileOptions(); scope.getGlobalScope().getExtension().getCompileSdkVersion() );
@Override public AaptOptions call() throws Exception { return getExtension().getAaptOptions(); } });
@Override public void execute(JillTask jillTask) { final GlobalScope globalScope = variantScope.getGlobalScope(); final AndroidBuilder androidBuilder = globalScope.getAndroidBuilder(); jillTask.setAndroidBuilder(androidBuilder); jillTask.setDexOptions(globalScope.getExtension().getDexOptions()); ConventionMappingHelper.map(jillTask, "inputLibs", new Callable<Set<File>>() { @Override public Set<File> call() throws Exception { return androidBuilder.getPackagedJars(variantScope.getVariantConfiguration()); } }); jillTask.setOutputFolder(variantScope.getJillPackagedLibrariesDir()); } }
@Override public void execute(UninstallTask uninstallTask) { uninstallTask.setDescription( "Uninstalls the " + scope.getVariantData().getDescription() + "."); uninstallTask.setGroup(TaskManager.INSTALL_GROUP); uninstallTask.setVariant(scope.getVariantData()); uninstallTask.setAndroidBuilder(scope.getGlobalScope().getAndroidBuilder()); uninstallTask.setTimeOutInMs( scope.getGlobalScope().getExtension().getAdbOptions().getTimeOutInMs()); ConventionMappingHelper.map(uninstallTask, "adbExe", new Callable<File>() { @Override public File call() throws Exception { final SdkInfo info = scope.getGlobalScope().getSdkHandler().getSdkInfo(); return (info == null ? null : info.getAdb()); } }); ((ApkVariantData) scope.getVariantData()).uninstallTask = uninstallTask; } }
mergeResourcesTask.crunchPng = scope.getGlobalScope().getExtension().getAaptOptions() .getCruncherEnabled(); mergeResourcesTask.normalizeResources = scope.getGlobalScope().getExtension().getBuildToolsRevision() .compareTo(NORMALIZE_RESOURCES_BUILD_TOOLS) < 0;
this.scope.getGlobalScope().getExtension().getSplits().getAbiFilters()); packageSplitAbiTask.setInputFiles(this.scope.getSplitAbiResOutputFiles()); packageSplitAbiTask.setSplits(filters); scope.getGlobalScope().getExtension().getAaptOptions(); packageSplitAbiTask.manifest = variantOutputScope.getManifestOutputFile();
testVariantData.getScope(), new ConnectedDeviceProvider(sdkHandler.getSdkInfo().getAdb(), globalScope.getExtension().getAdbOptions().getTimeOutInMs(), new LoggerWrapper(logger)), testData)); List<DeviceProvider> providers = getExtension().getDeviceProviders(); List<TestServer> servers = getExtension().getTestServers(); for (final TestServer testServer : servers) { final AndroidTask<TestServerTask> serverTask = androidTasks.create(
.getGlobalScope() .getExtension() .getCompileOptions() .getTargetCompatibility() .isJava8Compatible()) { .getSplitHandlingPolicy() .equals(SplitHandlingPolicy.RELEASE_21_AND_AFTER_POLICY)) { if (getExtension().getBuildToolsRevision().getMajor() < 21) { throw new RuntimeException( "Pure splits can only be used with buildtools 21 and later");
"classes/" + variantData.getVariantConfiguration().getDirName()); task.setSource(variantData.getJavaSources()); task.encoding = getExtension().getCompileOptions().getEncoding(); task.setSourceCompatibility( getExtension().getCompileOptions().getSourceCompatibility().toString()); ConventionMappingHelper.map(task, "classpath", new Callable<ConfigurableFileCollection>() { @Override
variantData.generateRClassTask = processResources; processResources.enforceUniquePackageName = scope.getGlobalScope().getExtension() .getEnforceUniquePackageName(); processResources.setAaptOptions(scope.getGlobalScope().getExtension().getAaptOptions()); processResources .setPseudoLocalesEnabled(config.getBuildType().isPseudoLocalesEnabled());
createVariantDataForProductFlavors(Collections.<ProductFlavor>emptyList()); } else { List<String> flavorDimensionList = extension.getFlavorDimensionList();
public void createMockableJarTask() { createMockableJar = project.getTasks().create("mockableAndroidJar", MockableAndroidJarTask.class); createMockableJar.setGroup(BUILD_GROUP); createMockableJar.setDescription( "Creates a version of android.jar that's suitable for unit tests."); ConventionMappingHelper.map(createMockableJar, "androidJar", new Callable<File>() { @Override public File call() throws Exception { return new File(androidBuilder.getTarget().getPath(IAndroidTarget.ANDROID_JAR)); } }); CharMatcher safeCharacters = CharMatcher.JAVA_LETTER_OR_DIGIT.or(CharMatcher.anyOf("-.")); String sdkName = safeCharacters.negate().replaceFrom(extension.getCompileSdkVersion(), '-'); createMockableJar.setOutputFile( new File(globalScope.getIntermediatesDir(), "mockable-" + sdkName + ".jar")); ConventionMappingHelper.map(createMockableJar, "returnDefaultValues", new Callable<Boolean>() { @Override public Boolean call() { return extension.getTestOptions().getUnitTests().isReturnDefaultValues(); } }); }