Search in sources :

Example 1 with MergedResourceWriter

use of com.android.ide.common.res2.MergedResourceWriter in project buck by facebook.

the class MergeAndroidResourceSourcesStep method execute.

@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
    ResourceMerger merger = new ResourceMerger(1);
    try {
        for (Path resPath : resPaths) {
            Preconditions.checkState(resPath.isAbsolute());
            ResourceSet set = new ResourceSet(resPath.toString(), true);
            set.setDontNormalizeQualifiers(true);
            set.addSource(resPath.toFile());
            set.loadFromFiles(new ResourcesSetLoadLogger(context.getBuckEventBus()));
            merger.addDataSet(set);
        }
        MergedResourceWriter writer = MergedResourceWriter.createWriterWithoutPngCruncher(outFolderPath.toFile(), null, /*publicFile*/
        null, /*blameLogFolder*/
        new NoOpResourcePreprocessor(), tmpFolderPath.toFile());
        merger.mergeData(writer, /* cleanUp */
        false);
    } catch (MergingException e) {
        LOG.error(e, "Failed merging resources.");
        return StepExecutionResult.ERROR;
    }
    return StepExecutionResult.SUCCESS;
}
Also used : Path(java.nio.file.Path) MergedResourceWriter(com.android.ide.common.res2.MergedResourceWriter) MergingException(com.android.ide.common.res2.MergingException) ResourceMerger(com.android.ide.common.res2.ResourceMerger) ResourceSet(com.android.ide.common.res2.ResourceSet) NoOpResourcePreprocessor(com.android.ide.common.res2.NoOpResourcePreprocessor)

Aggregations

MergedResourceWriter (com.android.ide.common.res2.MergedResourceWriter)1 MergingException (com.android.ide.common.res2.MergingException)1 NoOpResourcePreprocessor (com.android.ide.common.res2.NoOpResourcePreprocessor)1 ResourceMerger (com.android.ide.common.res2.ResourceMerger)1 ResourceSet (com.android.ide.common.res2.ResourceSet)1 Path (java.nio.file.Path)1