use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class CopyAwoSolibTask method doFullTaskAction.
@TaskAction
public void doFullTaskAction() {
if (!outputDir.exists()) {
outputDir.mkdirs();
}
Set<String> removeSoFiles = new HashSet<String>();
Set<String> supportAbis = new HashSet<String>();
//为了兼容之前老的aar,awb格式
File libJniFolder = new File(awbBundle.getFolder(), "libs");
if (libJniFolder.exists() && libJniFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(libJniFolder, outputDir, supportAbis, removeSoFiles, getILogger());
}
File libJniFolder2 = new File(awbBundle.getFolder(), "jni");
if (libJniFolder2.exists() && libJniFolder2.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(libJniFolder2, outputDir, supportAbis, removeSoFiles, getILogger());
}
File libJniFolder3 = new File(awbBundle.getFolder(), "jniLibs");
if (libJniFolder3.exists() && libJniFolder3.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(libJniFolder3, outputDir, supportAbis, removeSoFiles, getILogger());
}
List<? extends AndroidLibrary> deps = awbBundle.getLibraryDependencies();
for (AndroidLibrary dep : deps) {
File depJniFolder = dep.getJniFolder();
if (depJniFolder.exists() && depJniFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(depJniFolder, outputDir, supportAbis, removeSoFiles, getILogger());
}
//为了兼容之前老的aar,awb格式
File depLibsFolder = new File(dep.getFolder(), "libs");
if (depLibsFolder.exists() && depLibsFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(depLibsFolder, outputDir, supportAbis, removeSoFiles, getILogger());
}
}
List<SoLibrary> solibs = awbBundle.getSoLibraries();
if (null != solibs) {
for (SoLibrary solib : solibs) {
File explodeFolder = solib.getFolder();
if (!explodeFolder.exists()) {
LibraryCache.unzipAar(solib.getSoLibFile(), explodeFolder, getProject());
}
if (explodeFolder.exists() && explodeFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(explodeFolder, outputDir, supportAbis, removeSoFiles, getILogger());
}
}
}
}
use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class DiffDependencyTask method doTask.
@TaskAction
public void doTask() throws IOException {
apDependenciesFile = getApDependenciesFile();
diffOutFile = getDiffOutFile();
DependencyJson apDependencyJson = JSON.parseObject(FileUtils.readFileToString(apDependenciesFile), DependencyJson.class);
Set<String> apMainDependencies = Sets.newHashSet();
for (String mainDep : apDependencyJson.getMainDex()) {
String name = mainDep.substring(0, mainDep.lastIndexOf(":"));
apMainDependencies.add(name);
}
AwbBundle awbBundle = libVariantContext.getAwbBundle();
//aars
if (null != awbBundle.getLibraryDependencies()) {
for (int index = 0; index < awbBundle.getLibraryDependencies().size(); index++) {
AndroidLibrary libraryDependency = awbBundle.getLibraryDependencies().get(index);
MavenCoordinates mavenCoordinates = libraryDependency.getResolvedCoordinates();
String name = getMavenName(mavenCoordinates);
if (apMainDependencies.contains(name)) {
getLogger().info("[Remove]" + name);
awbBundle.getLibraryDependencies().remove(index);
} else {
inAwbDependencies.add(name);
}
}
}
//solibs
if (null != awbBundle.getSoLibraries()) {
for (int index = 0; index < awbBundle.getSoLibraries().size(); index++) {
SoLibrary soLibrary = awbBundle.getSoLibraries().get(index);
MavenCoordinates mavenCoordinates = soLibrary.getResolvedCoordinates();
String name = getMavenName(mavenCoordinates);
if (apMainDependencies.contains(name)) {
getLogger().info("[Remove]" + name);
awbBundle.getSoLibraries().remove(index);
} else {
inAwbDependencies.add(name);
}
}
}
// jars
if (null != awbBundle.getJavaDependencies()) {
Iterator<? extends JavaLibrary> iterator = awbBundle.getJavaDependencies().iterator();
while (iterator.hasNext()) {
JavaLibrary jarInfo = iterator.next();
MavenCoordinates mavenCoordinates = jarInfo.getResolvedCoordinates();
String name = getMavenName(mavenCoordinates);
if (apMainDependencies.contains(name)) {
getLogger().info("[Remove]" + name);
iterator.remove();
} else {
inAwbDependencies.add(name);
}
}
}
FileUtils.writeStringToFile(diffOutFile, StringUtils.join(inAwbDependencies, "\n"));
}
use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class DependencyConvertUtils method collectChildren.
/**
* 收集子集合
*
* @param dependencyInfo
* @param dependencies
* @param jarDependencies
* @param soLibraries
*/
private static void collectChildren(ResolvedDependencyInfo dependencyInfo, List<LibraryDependency> dependencies, Collection<JarDependency> jarDependencies, List<SoLibrary> soLibraries) {
List<ResolvedDependencyInfo> children = dependencyInfo.getChildren();
for (ResolvedDependencyInfo child : children) {
switch(Type.getType(child.getType())) {
case AAR:
AarBundle aarBundle = toAarBundle(child, false);
dependencies.add(aarBundle);
collectChildren(child, dependencies, jarDependencies, soLibraries);
break;
case JAR:
JarDependency jarInfo = toJarDependency(child, false);
jarDependencies.add(jarInfo);
collectChildren(child, dependencies, jarDependencies, soLibraries);
break;
case SOLIB:
SoLibrary soLibrary = toSoLibrary(child);
soLibraries.add(soLibrary);
break;
default:
break;
}
}
}
use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class DependencyConvertUtils method toSoLibrary.
/**
* 转换为solibrary依赖
*
* @param resolvedDependencyInfo
* @return
*/
public static SoLibrary toSoLibrary(ResolvedDependencyInfo resolvedDependencyInfo) {
assertType(Type.SOLIB, resolvedDependencyInfo);
ResolvedArtifact artifact = resolvedDependencyInfo.getResolvedArtifact();
SoLibrary soLibrary = new SoLibrary(convert(artifact), artifact.getFile(), resolvedDependencyInfo.getExplodedDir());
return soLibrary;
}
use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class DependencyConvertUtils method toAarBundle.
/**
* 将依赖类型转换为LibraryDependencyImpl
*
* @param resolvedDependencyInfo
* @return
*/
private static AarBundle toAarBundle(ResolvedDependencyInfo resolvedDependencyInfo, boolean containChild) {
assertType(Type.AAR, resolvedDependencyInfo);
List<LibraryDependency> dependencies = Lists.newArrayList();
Collection<JarDependency> jarDependencies = Lists.newArrayList();
List<SoLibrary> soLibraries = Lists.newArrayList();
if (containChild) {
collectChildren(resolvedDependencyInfo, dependencies, jarDependencies, soLibraries);
}
AarBundle aarBundle = new AarBundle(resolvedDependencyInfo.getResolvedArtifact().getFile(), resolvedDependencyInfo.getExplodedDir(), dependencies, jarDependencies, resolvedDependencyInfo.getGroup() + "-" + resolvedDependencyInfo.getName(), resolvedDependencyInfo.getVariantName(), resolvedDependencyInfo.getGradlePath(), null, convert(resolvedDependencyInfo.getResolvedArtifact()));
aarBundle.setSoLibraries(soLibraries);
return aarBundle;
}
Aggregations