Search in sources :

Example 1 with AtlasConfigField

use of com.taobao.android.builder.tools.guide.AtlasConfigField in project atlas by alibaba.

the class AtlasListTask method executeTask.

@TaskAction
public void executeTask() {
    Project project = getProject();
    AtlasExtension atlasExtension = project.getExtensions().getByType(AtlasExtension.class);
    List<AtlasConfigField> list = null;
    try {
        list = AtlasConfigHelper.readConfig(atlasExtension, "atlas");
    } catch (Throwable e) {
        e.printStackTrace();
        return;
    }
    List<String> lines = new ArrayList<>();
    lines.add(" function  | The name of the configuration |  type | value ");
    lines.add(" ------------- | ------------- | ------------- | ------------- ");
    for (AtlasConfigField configField : list) {
        lines.add(configField.desc + "  | " + configField.name + " | " + configField.type + "  | " + configField.value);
    }
    for (String line : lines) {
        project.getLogger().error(line);
    }
    File file = new File(project.getProjectDir(), "atlasConfigList.MD");
    try {
        FileUtils.writeLines(file, lines);
        project.getLogger().error(file.getAbsolutePath() + " has generated");
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        FileUtils.write(new File(project.getProjectDir(), "atlasConfigList.json"), JSON.toJSONString(list, true));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Project(org.gradle.api.Project) AtlasExtension(com.taobao.android.builder.extension.AtlasExtension) AtlasConfigField(com.taobao.android.builder.tools.guide.AtlasConfigField) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

AtlasExtension (com.taobao.android.builder.extension.AtlasExtension)1 AtlasConfigField (com.taobao.android.builder.tools.guide.AtlasConfigField)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Project (org.gradle.api.Project)1 TaskAction (org.gradle.api.tasks.TaskAction)1