def serverEnv() {
def dir = getProjectDir();
def path = dir.path + "/src/main/java/com/example"
File fileAppConfig = new File(path + "/AppConfig.java")
if(fileAppConfig!=null&&fileAppConfig.exists()){
def debugIndex=fileAppConfig.text.indexOf("IS_DEBUG");
if(debugIndex==-1){
throw Exception("error index")
}else{
def text=fileAppConfig.text.substring(debugIndex+11,debugIndex+15)
def str=""
if(!text.toBoolean()){
str= "prod"
}else{
str= "test";
}
return str
}
}else{
throw Exception("file error")
}
}
调用 serverEnv();