Search in sources :

Example 1 with AaptOptions

use of com.android.build.gradle.internal.dsl.AaptOptions in project atlas by alibaba.

the class AtlasBuilder method processResources.

@Override
public void processResources(Aapt aapt, Builder aaptConfigBuilder, boolean enforceUniquePackageName) throws IOException, InterruptedException, ProcessException {
    if (aapt instanceof AaptV1) {
        try {
            getTargetInfo();
            AaptOptions aaptOptions = (AaptOptions) FieldUtils.readField(aaptConfigBuilder.build(), "mAaptOptions", true);
            ProcessExecutor processExecutor = (ProcessExecutor) FieldUtils.readField(aapt, "mProcessExecutor", true);
            ProcessOutputHandler processOutputHandler = (ProcessOutputHandler) FieldUtils.readField(aapt, "mProcessOutputHandler", true);
            BuildToolInfo buildToolInfo = (BuildToolInfo) FieldUtils.readField(aapt, "mBuildToolInfo", true);
            PngProcessMode processMode = (PngProcessMode) FieldUtils.readField(aapt, "mProcessMode", true);
            int cruncherProcesses = aaptOptions.getCruncherProcesses();
            aapt = new AtlasAapt(processExecutor, processOutputHandler, buildToolInfo, getLogger(), processMode, cruncherProcesses);
        } catch (Throwable e) {
            throw new GradleException("aapt exception", e);
        }
    }
    super.processResources(aapt, aaptConfigBuilder, enforceUniquePackageName);
}
Also used : ProcessOutputHandler(com.android.ide.common.process.ProcessOutputHandler) PngProcessMode(com.android.builder.internal.aapt.v1.AaptV1.PngProcessMode) BuildToolInfo(com.android.sdklib.BuildToolInfo) AaptOptions(com.android.build.gradle.internal.dsl.AaptOptions) GradleException(org.gradle.api.GradleException) AaptV1(com.android.builder.internal.aapt.v1.AaptV1) ProcessExecutor(com.android.ide.common.process.ProcessExecutor) JavaProcessExecutor(com.android.ide.common.process.JavaProcessExecutor)

Example 2 with AaptOptions

use of com.android.build.gradle.internal.dsl.AaptOptions in project atlas by alibaba.

the class PrepareAaptTask method doExecute.

//MergeResources mergeResources;
@TaskAction
public void doExecute() {
    AaptOptions aaptOptions = processAndroidResources.getAaptOptions();
    if (null == aaptOptions) {
        aaptOptions = new AaptOptions();
    }
    if (null == aaptOptions.getAdditionalParameters()) {
        aaptOptions.setAdditionalParameters(new ArrayList<String>());
    }
    if (!appVariantContext.getAtlasExtension().getTBuildConfig().getAaptConstantId()) {
        aaptOptions.getAdditionalParameters().add("--non-constant-id");
    }
    processAndroidResources.setAndroidBuilder(getBuilder());
    processAndroidResources.setAaptOptions(aaptOptions);
    ApContext apContext = appVariantContext.apContext;
    if (null != apContext && apContext.getBaseApk().exists()) {
        File baseApk = appVariantContext.apContext.getBaseApk();
        //需要增加-b参数
        if (!aaptOptions.getAdditionalParameters().contains("-B")) {
            aaptOptions.getAdditionalParameters().add("-B");
            aaptOptions.getAdditionalParameters().add(baseApk.getAbsolutePath());
        }
    //AndroidManifest文件不能有修改OR在patch的时候忽略,目前选择在patch的时候忽略
    }
//TODO update merge resource
//mergeResources.setAndroidBuilder(AtlasBuildContext.androidBuilder);
}
Also used : ApContext(com.android.build.gradle.internal.api.ApContext) AaptOptions(com.android.build.gradle.internal.dsl.AaptOptions) File(java.io.File) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

AaptOptions (com.android.build.gradle.internal.dsl.AaptOptions)2 ApContext (com.android.build.gradle.internal.api.ApContext)1 AaptV1 (com.android.builder.internal.aapt.v1.AaptV1)1 PngProcessMode (com.android.builder.internal.aapt.v1.AaptV1.PngProcessMode)1 JavaProcessExecutor (com.android.ide.common.process.JavaProcessExecutor)1 ProcessExecutor (com.android.ide.common.process.ProcessExecutor)1 ProcessOutputHandler (com.android.ide.common.process.ProcessOutputHandler)1 BuildToolInfo (com.android.sdklib.BuildToolInfo)1 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)1 File (java.io.File)1 GradleException (org.gradle.api.GradleException)1 TaskAction (org.gradle.api.tasks.TaskAction)1