com.android.ide.common.blame.parser.ToolOutputParser Java Examples

The following examples show how to use com.android.ide.common.blame.parser.ToolOutputParser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AtlasDexMerger.java    From atlas with Apache License 2.0 6 votes vote down vote up
public AtlasDexMerger(DexingType dexingType, FileCollection mainDexListFile, ErrorReporter errorReporter, DexMergerTool dexMerger, int minSdkVersion, boolean isDebuggable, AppVariantOutputContext appVariantOutputContext) {
    this.dexingType = dexingType;
    this.mainDexListFile = mainDexListFile;
    this.dexMerger = dexMerger;
    this.minSdkVersion = minSdkVersion;
    this.isDebuggable = isDebuggable;
    this.logger= LoggerWrapper.getLogger(getClass());
    Preconditions.checkState(
            (dexingType == DexingType.LEGACY_MULTIDEX) == (mainDexListFile != null),
            "Main dex list must only be set when in legacy multidex");
    this.errorReporter = errorReporter;
    this.variantOutputContext = appVariantOutputContext;
     outputHandler =
            new ParsingProcessOutputHandler(
                    new ToolOutputParser(new DexParser(), Message.Kind.ERROR, logger),
                    new ToolOutputParser(new DexParser(), logger),
                    errorReporter);

}
 
Example #2
Source File: ProcessAwbAndroidResources.java    From atlas with Apache License 2.0 6 votes vote down vote up
private Aapt makeAapt() throws IOException {
    AndroidBuilder builder = getBuilder();
    MergingLog mergingLog = new MergingLog(getMergeBlameLogFolder());
    FileCache fileCache = appVariantContext.getScope().getGlobalScope().getBuildCache();
    ProcessOutputHandler processOutputHandler =
            new ParsingProcessOutputHandler(
                    new ToolOutputParser(
                            aaptGeneration == AaptGeneration.AAPT_V1
                                    ? new AaptOutputParser()
                                    : new Aapt2OutputParser(),
                            getILogger()),
                    new MergingLogRewriter(mergingLog::find, builder.getErrorReporter()));

    return AaptGradleFactory.make(
            aaptGeneration,
            builder,
            processOutputHandler,
            fileCache,
            true,
            FileUtils.mkdirs(new File(getIncrementalFolder(), "awb-aapt-temp/"+awbBundle.getName())),
            aaptOptions.getCruncherProcesses());
}
 
Example #3
Source File: TPatchDiffResAPBuildTask.java    From atlas with Apache License 2.0 6 votes vote down vote up
private Aapt makeAapt(AaptGeneration aaptGeneration) throws IOException {
    AndroidBuilder builder = getBuilder();
    MergingLog mergingLog = new MergingLog(mergeBlameLogFolder);

    ProcessOutputHandler processOutputHandler =
            new ParsingProcessOutputHandler(
                    new ToolOutputParser(
                            aaptGeneration == AaptGeneration.AAPT_V1
                                    ? new AaptOutputParser()
                                    : new Aapt2OutputParser(),
                            getILogger()),
                    new MergingLogRewriter(mergingLog::find, builder.getErrorReporter()));

    return AaptGradleFactory.make(
            aaptGeneration,
            builder,
        processOutputHandler,
        fileCache,
        true,
        com.android.utils.FileUtils.mkdirs(new File(appVariantContext.getScope().getIncrementalDir(getName()),
            "aapt-temp")),
            aaptOptions.getCruncherProcesses());
}
 
Example #4
Source File: MergeResources.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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);
}
 
Example #5
Source File: MergeAwbResource.java    From atlas with Apache License 2.0 5 votes vote down vote up
@NonNull
private static Aapt makeAapt(
        @NonNull AaptGeneration aaptGeneration,
        @NonNull AndroidBuilder builder,
        @Nullable FileCache fileCache,
        boolean crunchPng,
        @NonNull VariantScope scope,
        @NonNull File intermediateDir,
        @Nullable MergingLog blameLog)
        throws IOException {
    return AaptGradleFactory.make(
            aaptGeneration,
            builder,
            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())),
            fileCache,
            crunchPng,
            intermediateDir,
            scope.getGlobalScope().getExtension().getAaptOptions().getCruncherProcesses());
}
 
Example #6
Source File: AtlasDexArchiveBuilderTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
private List<File> convertToDexArchive(
        @NonNull Context context,
        @NonNull QualifiedContent input,
        @NonNull TransformOutputProvider outputProvider,
        boolean isIncremental)
        throws Exception {

    logger.verbose("Dexing {}", input.getFile().getAbsolutePath());
    ImmutableList.Builder<File> dexArchives = ImmutableList.builder();
    for (int bucketId = 0; bucketId < NUMBER_OF_BUCKETS; bucketId++) {
        File preDexOutputFile = getPreDexFile(outputProvider, input, bucketId);
        if (input.getFile().isDirectory()) {
            File cachedVersion = cacheHandler.getCachedVersionIfPresent(input.getFile());
            dexArchives.add(preDexOutputFile);
            if (cachedVersion != null) {
                FileUtils.copyDirectoryContentToDirectory(cachedVersion, preDexOutputFile);
                return dexArchives.build();

            }
        }
        if (preDexOutputFile.isDirectory() && preDexOutputFile.exists()) {
            FileUtils.cleanOutputDir(preDexOutputFile);
        }else {
            FileUtils.deleteIfExists(preDexOutputFile);
        }
        AtlasDexArchiveBuilderTransform.DexConversionParameters parameters =
                new AtlasDexArchiveBuilderTransform.DexConversionParameters(
                        input,
                        preDexOutputFile,
                        NUMBER_OF_BUCKETS,
                        bucketId,
                        minSdkVersion,
                        dexOptions.getAdditionalParameters(),
                        inBufferSize,
                        outBufferSize,
                        dexer,
                        isDebuggable,
                        isIncremental,
                        false);

        if (useGradleWorkers) {
            context.getWorkerExecutor()
                    .submit(
                            DexArchiveBuilderTransform.DexConversionWorkAction.class,
                            configuration -> {
                                configuration.setIsolationMode(IsolationMode.NONE);
                                configuration.setParams(parameters);
                            });
        } else {
            executor.execute(
                    () -> {
                        ProcessOutputHandler outputHandler =
                                new ParsingProcessOutputHandler(
                                        new ToolOutputParser(
                                                new DexParser(), Message.Kind.ERROR, logger),
                                        new ToolOutputParser(new DexParser(), logger),
                                        errorReporter);
                        ProcessOutput output = null;
                        try (Closeable ignored = output = outputHandler.createOutput()) {
                            launchProcessing(
                                    parameters,
                                    output.getStandardOutput(),
                                    output.getErrorOutput());
                        } finally {
                            if (output != null) {
                                try {
                                    outputHandler.handleOutput(output);
                                } catch (ProcessException e) {
                                    // ignore this one
                                }
                            }
                        }
                        return null;
                    });
        }
    }
    List<File> files = dexArchives.build();
    return files;
}
 
