Search in sources :

Example 1 with MergingLog

use of com.android.ide.common.blame.MergingLog in project atlas by alibaba.

the class AwbXmlProcessor method getLayoutXmlProcessor.

public static LayoutXmlProcessor getLayoutXmlProcessor(AppVariantContext appVariantContext, AwbBundle awbBundle, DataBindingBuilder dataBindingBuilder) {
    File resourceBlameLogDir = appVariantContext.getAwbBlameLogFolder(awbBundle);
    //        if (!resourceBlameLogDir.exists()) {
    //            resourceBlameLogDir = appVariantContext.getScope().getResourceBlameLogDir();
    //        }
    final MergingLog mergingLog = new MergingLog(resourceBlameLogDir);
    LayoutXmlProcessor layoutXmlProcessor = new LayoutXmlProcessor(//                "com.taobao.demo2",
    appVariantContext.getVariantConfiguration().getOriginalApplicationId(), dataBindingBuilder.createJavaFileWriter(appVariantContext.getAwbClassOutputForDataBinding(awbBundle)), appVariantContext.getVariantConfiguration().getMinSdkVersion().getApiLevel(), false, //                appVariantContext.getVariantData().getType() == VariantType.LIBRARY,
    new LayoutXmlProcessor.OriginalFileLookup() {

        @Override
        public File getOriginalFileFor(File file) {
            SourceFile input = new SourceFile(file);
            SourceFile original = mergingLog.find(input);
            // it is not what we want so we alter the response.
            return original == input ? null : original.getSourceFile();
        }
    });
    return layoutXmlProcessor;
}
Also used : MergingLog(com.android.ide.common.blame.MergingLog) SourceFile(com.android.ide.common.blame.SourceFile) SourceFile(com.android.ide.common.blame.SourceFile) File(java.io.File) LayoutXmlProcessor(android.databinding.tool.LayoutXmlProcessor)

Example 2 with MergingLog

use of com.android.ide.common.blame.MergingLog in project atlas by alibaba.

the class TPatchDiffResAPBuildTask method doAction.

@TaskAction
protected void doAction() throws IOException {
    manifestFile = getManifestFile();
    aaptOptions = getAaptOptions();
    diffResDir = getDiffResDir();
    resourceConfigs = getResourceConfigs();
    preferredDensity = getPreferredDensity();
    //TODO  minifyManifest
    File miniManifest = new File(packageOutputFile.getParentFile(), "AndroidManifest.xml");
    try {
        ManifestFileUtils.minifyManifest(manifestFile, miniManifest);
    } catch (DocumentException e) {
        throw new GradleException(e.getMessage());
    }
    File assetsFolder = new File(diffResDir, "assets");
    File resFolder = new File(diffResDir, "res");
    if (!assetsFolder.exists()) {
        assetsFolder.mkdirs();
    }
    if (!resFolder.exists()) {
        resFolder.mkdirs();
    }
    AaptPackageProcessBuilder aaptPackageCommandBuilder = new AaptPackageProcessBuilder(miniManifest, aaptOptions).setAssetsFolder(assetsFolder).setResFolder(resFolder).setLibraries(libraries).setPackageForR(packageForR).setResPackageOutput(packageOutputFile.getAbsolutePath()).setType(type).setDebuggable(debuggable).setPseudoLocalesEnabled(pseudoLocalesEnabled).setResourceConfigs(resourceConfigs).setSplits(splits).setPreferredDensity(preferredDensity);
    @NonNull AndroidBuilder builder = getBuilder();
    MergingLog mergingLog = new MergingLog(mergeBlameLogFolder);
    ProcessOutputHandler processOutputHandler = new ParsingProcessOutputHandler(new ToolOutputParser(new AaptOutputParser(), getILogger()), new MergingLogRewriter(mergingLog, builder.getErrorReporter()));
    try {
        if (builder instanceof AtlasBuilder) {
            ((AtlasBuilder) builder).processResources(aaptPackageCommandBuilder, enforceUniquePackageName, processOutputHandler);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    } catch (ProcessException e) {
        throw new RuntimeException(e);
    }
}
Also used : ParsingProcessOutputHandler(com.android.ide.common.blame.ParsingProcessOutputHandler) ProcessOutputHandler(com.android.ide.common.process.ProcessOutputHandler) MergingLog(com.android.ide.common.blame.MergingLog) AaptOutputParser(com.android.ide.common.blame.parser.aapt.AaptOutputParser) IOException(java.io.IOException) MergingLogRewriter(com.android.ide.common.blame.MergingLogRewriter) ProcessException(com.android.ide.common.process.ProcessException) AaptPackageProcessBuilder(com.android.builder.core.AaptPackageProcessBuilder) ToolOutputParser(com.android.ide.common.blame.parser.ToolOutputParser) DocumentException(org.dom4j.DocumentException) GradleException(org.gradle.api.GradleException) NonNull(com.android.annotations.NonNull) AndroidBuilder(com.android.builder.core.AndroidBuilder) AtlasBuilder(com.android.builder.core.AtlasBuilder) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile) ParsingProcessOutputHandler(com.android.ide.common.blame.ParsingProcessOutputHandler) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

MergingLog (com.android.ide.common.blame.MergingLog)2 File (java.io.File)2 LayoutXmlProcessor (android.databinding.tool.LayoutXmlProcessor)1 NonNull (com.android.annotations.NonNull)1 AaptPackageProcessBuilder (com.android.builder.core.AaptPackageProcessBuilder)1 AndroidBuilder (com.android.builder.core.AndroidBuilder)1 AtlasBuilder (com.android.builder.core.AtlasBuilder)1 MergingLogRewriter (com.android.ide.common.blame.MergingLogRewriter)1 ParsingProcessOutputHandler (com.android.ide.common.blame.ParsingProcessOutputHandler)1 SourceFile (com.android.ide.common.blame.SourceFile)1 ToolOutputParser (com.android.ide.common.blame.parser.ToolOutputParser)1 AaptOutputParser (com.android.ide.common.blame.parser.aapt.AaptOutputParser)1 ProcessException (com.android.ide.common.process.ProcessException)1 ProcessOutputHandler (com.android.ide.common.process.ProcessOutputHandler)1 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)1 IOException (java.io.IOException)1 DocumentException (org.dom4j.DocumentException)1 GradleException (org.gradle.api.GradleException)1 InputFile (org.gradle.api.tasks.InputFile)1 TaskAction (org.gradle.api.tasks.TaskAction)1