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;
}
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);
}
}
Aggregations