@Override public List<File> call() throws Exception { return androidBuilder.getBootClasspath(); } });
/** * Log low level diagnostic information. */ void diagnostic(String format, Object... args) { androidBuilder.getLogger().verbose( "External native generate JSON " + variantName + ": " + format, args); }
public void manifestMergerV2() throws MojoExecutionException, MojoFailureException AndroidBuilder builder = new AndroidBuilder( project.toString(), "created by Android Maven Plugin", new DefaultProcessExecutor( logger ), new DefaultJavaProcessExecutor( logger ), builder.mergeManifestsForApplication(
protected BuildToolInfo getBuildTools() { return androidBuilder.getTargetInfo().getBuildTools(); }
private void runJack(@NonNull TransformInvocation transformInvocation) throws ProcessException, IOException, JackToolchain.ToolchainException, ClassNotFoundException { TransformOutputProvider outputProvider = transformInvocation.getOutputProvider(); checkNotNull(outputProvider); final File outDirectory = outputProvider.getContentLocation( "main", getOutputTypes(), getScopes(), Format.DIRECTORY); options.setDexOutputDirectory(outDirectory); options.setClasspaths( TransformInputUtil.getAllFiles(transformInvocation.getReferencedInputs())); options.setImportFiles(TransformInputUtil.getAllFiles(transformInvocation.getInputs())); options.setInputFiles(getSourceFiles()); JackToolchain toolchain = new JackToolchain( androidBuilder.getTargetInfo().getBuildTools(), androidBuilder.getLogger(), androidBuilder.getErrorReporter()); toolchain.convert(options, androidBuilder.getJavaProcessExecutor(), jackInProcess); }
@NonNull File intermediateDir, int cruncherProcesses) { TargetInfo target = builder.getTargetInfo(); Preconditions.checkNotNull(target, "target == null"); BuildToolInfo buildTools = target.getBuildTools(); new TeeProcessOutputHandler( outputHandler, new LoggedProcessOutputHandler(new FilteringLogger(builder.getLogger()))); builder.getProcessExecutor(), teeOutputHandler, buildTools, intermediateDir, new FilteringLogger(builder.getLogger())); } else { AaptV1.PngProcessMode processMode; builder.getProcessExecutor(), teeOutputHandler, buildTools, new FilteringLogger(builder.getLogger()), processMode, cruncherProcesses);
private static Pair<Dependency, DependencyNode> handleRenderscriptSupport( @NonNull VariantConfiguration variantConfiguration, @NonNull AndroidBuilder androidBuilder) { if (variantConfiguration.getRenderscriptSupportModeEnabled()) { File supportJar = androidBuilder.getRenderScriptSupportJar(); if (supportJar != null) { return sRSCache.get(Pair.of( supportJar, androidBuilder.getTargetInfo().getBuildTools().getRevision().toString())); } } return null; } }
/** * Returns the list of packaged jars for this config. If the config tests a library, this * will include the jars of the tested config * * If the SDK was loaded, this may include the renderscript support jar. * * @return a non null, but possibly empty list. */ @NonNull public Set<File> getAdditionalPackagedJars(@NonNull VariantConfiguration<?,?,?> variantConfiguration) { if (variantConfiguration.getRenderscriptSupportModeEnabled()) { File renderScriptSupportJar = getRenderScriptSupportJar(); if (renderScriptSupportJar != null) { return ImmutableSet.of(renderScriptSupportJar); } } return ImmutableSet.of(); }
private static Aapt makeAapt( BuildToolInfo buildToolInfo, AaptGeneration aaptGeneration, AndroidBuilder builder, boolean crunchPng, MergingLog blameLog) { ProcessOutputHandler teeOutputHandler = new TeeProcessOutputHandler( blameLog != null ? new ParsingProcessOutputHandler( new ToolOutputParser( aaptGeneration == AaptGeneration.AAPT_V1 ? new AaptOutputParser() : new Aapt2OutputParser(), builder.getLogger()), new MergingLogRewriter(blameLog::find, builder.getErrorReporter())) : new LoggedProcessOutputHandler( new AaptGradleFactory.FilteringLogger(builder.getLogger())), new LoggedProcessOutputHandler(new AaptGradleFactory.FilteringLogger(builder.getLogger()))); return new AaptV1( builder.getProcessExecutor(), teeOutputHandler, buildToolInfo, new AaptGradleFactory.FilteringLogger(builder.getLogger()), crunchPng ? AaptV1.PngProcessMode.ALL : AaptV1.PngProcessMode.NO_CRUNCH, 0); }
private ApkInfoParser.ApkInfo loadTestedApkInfo() { File aaptFile = new File(androidBuilder.getTargetInfo().getBuildTools() .getPath(BuildToolInfo.PathId.AAPT)); ApkInfoParser apkInfoParser = new ApkInfoParser(aaptFile, androidBuilder.getProcessExecutor()); try { return apkInfoParser.parseApk(getMainApk()); } catch (ProcessException e) { throw new RuntimeException(e); } }
IAndroidTarget target = getBuilder().getTarget(); if (!target.isPlatform()) { target = target.getParent(); ProcessOutputHandler handler = new LoggedProcessOutputHandler(getBuilder().getLogger()); getBuilder().executeProcess(builder.createProcess(), handler) .rethrowFailure().assertNormalExitValue();
throws IOException, ProcessException, InterruptedException { checkState(!multiDex || outFile.isDirectory()); checkState(builder.getTargetInfo() != null); builder.getTargetInfo().getBuildTools().getRevision(), dexOptions.getJumboMode(), optimize, multiDex); ILogger logger = builder.getLogger(); logger.verbose("preDexLibrary : %1$s", itemKey); Pair<Item, Boolean> pair = getItem(logger, itemKey); try { List<File> files = builder.preDexLibraryNoCache( inputFile, outFile,
Joiner.on(File.pathSeparator).join( scope.getGlobalScope().getAndroidBuilder() .getBootClasspathAsStrings(false))); scope.getGlobalScope() .getAndroidBuilder() .getBootClasspath(false))); .resolveAndGetAnnotationProcessorClassPath( annotationProcessorOptions.getIncludeCompileClasspath(), scope.getGlobalScope().getAndroidBuilder().getErrorReporter()));
JackPreDexTransform.builder() .buildToolInfo(androidBuilder::getBuildToolInfo) .errorReporter(androidBuilder.getErrorReporter()) .javaProcessExecutor(androidBuilder.getJavaProcessExecutor()) .javaMaxHeapSize( globalScope.getExtension().getDexOptions().getJavaMaxHeapSize()) .bootClasspath(() -> androidBuilder.getBootClasspath(true)) .buildToolInfo(androidBuilder::getBuildToolInfo) .errorReporter(androidBuilder.getErrorReporter()) .javaProcessExecutor(androidBuilder.getJavaProcessExecutor()) .javaMaxHeapSize( globalScope.getExtension().getDexOptions().getJavaMaxHeapSize())
checkNotNull(outFile, "outFile cannot be null."); checkNotNull(dexOptions, "dexOptions cannot be null."); getLogger().verbose("AndroidBuilder::preDexLibraryNoCache %1$s", inputFile.getAbsolutePath()); if (!checkLibraryClassesJar(inputFile)) { return ImmutableList.of(); .addInput(inputFile); getDexByteCodeConverter().runDexer(builder, dexOptions, processOutputHandler);
/** * Execute an external process and log the result in the case of a process exceptions. * Returns the info part of the log so that it can be parsed by ndk-build parser; * @throws BuildCommandException when the build failed. */ @NonNull public static String executeBuildProcessAndLogError( @NonNull AndroidBuilder androidBuilder, @NonNull ProcessInfoBuilder process, boolean logStdioToInfo) throws BuildCommandException, IOException { ProgressiveLoggingProcessOutputHandler handler = new ProgressiveLoggingProcessOutputHandler(androidBuilder.getLogger(), logStdioToInfo); try { // Log the command to execute but only in verbose (ie --info) androidBuilder.getLogger().verbose(process.toString()); androidBuilder.executeProcess(process.createProcess(), handler) .rethrowFailure().assertNormalExitValue(); return handler.getStandardOutputString(); } catch (ProcessException e) { // Also, add process output to the process exception so that it can be analyzed by // caller. Use combined stderr stdout instead of just stdout because compiler errors // go to stdout. String combinedMessage = String.format("%s\n%s", e.getMessage(), handler.getCombinedOutputString()); throw new BuildCommandException(combinedMessage); } }
task.setDeviceProvider(deviceProvider); task.setInstallOptions(scope.getGlobalScope().getExtension().getAdbOptions().getInstallOptions()); task.setProcessExecutor(scope.getGlobalScope().getAndroidBuilder().getProcessExecutor());
"Cannot call preDexLibrary() before setTargetInfo() is called."); getLogger().verbose("AndroidBuilder::preDexLibrary %1$s", inputFile.getAbsolutePath()); if (inputFile.isFile()) { PreDexCache.getCache().preDexLibrary( processOutputHandler); } else { preDexLibraryNoCache( inputFile, outFile, multiDex, dexOptions, processOutputHandler);
FileUtils.mkdirs(to); androidBuilder.preDexLibrary(from, to, multiDex, dexOptions, outputHandler); return null; }; getBuildCacheInputs( from, androidBuilder.getTargetInfo().getBuildTools().getRevision(), dexOptions, multiDex);
new AndroidBuilder( project.getPath(), "Android Studio + external build system", false); androidBuilder.setTargetInfo(targetInfo); return androidBuilder;