use of com.android.builder.dependency.MavenCoordinatesImpl in project atlas by alibaba.
the class AtlasLibTaskManager method createAwbBundle.
private AwbBundle createAwbBundle(LibVariantContext libVariantContext, String variantName) throws IOException {
AndroidDependencyTree libDependencyTree = AtlasBuildContext.libDependencyTrees.get(variantName);
if (null == libDependencyTree) {
dependencyManager.resolveDependencyForConfig(libVariantContext.getVariantDependency(), true);
libDependencyTree = AtlasBuildContext.libDependencyTrees.get(variantName);
}
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);
AwbBundle awbBundle = new AwbBundle(libVariantContext.getBundleTask().getArchivePath(), explodedDir, new ArrayList<LibraryDependency>(), new ArrayList<JarDependency>(), groupName + ":" + name, libVariantContext.getVariantName(), project.getPath(), null, new MavenCoordinatesImpl(groupName, name, version));
new AwoDependency(libVariantContext).parseDependency(libDependencyTree, awbBundle);
return awbBundle;
}
use of com.android.builder.dependency.MavenCoordinatesImpl 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;
}
use of com.android.builder.dependency.MavenCoordinatesImpl in project atlas by alibaba.
the class AtlasDependencyGraph method computeMavenCoordinates.
@NonNull
private static MavenCoordinates computeMavenCoordinates(@NonNull ResolvedArtifactResult artifact) {
// instance should be a hashable.
AtlasDependencyGraph.HashableResolvedArtifactResult hashableResult = (AtlasDependencyGraph.HashableResolvedArtifactResult) artifact;
ComponentIdentifier id = artifact.getId().getComponentIdentifier();
final File artifactFile = artifact.getFile();
final String fileName = artifactFile.getName();
String extension = hashableResult.getDependencyType().getExtension();
if (id instanceof ModuleComponentIdentifier) {
ModuleComponentIdentifier moduleComponentId = (ModuleComponentIdentifier) id;
final String module = moduleComponentId.getModule();
final String version = moduleComponentId.getVersion();
String classifier = null;
if (!artifact.getFile().isDirectory()) {
// attempts to compute classifier based on the filename.
String pattern = "^" + module + "-" + version + "-(.+)\\." + extension + "$";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(fileName);
if (m.matches()) {
classifier = m.group(1);
}
}
return new MavenCoordinatesImpl(moduleComponentId.getGroup(), module, version, extension, classifier);
} else if (id instanceof ProjectComponentIdentifier) {
return new MavenCoordinatesImpl("artifacts", ((ProjectComponentIdentifier) id).getProjectPath(), "unspecified");
} else if (id instanceof OpaqueComponentArtifactIdentifier) {
// We have a file based dependency
if (hashableResult.getDependencyType() == DependencyType.JAVA) {
return getMavenCoordForLocalFile(artifactFile);
} else {
// local aar?
assert artifactFile.isDirectory();
return getMavenCoordForLocalFile(artifactFile);
}
}
throw new RuntimeException("Don't know how to compute maven coordinate for artifact '" + artifact.getId().getDisplayName() + "' with component identifier of type '" + id.getClass() + "'.");
}
Aggregations