org.yes.tools.build.BuildMojo Maven / Gradle / Ivy
package org.yes.tools.build;
import freemarker.template.TemplateException;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.yes.tools.build.bo.DeployBo;
import org.yes.tools.build.handle.BuildHandle;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
/**
* @author Co.
* @name BuildMojo
* @date 2023/6/19 10:54
*/
@Mojo(name = "yes-build")
public class BuildMojo extends DeployBo {
@Parameter(property = "aPackage")
public Package aPackage = new Package();
public static class Package {
@Parameter(property = "image")
protected String image;
@Parameter(property = "projectPackageLists")
protected List projectPackageLists;
}
/**
* 日志工具
*/
protected Log log = getLog();
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (aPackage.projectPackageLists.size() <= 0) {
System.out.println("请填入包名");
return;
}
if (StringUtils.isEmpty(aPackage.image)) {
System.out.println("请填入镜像名称");
return;
}
try {
BuildHandle.generateDockerFile(aPackage.projectPackageLists, aPackage.image, log, deploy);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (TemplateException e) {
throw new RuntimeException(e);
}
}
}