提交 7519aec8 编写于 作者: hlwwx's avatar hlwwx 提交者: hlwwx

'1.编译时增加合并api.json功能2.configSample/manifest.cfg增加web相关配置'


(cherry picked from commit eaaee28d41b99e2f6d1a910527d4e8535e1ffcdf)
上级 66d3f2aa
......@@ -33,5 +33,6 @@
"vfs.json":"虚拟文件存储配置",
"welink.json":"华为WeLink配置",
"workTime.json":"工作时间配置",
"zhengwuDingding.json":"政务钉钉配置"
"zhengwuDingding.json":"政务钉钉配置",
"web.json":"前端相关配置"
}
\ No newline at end of file
......@@ -9,11 +9,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -63,22 +61,45 @@ public class ApiBuilder {
private static Logger logger = LoggerFactory.getLogger(ApiBuilder.class);
public static void main(String[] args) throws IOException {
//System.out.println("ApiBuilder......");
File basedir = new File(args[0]);
File sourcedir = new File(args[1]);
File dir = new File(basedir, "src/main/webapp/describe");
FileUtils.forceMkdir(dir);
ApiBuilder builder = new ApiBuilder();
builder.scan(dir);
//FileUtils.copyDirectory(sourcedir, new File(dir, "sources"));
String filePath = args[0];
String fileName = filePath.substring(filePath.lastIndexOf(File.separator), filePath.length());
filePath = filePath.substring(0, filePath.lastIndexOf(File.separator));
filePath = filePath + File.separator+"x_program_center";
dir = new File(filePath ,"src/main/webapp/describe/api");
FileUtils.forceMkdir(dir);
builder.scan(dir,fileName);
}
private void scan(File dir,String fileName) {
try {
List<JaxrsClass> jaxrsClasses = new ArrayList<>();
List<Class<?>> classes = this.scanJaxrsClass();
for (Class<?> clz : classes) {
if (StandardJaxrsAction.class.isAssignableFrom(clz)) {
jaxrsClasses.add(this.jaxrsClass(clz));
}
}
LinkedHashMap<String, List<?>> map = new LinkedHashMap<>();
jaxrsClasses = jaxrsClasses.stream().sorted(Comparator.comparing(JaxrsClass::getName))
.collect(Collectors.toList());
map.put("jaxrs", jaxrsClasses);
File file = new File(dir, fileName + ".json");
FileUtils.writeStringToFile(file, XGsonBuilder.toJson(map), DefaultCharset.charset);
} catch (Exception e) {
e.printStackTrace();
}
}
private void scan(File dir) {
try {
List<JaxrsClass> jaxrsClasses = new ArrayList<>();
......@@ -123,23 +144,13 @@ public class ApiBuilder {
logger.print("describe class:{}.", clz.getName());
JaxrsDescribe jaxrsDescribe = clz.getAnnotation(JaxrsDescribe.class);
JaxrsClass jaxrsClass = new JaxrsClass();
//jaxrsClass.setClassName(clz.getName());
jaxrsClass.setName(clz.getSimpleName());
//jaxrsClass.setDescription(jaxrsDescribe.value());
for (Method method : clz.getMethods()) {
JaxrsMethodDescribe jaxrsMethodDescribe = method.getAnnotation(JaxrsMethodDescribe.class);
if (null != jaxrsMethodDescribe) {
/*
Map<String, JaxrsApiMethod> map = new HashMap<String,JaxrsApiMethod>();
map.put(method.getName(), this.jaxrsApiMethod(clz, method));
jaxrsClass.getMethods().add(map);
*/
jaxrsClass.getMethods().add(this.jaxrsApiMethod(clz, method));
}
}
//jaxrsClass.setMethods(this.getSortData("name",jaxrsClass.getMethods()));
}
return jaxrsClass;
}
......@@ -152,7 +163,6 @@ public class ApiBuilder {
this.keyName = keyName;
}
public int compare(Map<String, JaxrsApiMethod> mp1, Map<String, JaxrsApiMethod> mp2) {
System.out.println("this.keyName=" + mp1.keySet().toArray()[0]);
String d1 = mp1.keySet().toArray()[0].toString();
String d2 = mp2.keySet().toArray()[0].toString();
return d2.compareTo(d1);
......@@ -167,9 +177,7 @@ public class ApiBuilder {
JaxrsMethodDescribe jaxrsMethodDescribe = method.getAnnotation(JaxrsMethodDescribe.class);
JaxrsApiMethod jaxrsMethod = new JaxrsApiMethod();
jaxrsMethod.setName(method.getName());
//jaxrsMethod.setDescription(jaxrsMethodDescribe.value());
Class<?> actionClass = jaxrsMethodDescribe.action();
//jaxrsMethod.setClassName(actionClass.getName());
if (null != method.getAnnotation(GET.class)) {
jaxrsMethod.setMethod("GET");
} else if (null != method.getAnnotation(POST.class)) {
......@@ -541,23 +549,13 @@ public class ApiBuilder {
public String getName() {
return name;
}
/*
private List<Map<String,JaxrsApiMethod>> methods = new ArrayList<Map<String,JaxrsApiMethod>>();
public List<Map<String, JaxrsApiMethod>> getMethods() {
return methods;
}
public void setMethods(List<Map<String, JaxrsApiMethod>> methods) {
this.methods = methods;
}
*/
public void setName(String name) {
this.name = name;
}
}
public class JaxrsApiMethod{
//private List<JaxsApiMethodProperty> name = new ArrayList<>();
private String name;
private String uri;
private String method;
......
......@@ -95,6 +95,24 @@
</arguments>
</configuration>
</execution>
<execution>
<id>apiAllBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.ApiAllBuilder
</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>checkAssemble</id>
<phase>prepare-package</phase>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册