public static DefaultDexOptions copyOf(DexOptions dexOptions) { DefaultDexOptions result = new DefaultDexOptions(); result.setPreDexLibraries(dexOptions.getPreDexLibraries()); result.setJumboMode(dexOptions.getJumboMode()); result.setDexInProcess(dexOptions.getDexInProcess()); result.setThreadCount(dexOptions.getThreadCount()); result.setJavaMaxHeapSize(dexOptions.getJavaMaxHeapSize()); result.setAdditionalParameters(dexOptions.getAdditionalParameters()); result.setMaxProcessCount(dexOptions.getMaxProcessCount()); result.setKeepRuntimeAnnotatedClasses( dexOptions.getKeepRuntimeAnnotatedClasses()); return result; }
@NonNull @Override public Map<String, Object> getParameterInputs() { try { // ATTENTION: if you add something here, consider adding the value to DexKey - it needs // to be saved if affects how dx is invoked. Map<String, Object> params = Maps.newHashMapWithExpectedSize(4); params.put("optimize", true); params.put("predex", dexOptions.getPreDexLibraries()); params.put("jumbo", dexOptions.getJumboMode()); params.put("multidex", multiDex); params.put("multidex-legacy", multiDex && mainDexListFile != null); params.put("java-max-heap-size", dexOptions.getJavaMaxHeapSize()); params.put( "additional-parameters", Iterables.toString(dexOptions.getAdditionalParameters())); TargetInfo targetInfo = androidBuilder.getTargetInfo(); Preconditions.checkState(targetInfo != null, "androidBuilder.targetInfo required for task '%s'.", getName()); BuildToolInfo buildTools = targetInfo.getBuildTools(); params.put("build-tools", buildTools.getRevision().toString()); return params; } catch (Exception e) { throw new RuntimeException(e); } }
return mIsDexInProcess; if (!dexOptions.getDexInProcess()) { mIsDexInProcess = false; return false; if (dexOptions.getJavaMaxHeapSize() != null) { Optional<Long> heapSize = parseSizeToBytes(dexOptions.getJavaMaxHeapSize()); if (heapSize.isPresent()) { requestedHeapSize = heapSize.get(); mLogger.warning( "Unable to parse dex options size parameter '%1$s', assuming %2$s bytes.", dexOptions.getJavaMaxHeapSize(), DEFAULT_DEX_HEAP_SIZE); requestedHeapSize = DEFAULT_DEX_HEAP_SIZE; if (dexOptions.getJavaMaxHeapSize() != null) { dexOptionsComment = String.format( " (based on the dexOptions.javaMaxHeapSize = %s)", dexOptions.getJavaMaxHeapSize());
builder.setMain("com.android.dx.command.Main"); if (dexOptions.getJavaMaxHeapSize() != null) { builder.addJvmArg("-Xmx" + dexOptions.getJavaMaxHeapSize()); } else { builder.addJvmArg("-Xmx1024M"); if (dexOptions.getJumboMode()) { builder.addArgs("--force-jumbo"); Integer threadCount = dexOptions.getThreadCount(); if (threadCount == null) { builder.addArgs("--num-threads=4"); for (String arg : dexOptions.getAdditionalParameters()) { builder.addArgs(arg);
builder.setMain("com.android.dx.command.Main"); if (dexOptions.getJavaMaxHeapSize() != null) { builder.addJvmArg("-Xmx" + dexOptions.getJavaMaxHeapSize()); } else { builder.addJvmArg("-Xmx1024M"); if (dexOptions.getJumboMode()) { builder.addArgs("--force-jumbo"); Integer threadCount = dexOptions.getThreadCount(); if (threadCount == null) { builder.addArgs("--num-threads=4");
args.numThreads = Objects.firstNonNull(dexOptions.getThreadCount(), 4); args.forceJumbo = dexOptions.getJumboMode(); args.parseFlags(Iterables.toArray(dexOptions.getAdditionalParameters(), String.class)); args.makeOptionsObjects(dxContext);
FileCacheInputParams.BUILD_TOOLS_REVISION.name(), buildToolsRevision.toString()) .putBoolean(FileCacheInputParams.JUMBO_MODE.name(), dexOptions.getJumboMode()) .putBoolean(FileCacheInputParams.OPTIMIZE.name(), true) .putBoolean(FileCacheInputParams.MULTI_DEX.name(), multiDex); List<String> additionalParams = dexOptions.getAdditionalParameters(); for (int i = 0; i < additionalParams.size(); i++) { buildCacheInputs.putString(
logger.verbose("DirInputs %s", Joiner.on(",").join(directoryInputs)); if (!dexOptions.getKeepRuntimeAnnotatedClasses() && mainDexListFile == null) { logger.info("DexOptions.keepRuntimeAnnotatedClasses has no affect in native multidex."); || !dexOptions.getPreDexLibraries()) {
inputFile, buildToolInfo.getRevision(), dexOptions.getJumboMode());
builder.setMain("com.android.jill.Main"); if (dexOptions.getJavaMaxHeapSize() != null) { builder.addJvmArg("-Xmx" + dexOptions.getJavaMaxHeapSize());
@NonNull @Override public Collection<File> getSecondaryDirectoryOutputs() { // we use the intermediate folder only if // - there's per-scope dexing // - there's no native multi-dex if (dexOptions.getPreDexLibraries() && !(multiDex && mainDexListFile == null)) { return ImmutableList.of(intermediateFolder); } return ImmutableList.of(); }
public void runDexer( @NonNull final DexProcessBuilder builder, @NonNull final DexOptions dexOptions, @NonNull final ProcessOutputHandler processOutputHandler) throws ProcessException, IOException, InterruptedException { initDexExecutorService(dexOptions); if (dexOptions.getAdditionalParameters().contains("--no-optimize")) { mLogger.warning(DefaultDexOptions.OPTIMIZE_WARNING); } if (shouldDexInProcess(dexOptions)) { dexInProcess(builder, dexOptions, processOutputHandler); } else { dexOutOfProcess(builder, dexOptions, processOutputHandler); } }
private void initDexExecutorService(@NonNull DexOptions dexOptions) { synchronized (LOCK_FOR_DEX) { if (sDexExecutorService == null) { if (dexOptions.getMaxProcessCount() != null) { DEX_PROCESS_COUNT.set(dexOptions.getMaxProcessCount()); } mLogger.verbose( "Allocated dexExecutorService of size %1$d.", DEX_PROCESS_COUNT.get()); sDexExecutorService = Executors.newFixedThreadPool(DEX_PROCESS_COUNT.get()); } else { // check whether our executor service has the same number of max processes as // this module requests, and print a warning if necessary. if (dexOptions.getMaxProcessCount() != null && dexOptions.getMaxProcessCount() != DEX_PROCESS_COUNT.get()) { mLogger.warning( "dexOptions is specifying a maximum number of %1$d concurrent dx processes," + " but the Gradle daemon was initialized with %2$d.\n" + "To initialize with a different maximum value," + " first stop the Gradle daemon by calling ‘gradlew —-stop’.", dexOptions.getMaxProcessCount(), DEX_PROCESS_COUNT.get()); } } } }
inputFile, builder.getTargetInfo().getBuildTools().getRevision(), dexOptions.getJumboMode(), optimize, dexOptions.getAdditionalParameters(), multiDex);