Search in sources :

Example 1 with ProjectOptions

use of com.android.build.gradle.options.ProjectOptions in project atlas by alibaba.

the class AwbGenerator method createAwbBundle.

public AwbBundle createAwbBundle(LibVariantContext libVariantContext) throws IOException {
    String variantName = libVariantContext.getVariantName();
    AtlasDependencyTree libDependencyTree = AtlasBuildContext.libDependencyTrees.get(variantName);
    // TODO 2.3
    if (null == libDependencyTree) {
        libDependencyTree = new AtlasDepTreeParser(libVariantContext.getProject(), new ExtraModelInfo(new ProjectOptions(libVariantContext.getProject()), null), new HashSet<>()).parseDependencyTree(libVariantContext.getVariantDependency());
        AtlasBuildContext.libDependencyTrees.put(variantName, libDependencyTree);
    }
    Project project = libVariantContext.getProject();
    String groupName = (String) project.getGroup();
    String name = "";
    String version = (String) project.getVersion();
    if (project.hasProperty("archivesBaseName")) {
        name = (String) project.getProperties().get("archivesBaseName");
    } else {
        name = project.getName();
    }
    File explodedDir = project.file(project.getBuildDir().getAbsolutePath() + "/" + FD_INTERMEDIATES + "/exploded-awb/" + computeArtifactPath(groupName, name, version));
    FileUtils.deleteDirectory(explodedDir);
    MavenCoordinates mavenCoordinates = new MavenCoordinatesImpl(groupName, name, version, "awb", "");
    ResolvedDependencyInfo resolvedDependencyInfo = new ResolvedDependencyInfo(groupName, name, version, "awb");
    resolvedDependencyInfo.setVariantName(libVariantContext.getVariantName());
    AwbBundle awbBundle = new AwbBundle(resolvedDependencyInfo, DependencyConvertUtils.toAndroidLibrary(mavenCoordinates, libVariantContext.getBundleTask().getArchivePath(), explodedDir));
    awbBundle.getSoLibraries().addAll(libDependencyTree.getMainBundle().getSoLibraries());
    awbBundle.getAndroidLibraries().addAll(libDependencyTree.getMainBundle().getAndroidLibraries());
    awbBundle.getJavaLibraries().addAll(libDependencyTree.getMainBundle().getJavaLibraries());
    return awbBundle;
}
Also used : Project(org.gradle.api.Project) MavenCoordinates(com.android.builder.model.MavenCoordinates) MavenCoordinatesImpl(com.android.builder.dependency.MavenCoordinatesImpl) ResolvedDependencyInfo(com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo) AtlasDepTreeParser(com.taobao.android.builder.dependency.parser.AtlasDepTreeParser) ExtraModelInfo(com.android.build.gradle.internal.ExtraModelInfo) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree) ProjectOptions(com.android.build.gradle.options.ProjectOptions) File(java.io.File)

Example 2 with ProjectOptions

use of com.android.build.gradle.options.ProjectOptions in project atlas by alibaba.

the class TransformReplacer method replaceDexArchiveBuilderTransform.

public void replaceDexArchiveBuilderTransform(BaseVariantOutput vod) {
    List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext, DexArchiveBuilderTransform.class);
    DefaultDexOptions dexOptions = variantContext.getAppExtension().getDexOptions();
    boolean minified = variantContext.getScope().getCodeShrinker() != null;
    ProjectOptions projectOptions = variantContext.getScope().getGlobalScope().getProjectOptions();
    FileCache userLevelCache = getUserDexCache(minified, dexOptions.getPreDexLibraries());
    for (TransformTask transformTask : list) {
        AtlasDexArchiveBuilderTransform atlasDexArchiveBuilderTransform = new AtlasDexArchiveBuilderTransform(variantContext, vod, dexOptions, variantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter(), userLevelCache, variantContext.getScope().getMinSdkVersion().getFeatureLevel(), variantContext.getScope().getDexer(), projectOptions.get(BooleanOption.ENABLE_GRADLE_WORKERS), projectOptions.get(IntegerOption.DEXING_READ_BUFFER_SIZE), projectOptions.get(IntegerOption.DEXING_WRITE_BUFFER_SIZE), variantContext.getScope().getVariantConfiguration().getBuildType().isDebuggable());
        atlasDexArchiveBuilderTransform.setTransformTask(transformTask);
        ReflectUtils.updateField(transformTask, "transform", atlasDexArchiveBuilderTransform);
        if (variantContext.getScope().getInstantRunBuildContext().isInInstantRunMode() && variantContext.getVariantConfiguration().getMinSdkVersion().getApiLevel() < 21) {
            transformTask.doLast(task -> {
                task.getLogger().info("generate maindexList......");
                generateMainDexList(variantContext.getScope());
            });
        }
    }
}
Also used : AtlasDexArchiveBuilderTransform(com.taobao.android.builder.tasks.transform.dex.AtlasDexArchiveBuilderTransform) TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) DefaultDexOptions(com.android.builder.core.DefaultDexOptions) ProjectOptions(com.android.build.gradle.options.ProjectOptions) FileCache(com.android.builder.utils.FileCache)

Example 3 with ProjectOptions

use of com.android.build.gradle.options.ProjectOptions in project atlas by alibaba.

the class AtlasConfigurationHelper method configDependencies.

public void configDependencies(File awbConfigFile) {
    Set<String> awbs = getAwbs(awbConfigFile);
    AtlasDependencyManager atlasDependencyManager = new AtlasDependencyManager(project, new ExtraModelInfo(new ProjectOptions(project), project.getLogger()), awbs);
    VariantManager variantManager = getVariantManager();
    if (variantManager != null) {
        variantManager.getVariantScopes().stream().forEach(variantScope -> atlasDependencyManager.resolveDependencies(variantScope.getVariantDependencies()));
    }
}
Also used : ExtraModelInfo(com.android.build.gradle.internal.ExtraModelInfo) AtlasDependencyManager(com.android.build.gradle.internal.AtlasDependencyManager) ProjectOptions(com.android.build.gradle.options.ProjectOptions) VariantManager(com.android.build.gradle.internal.VariantManager)

Aggregations

ProjectOptions (com.android.build.gradle.options.ProjectOptions)3 ExtraModelInfo (com.android.build.gradle.internal.ExtraModelInfo)2 AtlasDependencyManager (com.android.build.gradle.internal.AtlasDependencyManager)1 VariantManager (com.android.build.gradle.internal.VariantManager)1 TransformTask (com.android.build.gradle.internal.pipeline.TransformTask)1 DefaultDexOptions (com.android.builder.core.DefaultDexOptions)1 MavenCoordinatesImpl (com.android.builder.dependency.MavenCoordinatesImpl)1 MavenCoordinates (com.android.builder.model.MavenCoordinates)1 FileCache (com.android.builder.utils.FileCache)1 AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)1 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)1 AtlasDepTreeParser (com.taobao.android.builder.dependency.parser.AtlasDepTreeParser)1 ResolvedDependencyInfo (com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo)1 AtlasDexArchiveBuilderTransform (com.taobao.android.builder.tasks.transform.dex.AtlasDexArchiveBuilderTransform)1 File (java.io.File)1 Project (org.gradle.api.Project)1