Example #7
Source File: AtlasDexArchiveBuilderTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
private List<File> convertAwbToDexArchive(
        @NonNull Context context,
        @NonNull QualifiedContent input,
        @NonNull File outputProvider,
        boolean isIncremental,
        boolean awb)
        throws Exception {

    int count = 0;
    if (input.getFile().isFile()) {
         count = computerClassCount(input.getFile());
       
    }else if (input.getFile().isDirectory()){
        count = 1;
    }
    logger.verbose("Dexing {}", input.getFile().getAbsolutePath());

    ImmutableList.Builder<File> dexArchives = ImmutableList.builder();

    for (int bucketId = 0; bucketId < count; bucketId++) {
        File preDexOutputFile = getAwbPreDexFile(outputProvider, input, bucketId);
        if (input.getFile().isDirectory()) {
            File cachedVersion = cacheHandler.getCachedVersionIfPresent(input.getFile());
            dexArchives.add(preDexOutputFile);
            if (cachedVersion != null) {
                FileUtils.copyDirectoryContentToDirectory(cachedVersion, preDexOutputFile);
                return dexArchives.build();
            }
        }
        if (preDexOutputFile.isDirectory() && preDexOutputFile.exists()) {
            FileUtils.cleanOutputDir(preDexOutputFile);
        }else {
            FileUtils.deleteIfExists(preDexOutputFile);
        }
        AtlasDexArchiveBuilderTransform.DexConversionParameters parameters =
                new AtlasDexArchiveBuilderTransform.DexConversionParameters(
                        input,
                        preDexOutputFile,
                        NUMBER_OF_BUCKETS,
                        bucketId,
                        minSdkVersion,
                        dexOptions.getAdditionalParameters(),
                        inBufferSize,
                        outBufferSize,
                        dexer,
                        isDebuggable,
                        false,
                        awb);

        if (useGradleWorkers) {
            context.getWorkerExecutor()
                    .submit(
                            DexArchiveBuilderTransform.DexConversionWorkAction.class,
                            configuration -> {
                                configuration.setIsolationMode(IsolationMode.NONE);
                                configuration.setParams(parameters);
                            });
        } else {
            executor.execute(
                    () -> {
                        ProcessOutputHandler outputHandler =
                                new ParsingProcessOutputHandler(
                                        new ToolOutputParser(
                                                new DexParser(), Message.Kind.ERROR, logger),
                                        new ToolOutputParser(new DexParser(), logger),
                                        errorReporter);
                        ProcessOutput output = null;
                        try (Closeable ignored = output = outputHandler.createOutput()) {
                            launchProcessing(
                                    parameters,
                                    output.getStandardOutput(),
                                    output.getErrorOutput());
                        } finally {
                            if (output != null) {
                                try {
                                    outputHandler.handleOutput(output);
                                } catch (ProcessException e) {
                                    // ignore this one
                                }
                            }
                        }
                        return null;
                    });
        }
    }

   List<File>files =  dexArchives.build();
    return files;
}
 
Example #8
Source File: ParsingProcessOutputHandler.java    From javaide with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Create a ParsingProcessOutputHandler.
 *
 * @param errorToolOutputParser the {@link ToolOutputParser} to use for process output sent
 *                              to stderr,
 * @param stdoutToolOutputParser the ToolOutputParser to use for process output to sent to
 *                               stdout.
 * @param messageReceivers the message receivers to notify for each message,
 */
public ParsingProcessOutputHandler(
        @NonNull ToolOutputParser errorToolOutputParser,
        @NonNull ToolOutputParser stdoutToolOutputParser,
        @NonNull MessageReceiver... messageReceivers) {
    mErrorToolOutputParser = errorToolOutputParser;
    mStdoutToolOutputParser = stdoutToolOutputParser;
    mMessageReceivers = ImmutableList.copyOf(messageReceivers);
}
 
Example #9
Source File: ParsingProcessOutputHandler.java    From javaide with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create a ParsingProcessOutputHandler.
 *
 * @param toolOutputParser the {@link ToolOutputParser} to use for process output sent to
 *                         stderr and stdout,
 * @param messageReceivers the message receivers to notify for each message,
 */
public ParsingProcessOutputHandler(
        @NonNull ToolOutputParser toolOutputParser,
        @NonNull MessageReceiver... messageReceivers) {
    this(toolOutputParser, toolOutputParser, messageReceivers);
}