Search in sources :

Example 1 with AtlasDepTreeParser

use of com.taobao.android.builder.dependency.parser.AtlasDepTreeParser 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 AtlasDepTreeParser

use of com.taobao.android.builder.dependency.parser.AtlasDepTreeParser in project atlas by alibaba.

the class AtlasDependencyManager method resolveDependencies.

/**
 * 1 . detect if has awb dependency
 * <p>
 * yes : special process
 * no  : default process
 * <p>
 * 2.  parse to AtlasDependencyTree
 */
public Set<AndroidDependency> resolveDependencies(@NonNull VariantDependencies variantDeps) {
    this.apDependency = resolveApDependencies(variantDeps);
    AtlasDependencyTree atlasDependencyTree = new AtlasDepTreeParser(project, extraModelInfo, awbs).parseDependencyTree(variantDeps);
    sLogger.info("[dependencyTree" + variantDeps.getName() + "] {}", JSON.toJSONString(atlasDependencyTree.getDependencyJson(), true));
    if (PluginTypeUtils.isAppProject(project)) {
        AtlasBuildContext.androidDependencyTrees.put(variantDeps.getName(), atlasDependencyTree);
    } else {
        AtlasBuildContext.libDependencyTrees.put(variantDeps.getName(), atlasDependencyTree);
    }
    // return libsToExplode;
    return new HashSet<>(0);
}
Also used : AtlasDepTreeParser(com.taobao.android.builder.dependency.parser.AtlasDepTreeParser) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree) HashSet(java.util.HashSet)

Aggregations

AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)2 AtlasDepTreeParser (com.taobao.android.builder.dependency.parser.AtlasDepTreeParser)2 ExtraModelInfo (com.android.build.gradle.internal.ExtraModelInfo)1 ProjectOptions (com.android.build.gradle.options.ProjectOptions)1 MavenCoordinatesImpl (com.android.builder.dependency.MavenCoordinatesImpl)1 MavenCoordinates (com.android.builder.model.MavenCoordinates)1 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)1 ResolvedDependencyInfo (com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo)1 File (java.io.File)1 HashSet (java.util.HashSet)1 Project (org.gradle.api.Project)1