use of com.taobao.android.builder.dependency.model.AwbBundle in project atlas by alibaba.
the class AppVariantOutputContext method getAwbTransformMap.
public synchronized Map<String, AwbTransform> getAwbTransformMap() {
//TODO
if (awbTransformMap.isEmpty()) {
AndroidDependencyTree dependencyTree = AtlasBuildContext.androidDependencyTrees.get(variantContext.getVariantName());
for (AwbBundle awbBundle : dependencyTree.getAwbBundles()) {
//生成AwbTransform对象
AwbTransform awbTransform = new AwbTransform(awbBundle);
// awbTransform.setInputDir(awbJavaCompile.getDestinationDir());
//ADD R.class
awbTransform.getInputLibraries().addAll(awbBundle.getLibraryJars());
// awbTransform.getInputLibraries().addAll(appVariantOutputContext.getJAwbavaOutputDir(awbBundle));
awbTransformMap.put(awbBundle.getName(), awbTransform);
}
}
return awbTransformMap;
}
use of com.taobao.android.builder.dependency.model.AwbBundle 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.taobao.android.builder.dependency.model.AwbBundle 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.AwbBundle in project atlas by alibaba.
the class PackageAwbsTask method createAwbPackages.
/**
* 生成so的目录
*/
@TaskAction
void createAwbPackages() throws ExecutionException, InterruptedException {
AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());
if (null == androidDependencyTree) {
return;
}
final ProcessOutputHandler outputHandler = new ParsingProcessOutputHandler(new ToolOutputParser(new DexParser(), Message.Kind.ERROR, getILogger()), new ToolOutputParser(new DexParser(), getILogger()), getBuilder().getErrorReporter());
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
List<Runnable> runnables = new ArrayList<>();
final AtomicLong dexTotalTime = new AtomicLong(0);
final AtomicLong packageTotalTime = new AtomicLong(0);
final Map<String, Long[]> monitors = new HashMap<String, Long[]>();
long startTime = System.currentTimeMillis();
for (final AwbBundle awbBundle : androidDependencyTree.getAwbBundles()) {
runnables.add(new Runnable() {
@Override
public void run() {
try {
long start = System.currentTimeMillis();
//create dex
File dexOutputFile = appVariantContext.getAwbDexOutput(awbBundle.getName());
emptyFolder(dexOutputFile);
// if some of our .jar input files exist, just reset the inputDir to null
AwbTransform awbTransform = appVariantOutputContext.getAwbTransformMap().get(awbBundle.getName());
List<File> inputFiles = new ArrayList<File>();
inputFiles.addAll(awbTransform.getInputFiles());
inputFiles.addAll(awbTransform.getInputLibraries());
if (null != awbTransform.getInputDir()) {
inputFiles.add(awbTransform.getInputDir());
}
AtlasBuildContext.androidBuilder.convertByteCode(inputFiles, dexOutputFile, appVariantContext.getVariantData().getVariantConfiguration().isMultiDexEnabled(), null, androidConfig.getDexOptions(), true, outputHandler);
//create package
long endDex = System.currentTimeMillis();
//PACKAGE APP:
File resourceFile = appVariantOutputContext.getAwbAndroidResourcesMap().get(awbBundle.getName()).getPackageOutputFile();
Set<File> dexFolders = new HashSet<File>();
dexFolders.add(dexOutputFile);
Set<File> jniFolders = Sets.newHashSet();
if (appVariantOutputContext.getAwbJniFolder(awbBundle) != null && appVariantOutputContext.getAwbJniFolder(awbBundle).exists()) {
jniFolders.add(appVariantOutputContext.getAwbJniFolder(awbBundle));
}
Set<File> javaResourcesLocations = Sets.newHashSet();
if (appVariantContext.getAtlasExtension().getTBuildConfig().getMergeAwbJavaRes()) {
javaResourcesLocations.addAll(awbBundle.getLibraryJars());
}
//getBuilder().packageCodeSplitApk();
getBuilder().oldPackageApk(resourceFile.getAbsolutePath(), dexFolders, javaResourcesLocations, jniFolders, null, getAbiFilters(), config.getBuildType().isJniDebuggable(), null, getOutputFile(awbBundle), config.getMinSdkVersion().getApiLevel(), new Predicate<String>() {
@Override
public boolean apply(@Nullable String s) {
return false;
}
});
long endPackage = System.currentTimeMillis();
dexTotalTime.addAndGet(endDex - start);
packageTotalTime.addAndGet(endPackage - endDex);
monitors.put(awbBundle.getName(), new Long[] { endDex - start, endPackage - endDex });
} catch (Throwable e) {
e.printStackTrace();
throw new GradleException("package " + awbBundle.getName() + " failed");
}
}
});
}
executorServicesHelper.execute(runnables);
if (getLogger().isInfoEnabled()) {
getLogger().info(">>>>> packageAwbs >>>>>>>>>>>>");
getLogger().info("totalTime is " + (System.currentTimeMillis() - startTime));
getLogger().info("dexTotalTime is " + dexTotalTime);
getLogger().info("packageTotalTime is " + packageTotalTime);
String format = "[packageawb] bundle:%50s dexTime: %10d packageTime: %10d ";
for (String bundle : monitors.keySet()) {
Long[] value = monitors.get(bundle);
getLogger().info(String.format(format, bundle, value[0], value[1]));
}
getLogger().info(">>>>> packageAwbs >>>>>>>>>>>>");
}
}
use of com.taobao.android.builder.dependency.model.AwbBundle in project atlas by alibaba.
the class DataBindingProcessLayoutAwbsConfigAction method execute.
@Override
public void execute(MtlParallelTask parallelTask) {
super.execute(parallelTask);
AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(parallelTask.getVariantName());
if (null == androidDependencyTree) {
return;
}
DataBindingBuilder dataBindingBuilder = new DataBindingBuilder();
dataBindingBuilder.setPrintMachineReadableOutput(false);
dataBindingBuilder.setDebugLogEnabled(appVariantContext.getProject().getLogger().isDebugEnabled());
List<DefaultTask> tasks = new ArrayList<DefaultTask>();
for (final AwbBundle awbBundle : androidDependencyTree.getAwbBundles()) {
AwbDataBindingProcessLayoutsConfigAction processLayoutsConfigAction = new AwbDataBindingProcessLayoutsConfigAction(appVariantContext, awbBundle, dataBindingBuilder);
DataBindingProcessLayoutsTask dataBindingProcessLayoutsTask = TaskCreater.create(appVariantContext.getProject(), processLayoutsConfigAction.getName(), processLayoutsConfigAction.getType());
processLayoutsConfigAction.execute(dataBindingProcessLayoutsTask);
tasks.add(dataBindingProcessLayoutsTask);
}
parallelTask.parallelTask = tasks;
parallelTask.uniqueTaskName = getName();
parallelTask.concurrent = true;
}
Aggregations