use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class DependencyConvertUtils method toAwbBundle.
public static AwbBundle toAwbBundle(ResolvedDependencyInfo resolvedDependencyInfo) {
assertType(Type.AWB, resolvedDependencyInfo);
List<LibraryDependency> dependencies = Lists.newArrayList();
Collection<JarDependency> jarDependencies = Lists.newArrayList();
List<SoLibrary> soLibraries = Lists.newArrayList();
collectChildren(resolvedDependencyInfo, dependencies, jarDependencies, soLibraries);
AwbBundle awbBundle = new AwbBundle(resolvedDependencyInfo.getResolvedArtifact().getFile(), resolvedDependencyInfo.getExplodedDir(), dependencies, jarDependencies, resolvedDependencyInfo.getGroup() + "-" + resolvedDependencyInfo.getName(), resolvedDependencyInfo.getVariantName(), resolvedDependencyInfo.getGradlePath(), null, convert(resolvedDependencyInfo.getResolvedArtifact()));
awbBundle.setSoLibraries(soLibraries);
return awbBundle;
}
use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class DependencyTree method toAndroidDependency.
/**
* 转换为Android的依赖
*
* @return
*/
public AndroidDependencyTree toAndroidDependency() {
AndroidDependencyTree androidDependencyTree = new AndroidDependencyTree(mResolvedDependencies);
for (ResolvedDependencyInfo dependencyInfo : mResolvedDependencies) {
switch(DependencyConvertUtils.Type.getType(dependencyInfo.getType())) {
case AAR:
AarBundle aarBundle = DependencyConvertUtils.toAarBundle(dependencyInfo);
androidDependencyTree.getAarBundles().add(aarBundle);
for (AndroidLibrary libraryDependency : aarBundle.getLibraryDependencies()) {
if (libraryDependency instanceof AarBundle) {
androidDependencyTree.getAarBundles().add((AarBundle) libraryDependency);
}
}
androidDependencyTree.getJars().addAll(aarBundle.getJavaDependencies());
androidDependencyTree.getSoLibraries().addAll(aarBundle.getSoLibraries());
break;
case AWB:
AwbBundle awbBundle = DependencyConvertUtils.toAwbBundle(dependencyInfo);
androidDependencyTree.getAwbBundles().add(awbBundle);
break;
case JAR:
JavaLibrary jarInfo = DependencyConvertUtils.toJarDependency(dependencyInfo);
androidDependencyTree.getJars().add(jarInfo);
androidDependencyTree.getJars().addAll(jarInfo.getDependencies());
break;
case SOLIB:
SoLibrary soLibrary = DependencyConvertUtils.toSoLibrary(dependencyInfo);
androidDependencyTree.getSoLibraries().add(soLibrary);
break;
case APK:
ApkLibrary apkLibrary = DependencyConvertUtils.toApkLibrary(dependencyInfo);
androidDependencyTree.getApkLibraries().add(apkLibrary);
break;
case AP:
ApLibrary apLibrary = DependencyConvertUtils.toApLibrary(dependencyInfo);
androidDependencyTree.getApLibraries().add(apLibrary);
break;
default:
break;
}
}
return androidDependencyTree;
}
use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class PrepareAwbTask method run.
@TaskAction
void run() throws ExecutionException, InterruptedException, IOException, DocumentException {
AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());
if (null == androidDependencyTree) {
return;
}
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
List<Runnable> runnables = new ArrayList<>();
Set<SoLibrary> soLibraries = androidDependencyTree.getALLSoLibDependencies();
for (final SoLibrary soLibrary : soLibraries) {
runnables.add(new Runnable() {
@Override
public void run() {
prepare(soLibrary.getSoLibFile(), soLibrary.getFolder(), false);
}
});
}
executorServicesHelper.execute(runnables);
runnables.clear();
List<AwbBundle> awbBundles = androidDependencyTree.getAwbBundles();
for (final AwbBundle awbBundle : awbBundles) {
runnables.add(new Runnable() {
@Override
public void run() {
prepare(awbBundle.getBundle(), awbBundle.getFolder(), true);
}
});
}
executorServicesHelper.execute(runnables);
runnables.clear();
Set<AarBundle> aarBundles = androidDependencyTree.getALLAarDependencies();
for (final AarBundle aarBundle : aarBundles) {
runnables.add(new Runnable() {
@Override
public void run() {
prepare(aarBundle.getBundle(), aarBundle.getFolder(), true);
}
});
}
executorServicesHelper.execute(runnables);
runnables.clear();
}
use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class AwoDependency method parseDependency.
public void parseDependency(AndroidDependencyTree libDependencyTree, AwbBundle awbBundle) {
List<SoLibrary> soLibraries = new ArrayList<SoLibrary>();
for (SoLibrary soLibrary : libDependencyTree.getSoLibraries()) {
if (isCompileDependency(soLibrary.getResolvedCoordinates())) {
soLibraries.add(soLibrary);
}
}
List aarBundles = new ArrayList<>();
for (AarBundle aarBundle : libDependencyTree.getAarBundles()) {
if (isCompileDependency(aarBundle.getResolvedCoordinates())) {
aarBundles.add(aarBundle);
}
}
List jarInfos = new ArrayList<JavaLibrary>();
for (JavaLibrary jarInfo : libDependencyTree.getJars()) {
if (isCompileDependency(jarInfo.getResolvedCoordinates())) {
jarInfos.add(jarInfo);
}
}
awbBundle.getSoLibraries().addAll(soLibraries);
awbBundle.getLibraryDependencies().addAll(aarBundles);
awbBundle.getJavaDependencies().addAll(jarInfos);
}
use of com.taobao.android.builder.dependency.model.SoLibrary in project atlas by alibaba.
the class PrepareSoLibTask method generate.
/**
* 生成so的目录
*/
@TaskAction
void generate() {
List<File> scanDirs = new ArrayList<File>();
//先生成主bundle的jnifolder目录
if (!getMainBundleOutputFolder().exists()) {
getMainBundleOutputFolder().mkdirs();
}
for (File jniFolder : getJniFolders()) {
if (jniFolder.exists() && jniFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(jniFolder, getMainBundleOutputFolder(), getSupportAbis(), getRemoveSoFiles(), getILogger());
}
}
scanDirs.add(getMainBundleOutputFolder());
//增加主bundle依赖的solib的so
for (SoLibrary mainSoLib : getMainDexSoLibraries()) {
File explodeFolder = mainSoLib.getFolder();
if (explodeFolder.exists() && explodeFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(explodeFolder, getMainBundleOutputFolder(), getSupportAbis(), getRemoveSoFiles(), getILogger());
}
}
//处理awb bundle的so
for (AwbBundle awbLib : getAwbLibs()) {
File awbOutputFolder = new File(appVariantOutputContext.getAwbJniFolder(awbLib), "lib");
awbOutputFolder.mkdirs();
scanDirs.add(awbOutputFolder);
File awbJniFolder = awbLib.getJniFolder();
if (awbJniFolder.exists() && awbJniFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(awbJniFolder, awbOutputFolder, getSupportAbis(), getRemoveSoFiles(), getILogger());
}
//为了兼容之前老的aar,awb格式
File libJniFolder = new File(awbLib.getFolder(), "libs");
if (libJniFolder.exists() && libJniFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(libJniFolder, awbOutputFolder, getSupportAbis(), getRemoveSoFiles(), getILogger());
}
List<? extends AndroidLibrary> deps = awbLib.getLibraryDependencies();
for (AndroidLibrary dep : deps) {
File depJniFolder = dep.getJniFolder();
if (depJniFolder.exists() && depJniFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(depJniFolder, awbOutputFolder, getSupportAbis(), getRemoveSoFiles(), getILogger());
}
//为了兼容之前老的aar,awb格式
File depLibsFolder = new File(dep.getFolder(), "libs");
if (depLibsFolder.exists() && depLibsFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(depLibsFolder, awbOutputFolder, getSupportAbis(), getRemoveSoFiles(), getILogger());
}
}
List<SoLibrary> solibs = awbLib.getSoLibraries();
if (null != solibs) {
for (SoLibrary solib : solibs) {
File explodeFolder = solib.getFolder();
if (explodeFolder.exists() && explodeFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(explodeFolder, awbOutputFolder, getSupportAbis(), getRemoveSoFiles(), getILogger());
}
}
}
}
//判断是否有重复的so文件
// 进行重复文件的查询
Map<String, Multimap<String, File>> soMaps = NativeSoUtils.getAbiSoFiles(getSupportAbis(), getRemoveSoFiles(), scanDirs);
boolean hasDup = false;
for (Map.Entry<String, Multimap<String, File>> entry : soMaps.entrySet()) {
String abi = entry.getKey();
Multimap<String, File> soFiles = soMaps.get(abi);
for (String soKey : soFiles.keys()) {
if (soFiles.get(soKey).size() > 1) {
getILogger().warning("[SO Duplicate][" + abi + "]:" + StringUtils.join(soFiles.get(soKey), ","));
hasDup = true;
} else {
getILogger().verbose("[SO][" + abi + "]:" + StringUtils.join(soFiles.get(soKey), ","));
}
}
}
// if (hasDup && getFailOnDuplicateSo()) {
// throw new RuntimeException("SO file has duplicate files!See detail info!");
// }
}
Aggregations