|
|
|
|
@ -3,14 +3,16 @@ package xyz.wbsite.deployee;
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
|
|
import cn.hutool.core.io.resource.ResourceUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import org.apache.maven.plugin.AbstractMojo;
|
|
|
|
|
import org.apache.maven.plugin.MojoExecutionException;
|
|
|
|
|
import xyz.wbsite.deployee.config.Server;
|
|
|
|
|
import xyz.wbsite.deployee.util.IOUtil;
|
|
|
|
|
import xyz.wbsite.deployee.util.NetUtil;
|
|
|
|
|
import xyz.wbsite.deployee.util.TaskUtil;
|
|
|
|
|
import xyz.wbsite.deployee.util.ssh.JSshClient;
|
|
|
|
|
import xyz.wbsite.deployee.util.ssh.SshSimpleProgress;
|
|
|
|
|
import org.apache.maven.plugin.AbstractMojo;
|
|
|
|
|
import org.apache.maven.plugin.MojoExecutionException;
|
|
|
|
|
|
|
|
|
|
import xyz.wbsite.deployee.config.Server.JreVersion;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
@ -71,7 +73,7 @@ public class Deploy extends AbstractMojo {
|
|
|
|
|
printLog(serverPath);
|
|
|
|
|
if (!client.exist(serverPath)) {
|
|
|
|
|
try {
|
|
|
|
|
printLog("start install jre");
|
|
|
|
|
printLog("start upload jre");
|
|
|
|
|
|
|
|
|
|
printLog("create dir " + serverPath);
|
|
|
|
|
boolean dirs = client.createDirs(serverPath);
|
|
|
|
|
@ -81,9 +83,16 @@ public class Deploy extends AbstractMojo {
|
|
|
|
|
throw new MojoExecutionException(StrUtil.format("create dirs[{}] failed.", serverPath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InputStream stream = ResourceUtil.getStream("jre.tar.gz");
|
|
|
|
|
JreVersion jreVersion = server.getJre() != null ? server.getJre() : JreVersion.jre8;
|
|
|
|
|
String jreFileName = jreVersion.name() + ".tar.gz";
|
|
|
|
|
printLog("use jre version: {}", jreVersion.name());
|
|
|
|
|
|
|
|
|
|
InputStream stream = ResourceUtil.getStream(jreFileName);
|
|
|
|
|
if (stream == null) {
|
|
|
|
|
throw new MojoExecutionException(StrUtil.format("jre resource [{}] not found.", jreFileName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client.putFile(stream, serverPath + "/jre.tar.gz", new SshSimpleProgress() {
|
|
|
|
|
client.putFile(stream, serverPath + "/" + jreFileName, new SshSimpleProgress() {
|
|
|
|
|
@Override
|
|
|
|
|
public void update(int process) {
|
|
|
|
|
System.out.print(StrUtil.format("[INFO] upload jre {}", process + "%\r"));
|
|
|
|
|
@ -91,12 +100,12 @@ public class Deploy extends AbstractMojo {
|
|
|
|
|
});
|
|
|
|
|
printLog(StrUtil.format("upload jre {}", "finish"));
|
|
|
|
|
|
|
|
|
|
printLog("unpackage [jre.tar.gz]");
|
|
|
|
|
printLog("unpackage [{}]", jreFileName);
|
|
|
|
|
client.exec("cd {}", serverPath);
|
|
|
|
|
client.exec("tar -zxvf {} -C {}", serverPath + "/jre.tar.gz", serverPath);
|
|
|
|
|
client.exec("tar -zxvf {} -C {}", serverPath + "/" + jreFileName, serverPath);
|
|
|
|
|
|
|
|
|
|
printLog("delete [jre.tar.gz]");
|
|
|
|
|
client.deleteFile(serverPath + "/jre.tar.gz");
|
|
|
|
|
printLog("delete [{}]", jreFileName);
|
|
|
|
|
client.deleteFile(serverPath + "/" + jreFileName);
|
|
|
|
|
|
|
|
|
|
printLog("create dir [jar]");
|
|
|
|
|
client.createDirs(serverPath + "/jar");
|
|
|
|
|
|