Search in sources :

Example 1 with GradleJavaProcessExecutor

use of com.android.build.gradle.internal.process.GradleJavaProcessExecutor in project atlas by alibaba.

the class TransformReplacer method replaceDexTransform.

public void replaceDexTransform(AppVariantContext appVariantContext, BaseVariantOutput vod) {
    List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(variantContext, DexTransform.class);
    DefaultDexOptions dexOptions = appVariantContext.getAppExtension().getDexOptions();
    DexingType dexingType = appVariantContext.getScope().getDexingType();
    DexByteCodeConverterHook dexByteCodeConverterHook = new DexByteCodeConverterHook(variantContext, variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), LoggerWrapper.getLogger(DexByteCodeConverterHook.class), appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getTargetInfo(), new GradleJavaProcessExecutor(appVariantContext.getProject()), appVariantContext.getProject().getLogger().isEnabled(LogLevel.INFO), new ExtraModelInfo(appVariantContext.getScope().getGlobalScope().getProjectOptions(), appVariantContext.getProject().getLogger()));
    for (TransformTask transformTask : baseTransforms) {
        DexTransform newTransform = new DexTransform(dexOptions, dexingType, false, appVariantContext.getProject().files(variantContext.getScope().getMainDexListFile()), verifyNotNull(appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getTargetInfo(), "Target Info not set."), dexByteCodeConverterHook, appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter(), variantContext.getScope().getMinSdkVersion().getFeatureLevel());
        ReflectUtils.updateField(transformTask, "transform", newTransform);
    }
}
Also used : DexingType(com.android.builder.dexing.DexingType) ExtraModelInfo(com.android.build.gradle.internal.ExtraModelInfo) DexByteCodeConverterHook(com.taobao.android.builder.hook.dex.DexByteCodeConverterHook) TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) DefaultDexOptions(com.android.builder.core.DefaultDexOptions) GradleJavaProcessExecutor(com.android.build.gradle.internal.process.GradleJavaProcessExecutor)

Example 2 with GradleJavaProcessExecutor

use of com.android.build.gradle.internal.process.GradleJavaProcessExecutor in project atlas by alibaba.

the class AtlasConfigurationHelper method createBuilderAfterEvaluate.

public void createBuilderAfterEvaluate() throws Exception {
    AndroidBuilder androidBuilder = appPluginHook.getAndroidBuilder();
    if (null == androidBuilder) {
        return;
    }
    AndroidBuilder atlasBuilder = new AtlasBuilder(project.equals(project.getRootProject()) ? project.getName() : project.getPath(), creator, new GradleProcessExecutor(project), new GradleJavaProcessExecutor(project), DefaultGroovyMethods.asType(ReflectUtils.getField(androidBuilder, "mErrorReporter"), ErrorReporter.class), LoggerWrapper.getLogger(AtlasBuilder.class), DefaultGroovyMethods.asType(ReflectUtils.getField(androidBuilder, "mVerboseExec"), Boolean.class));
    ((AtlasBuilder) atlasBuilder).setDefaultBuilder(androidBuilder);
    ((AtlasBuilder) atlasBuilder).setAtlasExtension(atlasExtension);
    AtlasBuildContext.androidBuilderMap.put(project, (AtlasBuilder) (atlasBuilder));
}
Also used : ErrorReporter(com.android.builder.core.ErrorReporter) GradleProcessExecutor(com.android.build.gradle.internal.process.GradleProcessExecutor) AndroidBuilder(com.android.builder.core.AndroidBuilder) AtlasBuilder(com.android.builder.core.AtlasBuilder) GradleJavaProcessExecutor(com.android.build.gradle.internal.process.GradleJavaProcessExecutor)

Example 3 with GradleJavaProcessExecutor

use of com.android.build.gradle.internal.process.GradleJavaProcessExecutor in project atlas by alibaba.

the class BasePlugin method configureProject.

