# compile **Repository Path**: zhoulikai/compile ## Basic Information - **Project Name**: compile - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-02-23 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ############################## 本compile主要实现xml配置文件到java源文件的转换功能 一、xml规范编写 二、生成规则 1、在所需的app中配置xml文件及java文件生成的路径,调用compile/scripts/下的compile.sh即可,本项目已配置好为app/compile.sh #!/bin/bash #获取app项目的路径 path="$( cd "$( dirname "$0" )" && pwd )" echo ${path} #获取项目的app的参数 configure_name=/src/main/assets/parameter.xml; outjavafile_name=/src/main/java/ configure_path=${path}${configure_name} outjavafile_path=${path}${outjavafile_name} #根据项目参数执行编译脚本 sh ../compile/scripts/compile.sh ${configure_path} ${outjavafile_path} 2、将上述的编译脚本app/compile.sh添加入app的build.gradle文件中,使得android studio可视化工具在编译或者运行时候调用到 task compile_java(type: Exec) { executable 'sh' args "-c", "./compile.sh" exec() } 3、自动生成的java文件权限默认不许序员修改,结构如下 package com.yongyou.route; import java.util.HashMap; import java.util.Map; import java.util.Collections; public class AppParameterClass { public static Map> clsMap = new HashMap<>(); static { Map TextC_map = new HashMap<>(); TextC_map.put(TextC.KEY_SHOP_ID_VALUE, true); TextC_map.put(TextC.KEY_SHOP_NAME_VALUE, true); TextC_map.put(TextC.KEY_SHOP_PHONE_VALUE, false); clsMap.put("TextC", TextC_map); Map TextB_map = new HashMap<>(); TextB_map.put(TextB.KEY_SHOP_ID_VALUE, false); TextB_map.put(TextB.KEY_SHOP_NAME_VALUE, true); TextB_map.put(TextB.KEY_SHOP_PHONE_VALUE, false); clsMap.put("TextB", TextB_map); clsMap = Collections.unmodifiableMap(clsMap); }; // 跳转测试类 public static class TextB { // 商品的id public static final String KEY_SHOP_ID_VALUE = "key_shop_id_value"; // 商品名称 public static final String KEY_SHOP_NAME_VALUE = "key_shop_name_value"; // 商品电话 public static final String KEY_SHOP_PHONE_VALUE = "key_shop_phone_value"; } // 跳转测试类 public static class TextC { // 商品id public static final String KEY_SHOP_ID_VALUE = "key_shop_id_value"; // 商品名称 public static final String KEY_SHOP_NAME_VALUE = "key_shop_name_value"; // 商品电话 public static final String KEY_SHOP_PHONE_VALUE = "key_shop_phone_value"; } } 三、接口调用规则 //调用方call openPage方法启动一个新的activty,项目中不按照此规则,将不会验证通过,其中传递的key请使用自动生成的JAVA KEY来统一管理 Bundle bundle = new Bundle(); bundle.putString(AppParameterClass.TextC.KEY_SHOP_ID_VALUE, "12343214");//配置的此key必须参数,不传入会直接crash bundle.putString(AppParameterClass.TextC.KEY_SHOP_NAME_VALUE, "zhoulikai"); // bundle.putString(AppParameterClass.TextC.KEY_SHOP_PHONE_VALUE, "12345677"); ActivityRouter.openPage(TestA.this, TextC.class, bundle); 或者 Bundle bundle = new Bundle(); bundle.putString(AppParameterClass.TextC.KEY_SHOP_ID_VALUE, "12343214");//配置的此key必须参数,不传入会直接crash bundle.putString(AppParameterClass.TextC.KEY_SHOP_NAME_VALUE, "zhoulikai"); // bundle.putString(AppParameterClass.TextC.KEY_SHOP_PHONE_VALUE, "12345677"); ActivityRouter.openPage(TestA.this, TextC.class, bundle,10086); ##############################