|
|
|
|
@ -1,11 +1,21 @@
|
|
|
|
|
package cokr.xit;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
|
|
|
|
|
|
|
|
|
import cokr.xit.foundation.Downloadable;
|
|
|
|
|
import cokr.xit.foundation.web.AbstractController;
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
|
@ -20,4 +30,180 @@ public class MainController extends AbstractController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(name="fims pom파일 작성", value={"/createFimsPOM.do"})
|
|
|
|
|
public ModelAndView createFimsPOM(HttpServletRequest req) {
|
|
|
|
|
|
|
|
|
|
ModelAndView mav = new ModelAndView("downloadView");
|
|
|
|
|
|
|
|
|
|
String project = req.getParameter("project");
|
|
|
|
|
String description = req.getParameter("description");
|
|
|
|
|
String[] serviceSelection = req.getParameterValues("serviceSelection");
|
|
|
|
|
String[] dbSelection = req.getParameterValues("dbSelection");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextFileMaker pom = new TextFileMaker();
|
|
|
|
|
|
|
|
|
|
//xml
|
|
|
|
|
pom.addLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
|
|
|
|
|
|
|
|
|
//pom
|
|
|
|
|
pom.addLine("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" "
|
|
|
|
|
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
|
|
|
|
|
+ "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">");
|
|
|
|
|
|
|
|
|
|
pom.addLine("<modelVersion>4.0.0</modelVersion>");
|
|
|
|
|
|
|
|
|
|
pom.addLine("<groupId>xit-app</groupId>");
|
|
|
|
|
pom.addLine("<artifactId>"+project+"</artifactId>");
|
|
|
|
|
pom.addLine("<version>1.0.0-SNAPSHOT</version>");
|
|
|
|
|
pom.addLine("<name>"+project+"</name>");
|
|
|
|
|
pom.addLine("<description>"+description+"</description>");
|
|
|
|
|
pom.addLine("<packaging>war</packaging>");
|
|
|
|
|
|
|
|
|
|
//부모프로젝트
|
|
|
|
|
String parent = """
|
|
|
|
|
<parent>
|
|
|
|
|
<groupId>org.springframework.boot</groupId>
|
|
|
|
|
<artifactId>spring-boot-starter-parent</artifactId>
|
|
|
|
|
<version>2.7.18</version>
|
|
|
|
|
<relativePath/>
|
|
|
|
|
</parent>
|
|
|
|
|
""";
|
|
|
|
|
pom.addLine(parent);
|
|
|
|
|
|
|
|
|
|
//프로퍼티
|
|
|
|
|
String encodingAndJava = """
|
|
|
|
|
<properties>
|
|
|
|
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
|
|
|
<java.version>17</java.version>
|
|
|
|
|
</properties>
|
|
|
|
|
""";
|
|
|
|
|
pom.addLine(encodingAndJava);
|
|
|
|
|
|
|
|
|
|
//저장소
|
|
|
|
|
String repo = """
|
|
|
|
|
<repositories>
|
|
|
|
|
<repository>
|
|
|
|
|
<id>maven-public</id>
|
|
|
|
|
<url>https://nas.xit.co.kr:8888/repository/maven-public/</url>
|
|
|
|
|
</repository>
|
|
|
|
|
</repositories>
|
|
|
|
|
|
|
|
|
|
<pluginRepositories>
|
|
|
|
|
<pluginRepository>
|
|
|
|
|
<id>maven-public</id>
|
|
|
|
|
<url>https://nas.xit.co.kr:8888/repository/maven-public/</url>
|
|
|
|
|
<snapshots>
|
|
|
|
|
<enabled>true</enabled>
|
|
|
|
|
</snapshots>
|
|
|
|
|
<releases>
|
|
|
|
|
<enabled>false</enabled>
|
|
|
|
|
</releases>
|
|
|
|
|
</pluginRepository>
|
|
|
|
|
</pluginRepositories>
|
|
|
|
|
""";
|
|
|
|
|
pom.addLine(repo);
|
|
|
|
|
|
|
|
|
|
//의존 라이브러리
|
|
|
|
|
pom.addLine("<dependencies>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(serviceSelection != null) {
|
|
|
|
|
for(String item : serviceSelection) {
|
|
|
|
|
pom.addLine(dependencyFims("java", item));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(dbSelection != null) {
|
|
|
|
|
for(String item : dbSelection) {
|
|
|
|
|
switch(item){
|
|
|
|
|
case "mariadb":
|
|
|
|
|
case "mysql":
|
|
|
|
|
//nothing
|
|
|
|
|
case "oracle":
|
|
|
|
|
//nothing?
|
|
|
|
|
break;
|
|
|
|
|
case "PostgreSQL":
|
|
|
|
|
case "CUBRID":
|
|
|
|
|
case "MSSQL":
|
|
|
|
|
case "TIBERO":
|
|
|
|
|
case "ALTIBASE":
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(serviceSelection != null) {
|
|
|
|
|
for(String item : serviceSelection) {
|
|
|
|
|
pom.addLine(dependencyFims("web", item));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pom.addLine("</dependencies>");
|
|
|
|
|
|
|
|
|
|
//빌드
|
|
|
|
|
String build = """
|
|
|
|
|
<build>
|
|
|
|
|
<plugins>
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.springframework.boot</groupId>
|
|
|
|
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
|
|
|
<configuration>
|
|
|
|
|
<excludes>
|
|
|
|
|
<exclude>
|
|
|
|
|
<groupId>org.projectlombok</groupId>
|
|
|
|
|
<artifactId>lombok</artifactId>
|
|
|
|
|
</exclude>
|
|
|
|
|
</excludes>
|
|
|
|
|
</configuration>
|
|
|
|
|
</plugin>
|
|
|
|
|
</plugins>
|
|
|
|
|
</build>
|
|
|
|
|
""";
|
|
|
|
|
pom.addLine(build);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pom.addLine("</project>");
|
|
|
|
|
|
|
|
|
|
pom.makeTxtFile("C:\\Temp", "pom.xml", pom.getFileCn());
|
|
|
|
|
|
|
|
|
|
File file = new File("C:\\Temp"+File.separator+"pom.xml");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
byte[] bytes = Files.readAllBytes(file.toPath());
|
|
|
|
|
|
|
|
|
|
Consumer<OutputStream> writer = new Consumer<OutputStream>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void accept(OutputStream os) {
|
|
|
|
|
try {
|
|
|
|
|
os.write(bytes);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
mav.addObject("download",
|
|
|
|
|
new Downloadable()
|
|
|
|
|
.setContentType("application/xml")
|
|
|
|
|
.setWriter(writer)
|
|
|
|
|
.setFilename("pom.xml")
|
|
|
|
|
);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return mav;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String dependencyFims(String lang, String service) {
|
|
|
|
|
String d = "";
|
|
|
|
|
d += "<dependency>\r\n";
|
|
|
|
|
d += "<groupId>cokr.xit.app</groupId>\r\n";
|
|
|
|
|
d += "<artifactId>fims-"+lang+"-"+service+"</artifactId>\r\n";
|
|
|
|
|
d += "<version>1.0.0-SNAPSHOT</version>\r\n";
|
|
|
|
|
d += "</dependency>\r\n";
|
|
|
|
|
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|