protected void configureProject() {
    extraModelInfo = new ExtraModelInfo(project, isLibrary());
    checkGradleVersion();
    sdkHandler = new SdkHandler(project, getLogger());
    project.afterEvaluate(p -> {
        if (!p.getGradle().getStartParameter().isOffline() && AndroidGradleOptions.getUseSdkDownload(p)) {
            SdkLibData sdkLibData = SdkLibData.download(getDownloader(), getSettingsController());
            dependencyManager.setSdkLibData(sdkLibData);
            sdkHandler.setSdkLibData(sdkLibData);
        }
    });
    androidBuilder = new AndroidBuilder(project == project.getRootProject() ? project.getName() : project.getPath(), creator, new GradleProcessExecutor(project), new GradleJavaProcessExecutor(project), extraModelInfo, getLogger(), isVerbose());
    dataBindingBuilder = new DataBindingBuilder();
    dataBindingBuilder.setPrintMachineReadableOutput(extraModelInfo.getErrorFormatMode() == ExtraModelInfo.ErrorFormatMode.MACHINE_PARSABLE);
    project.getPlugins().apply(JavaBasePlugin.class);
    jacocoPlugin = project.getPlugins().apply(JacocoPlugin.class);
    project.getTasks().getByName("assemble").setDescription("Assembles all variants of all applications and secondary packages.");
    // call back on execution. This is called after the whole build is done (not
    // after the current project is done).
    // This is will be called for each (android) projects though, so this should support
    // being called 2+ times.
    project.getGradle().addBuildListener(new BuildListener() {

        private final LibraryCache libraryCache = LibraryCache.getCache();

        @Override
        public void buildStarted(Gradle gradle) {
        }

        @Override
        public void settingsEvaluated(Settings settings) {
        }

        @Override
        public void projectsLoaded(Gradle gradle) {
        }

        @Override
        public void projectsEvaluated(Gradle gradle) {
        }

        @Override
        public void buildFinished(BuildResult buildResult) {
            ExecutorSingleton.shutdown();
            sdkHandler.unload();
            ThreadRecorder.get().record(ExecutionType.BASE_PLUGIN_BUILD_FINISHED, project.getPath(), null, new Recorder.Block() {

                @Override
                public Void call() throws Exception {
                    PreDexCache.getCache().clear(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/dex-cache/cache.xml"), getLogger());
                    JackConversionCache.getCache().clear(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/jack-cache/cache.xml"), getLogger());
                    libraryCache.unload();
                    Main.clearInternTables();
                    return null;
                }
            });
        }
    });
    project.getGradle().getTaskGraph().addTaskExecutionGraphListener(new TaskExecutionGraphListener() {

        @Override
        public void graphPopulated(TaskExecutionGraph taskGraph) {
            for (Task task : taskGraph.getAllTasks()) {
                if (task instanceof TransformTask) {
                    Transform transform = ((TransformTask) task).getTransform();
                    if (transform instanceof DexTransform) {
                        PreDexCache.getCache().load(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/dex-cache/cache.xml"));
                        break;
                    } else if (transform instanceof JackPreDexTransform) {
                        JackConversionCache.getCache().load(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/jack-cache/cache.xml"));
                        break;
                    }
                }
            }
        }
    });
}
Also used : TaskExecutionGraphListener(org.gradle.api.execution.TaskExecutionGraphListener) SdkLibData(com.android.builder.sdk.SdkLibData) TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) Task(org.gradle.api.Task) JackPreDexTransform(com.android.build.gradle.tasks.JackPreDexTransform) JacocoPlugin(com.android.build.gradle.internal.coverage.JacocoPlugin) DataBindingBuilder(android.databinding.tool.DataBindingBuilder) BuildListener(org.gradle.BuildListener) BuildResult(org.gradle.BuildResult) ExtraModelInfo(com.android.build.gradle.internal.ExtraModelInfo) GradleProcessExecutor(com.android.build.gradle.internal.process.GradleProcessExecutor) LibraryCache(com.android.build.gradle.internal.LibraryCache) AndroidBuilder(com.android.builder.core.AndroidBuilder) TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) Gradle(org.gradle.api.invocation.Gradle) SdkHandler(com.android.build.gradle.internal.SdkHandler) Transform(com.android.build.api.transform.Transform) DexTransform(com.android.build.gradle.internal.transforms.DexTransform) JackPreDexTransform(com.android.build.gradle.tasks.JackPreDexTransform) File(java.io.File) TaskExecutionGraph(org.gradle.api.execution.TaskExecutionGraph) DexTransform(com.android.build.gradle.internal.transforms.DexTransform) JackPreDexTransform(com.android.build.gradle.tasks.JackPreDexTransform) Settings(org.gradle.api.initialization.Settings) GradleJavaProcessExecutor(com.android.build.gradle.internal.process.GradleJavaProcessExecutor)

Aggregations

GradleJavaProcessExecutor (com.android.build.gradle.internal.process.GradleJavaProcessExecutor)3 ExtraModelInfo (com.android.build.gradle.internal.ExtraModelInfo)2 TransformTask (com.android.build.gradle.internal.pipeline.TransformTask)2 GradleProcessExecutor (com.android.build.gradle.internal.process.GradleProcessExecutor)2 AndroidBuilder (com.android.builder.core.AndroidBuilder)2 DataBindingBuilder (android.databinding.tool.DataBindingBuilder)1 Transform (com.android.build.api.transform.Transform)1 LibraryCache (com.android.build.gradle.internal.LibraryCache)1 SdkHandler (com.android.build.gradle.internal.SdkHandler)1 JacocoPlugin (com.android.build.gradle.internal.coverage.JacocoPlugin)1 DexTransform (com.android.build.gradle.internal.transforms.DexTransform)1 JackPreDexTransform (com.android.build.gradle.tasks.JackPreDexTransform)1 AtlasBuilder (com.android.builder.core.AtlasBuilder)1 DefaultDexOptions (com.android.builder.core.DefaultDexOptions)1 ErrorReporter (com.android.builder.core.ErrorReporter)1 DexingType (com.android.builder.dexing.DexingType)1 SdkLibData (com.android.builder.sdk.SdkLibData)1 DexByteCodeConverterHook (com.taobao.android.builder.hook.dex.DexByteCodeConverterHook)1 File (java.io.File)1 BuildListener (org.gradle.BuildListener)1