Search in sources :

Example 1 with ModuleInfo

use of com.taobao.android.builder.tasks.awo.projectstrucure.ModuleInfo in project atlas by alibaba.

the class ModuleInfoWriter method write.

public void write() {
    //生成项目的基本信息
    try {
        ModuleInfo moduleInfo = new ModuleInfo();
        moduleInfo.group = project.getGroup().toString();
        moduleInfo.name = project.getName();
        moduleInfo.version = project.getVersion().toString();
        moduleInfo.path = project.getProjectDir().getAbsolutePath().replace(project.getRootDir().getAbsolutePath(), "").substring(1);
        //获取android manifst
        moduleInfo.packageName = libraryVariant.getApplicationId();
        List<SourceProvider> sourceProviders = libraryVariant.getSourceSets();
        for (SourceProvider sourceProvider : sourceProviders) {
            for (File java : sourceProvider.getJavaDirectories()) {
                if (java.exists()) {
                    moduleInfo.java_SrcDirs.add(java.getAbsolutePath());
                }
            }
            for (File res : sourceProvider.getResDirectories()) {
                if (res.exists()) {
                    moduleInfo.res_srcDirs.add(res.getAbsolutePath());
                }
            }
            for (File assets : sourceProvider.getAssetsDirectories()) {
                if (assets.exists()) {
                    moduleInfo.assets_srcDirs.add(assets.getAbsolutePath());
                }
            }
        }
        File moduleInfoFile = new File(project.getRootDir(), ".awo/" + moduleInfo.name + ".mi");
        moduleInfoFile.getParentFile().mkdirs();
        FileUtils.write(moduleInfoFile, JSON.toJSONString(moduleInfo, true));
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : ModuleInfo(com.taobao.android.builder.tasks.awo.projectstrucure.ModuleInfo) SourceProvider(com.android.builder.model.SourceProvider) File(java.io.File)

Aggregations

SourceProvider (com.android.builder.model.SourceProvider)1 ModuleInfo (com.taobao.android.builder.tasks.awo.projectstrucure.ModuleInfo)1 File (java.io.File)1