Search in sources :

Example 1 with InstantRunBuildContext

use of com.android.build.gradle.internal.incremental.InstantRunBuildContext in project atlas by alibaba.

the class AwoPackageConfigAction method execute.

@Override
public void execute(PackageApplication packageApp) {
    final GradleVariantConfiguration config = scope.getVariantConfiguration();
    packageApp.setAndroidBuilder(scope.getGlobalScope().getAndroidBuilder());
    packageApp.setVariantName(scope.getVariantConfiguration().getFullName());
    packageApp.setMinSdkVersion(config.getMinSdkVersion());
    setFieldValueByReflection(packageApp, "dexPackagingPolicy", DexPackagingPolicy.STANDARD);
    setFieldValueByReflection(packageApp, "instantRunContext", new InstantRunBuildContext());
    ConventionMappingHelper.map(packageApp, "resourceFile", new Callable<File>() {

        @Override
        public File call() {
            return libVariantContext.getOutputResouceAP();
        }
    });
    ConventionMappingHelper.map(packageApp, "dexFolders", new Callable<Set<File>>() {

        @Override
        public Set<File> call() {
            File outFolder = libVariantContext.getDexFolder();
            Set<File> folders = Sets.newHashSet();
            folders.add(outFolder);
            return folders;
        }
    });
    ConventionMappingHelper.map(packageApp, "javaResourceFiles", new Callable<Set<File>>() {

        @Override
        public Set<File> call() throws Exception {
            return Collections.<File>emptySet();
        }
    });
    // TODO: 增加abiFilter的支持
    ConventionMappingHelper.map(packageApp, "jniFolders", new Callable<Set<File>>() {

        @Override
        public Set<File> call() {
            File jniFolder = awbBundle.getJniFolder();
            Set<File> folders = Sets.newHashSet();
            folders.add(jniFolder);
            return folders;
        }
    });
    ConventionMappingHelper.map(packageApp, "abiFilters", new Callable<Set<String>>() {

        @Override
        public Set<String> call() throws Exception {
            Set<String> supportedAbis = config.getSupportedAbis();
            if (supportedAbis != null) {
                return supportedAbis;
            }
            return ImmutableSet.of("armeabi", "x86");
        }
    });
    ConventionMappingHelper.map(packageApp, "jniDebugBuild", new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            return config.getBuildType().isJniDebuggable();
        }
    });
    ConventionMappingHelper.map(packageApp, "packagingOptions", new Callable<PackagingOptions>() {

        @Override
        public PackagingOptions call() throws Exception {
            return scope.getGlobalScope().getExtension().getPackagingOptions();
        }
    });
    ConventionMappingHelper.map(packageApp, "outputFile", new Callable<File>() {

        @Override
        public File call() throws Exception {
            return libVariantContext.getPackageFile();
        }
    });
    //setFieldValueByReflection(packageApp, "markerFile",
    //        PrePackageApplication.ConfigAction.getMarkerFile(scope));
    setFieldValueByReflection(packageApp, "inOldMode", AndroidGradleOptions.useOldPackaging(scope.getGlobalScope().getProject()));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) GradleVariantConfiguration(com.android.build.gradle.internal.core.GradleVariantConfiguration) InstantRunBuildContext(com.android.build.gradle.internal.incremental.InstantRunBuildContext) StopExecutionException(org.gradle.api.tasks.StopExecutionException) PackagingOptions(com.android.build.gradle.internal.dsl.PackagingOptions) File(java.io.File)

Aggregations

GradleVariantConfiguration (com.android.build.gradle.internal.core.GradleVariantConfiguration)1 PackagingOptions (com.android.build.gradle.internal.dsl.PackagingOptions)1 InstantRunBuildContext (com.android.build.gradle.internal.incremental.InstantRunBuildContext)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 File (java.io.File)1 Set (java.util.Set)1 StopExecutionException (org.gradle.api.tasks.StopExecutionException)1