Search in sources :

Example 1 with LoggingManager

use of org.gradle.api.logging.LoggingManager in project atlas by alibaba.

the class AtlasMultiDexListTransform method transform.

public void transform(@NonNull TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException {
    if (mainDexListFile.exists() && !variantScope.getVariantData().getName().toLowerCase().endsWith("release")) {
        return;
    }
    LoggingManager loggingManager = transformInvocation.getContext().getLogging();
    loggingManager.captureStandardOutput(LogLevel.INFO);
    loggingManager.captureStandardError(LogLevel.WARN);
    Collection<File> inputs = AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getAllMainDexJars();
    inputs.addAll(AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getInputDirs());
    if (AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()) == null) {
        super.transform(transformInvocation);
    } else if (AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()).multiDexer == null) {
        super.transform(transformInvocation);
    }
    FastMultiDexer fastMultiDexer = (FastMultiDexer) AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()).multiDexer;
    Collection<File> files = fastMultiDexer.repackageJarList(inputs, mainDexListFile, variantScope.getVariantData().getName().toLowerCase().endsWith("release"));
    if (files != null && files.size() > 0) {
        AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).addAllMainDexJars(files);
    }
}
Also used : FastMultiDexer(com.taobao.android.builder.tools.multidex.FastMultiDexer) LoggingManager(org.gradle.api.logging.LoggingManager) File(java.io.File)

Example 2 with LoggingManager

use of org.gradle.api.logging.LoggingManager in project gradle by gradle.

the class DefaultScript method init.

@Override
public void init(final Object target, ServiceRegistry services) {
    super.init(target, services);
    this.scriptServices = services;
    loggingManager = services.get(LoggingManager.class);
    if (target instanceof HasScriptServices) {
        HasScriptServices scriptServices = (HasScriptServices) target;
        fileOperations = scriptServices.getFileOperations();
        processOperations = scriptServices.getProcessOperations();
    } else {
        Instantiator instantiator = services.get(Instantiator.class);
        FileLookup fileLookup = services.get(FileLookup.class);
        FileCollectionFactory fileCollectionFactory = services.get(FileCollectionFactory.class);
        File sourceFile = getScriptSource().getResource().getLocation().getFile();
        if (sourceFile != null) {
            FileResolver resolver = fileLookup.getFileResolver(sourceFile.getParentFile());
            FileCollectionFactory fileCollectionFactoryWithBase = fileCollectionFactory.withResolver(resolver);
            fileOperations = DefaultFileOperations.createSimple(resolver, fileCollectionFactoryWithBase, services);
            processOperations = services.get(ExecFactory.class).forContext().withFileResolver(resolver).withFileCollectionFactory(fileCollectionFactoryWithBase).withInstantiator(instantiator).withObjectFactory(new InstantiatorBackedObjectFactory(instantiator)).build();
        } else {
            fileOperations = DefaultFileOperations.createSimple(fileLookup.getFileResolver(), fileCollectionFactory, services);
            processOperations = services.get(ExecFactory.class);
        }
    }
    providerFactory = services.get(ProviderFactory.class);
}
Also used : ExecFactory(org.gradle.process.internal.ExecFactory) InstantiatorBackedObjectFactory(org.gradle.api.internal.model.InstantiatorBackedObjectFactory) ProviderFactory(org.gradle.api.provider.ProviderFactory) LoggingManager(org.gradle.api.logging.LoggingManager) Instantiator(org.gradle.internal.reflect.Instantiator) FileResolver(org.gradle.api.internal.file.FileResolver) FileLookup(org.gradle.api.internal.file.FileLookup) File(java.io.File) HasScriptServices(org.gradle.api.internal.file.HasScriptServices) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory)

Aggregations

File (java.io.File)2 LoggingManager (org.gradle.api.logging.LoggingManager)2 FastMultiDexer (com.taobao.android.builder.tools.multidex.FastMultiDexer)1 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)1 FileLookup (org.gradle.api.internal.file.FileLookup)1 FileResolver (org.gradle.api.internal.file.FileResolver)1 HasScriptServices (org.gradle.api.internal.file.HasScriptServices)1 InstantiatorBackedObjectFactory (org.gradle.api.internal.model.InstantiatorBackedObjectFactory)1 ProviderFactory (org.gradle.api.provider.ProviderFactory)1 Instantiator (org.gradle.internal.reflect.Instantiator)1 ExecFactory (org.gradle.process.internal.ExecFactory)1