提交 503b9474 编写于 作者: sq3536's avatar sq3536

push

上级 59774755
......@@ -52,6 +52,30 @@ public class CodegenConfig {
private String templateDir;
private String auth;
public CodegenConfig setInputSpec(String inputSpec) {
if(!StringUtils.isEmpty(inputSpec))
{
this.inputSpec=inputSpec.replace("\\", "/");
}
return this;
}
public CodegenConfig setOutputDir(String outputDir) {
if(!StringUtils.isEmpty(outputDir))
{
this.outputDir=outputDir.replace("\\", "/");
}
return this;
}
public CodegenConfig setTemplateDir(String templateDir) {
if(!StringUtils.isEmpty(templateDir))
{
this.templateDir=templateDir.replace("\\", "/");
}
return this;
}
private Map<String, Object> additionalProperties = new HashMap<>();
private Map<String, String> typeMappings;
......@@ -92,7 +116,8 @@ public class CodegenConfig {
scanTemplate(sub,templateDefinitions);
}
else {
templateDefinitions.add(new TemplateDefinition(Paths.get("/",file.getPath().replace(this.getTemplateDir(),"")).toString()));
String path=file.getPath().replace("\\","/");
templateDefinitions.add(new TemplateDefinition(Paths.get("/",path.replace(this.getTemplateDir(),"")).toString()));
}
}
......
......@@ -155,6 +155,7 @@ public class CodegenConstants {
public static final String ENSURE_UNIQUE_PARAMS_DESC = "Whether to ensure parameter names are unique in an operation (rename parameters that are not).";
public static final String PROJECT_NAME = "projectName";
public static final String PROJECT_DESC = "projectDesc";
public static final String PACKAGE_NAME = "packageName";
public static final String PACKAGE_NAME_DESC = "package for generated classes (where supported)";
......
......@@ -52,27 +52,18 @@ public class DefaultGenerator implements Generator {
protected ModelStorage modelStorage;
protected DynamicModelStorage dynamicModelStorage;
@SuppressWarnings("deprecation")
@Override
public Generator opts(CodegenConfig opts) {
this.config = opts;
dynamicModelStorage=DynamicModelStorage.getInstance().modelPath(this.config.getInputSpec());
modelStorage=ModelStorage.getInstance().config(config);
TemplateManagerOptions templateManagerOptions = new TemplateManagerOptions(this.config.isEnableMinimalUpdate(),this.config.isSkipOverwrite());
TemplatingEngineAdapter templatingEngine = this.config.getTemplatingEngine();
if (templatingEngine instanceof MustacheEngineAdapter) {
MustacheEngineAdapter mustacheEngineAdapter = (MustacheEngineAdapter) templatingEngine;
// mustacheEngineAdapter.setCompiler(this.config.processCompiler(mustacheEngineAdapter.getCompiler()));
}
TemplatePathLocator commonTemplateLocator = new CommonTemplateContentLocator();
TemplatePathLocator generatorTemplateLocator = new GeneratorTemplateContentLocator(this.config);
this.templateProcessor = new TemplateManager(
......@@ -82,20 +73,10 @@ public class DefaultGenerator implements Generator {
);
String ignoreFileLocation = this.config.getIgnoreFilePathOverride();
if (ignoreFileLocation != null) {
final File ignoreFile = new File(ignoreFileLocation);
if (ignoreFile.exists() && ignoreFile.canRead()) {
this.ignoreProcessor = new CodegenIgnoreProcessor(ignoreFile);
} else {
log.warn("Ignore file specified at {} is not valid. This will fall back to an existing ignore file if present in the output directory.", ignoreFileLocation);
}
}
if (this.ignoreProcessor == null) {
this.ignoreProcessor = new CodegenIgnoreProcessor(this.config.getOutputDir());
}
this.ignoreProcessor=CodegenIgnoreProcessor.getInstance(ignoreFileLocation,this.config.getOutputDir(),this.config.getTemplateDir());
return this;
}
......@@ -106,7 +87,7 @@ public class DefaultGenerator implements Generator {
for(TemplateDefinition templateDefinition:this.config.getTemplateDefinitions())
{
for(CliOption opt:templateDefinition.getTemplateDatas())
for(CliOption opt:templateDefinition.getTemplateDatas().getOptions())
{
try {
processTemplateToFile(opt,templateDefinition.getTemplateFile());
......@@ -147,16 +128,11 @@ public class DefaultGenerator implements Generator {
return defaultValue;
}
private DefaultMustacheFactory mf = new DefaultMustacheFactory();
protected File processTemplateToFile(Map<String, Object> templateData, String templateName) throws IOException {
StringWriter writer = new StringWriter();
Mustache mustache = mf.compile(new StringReader(templateName), "outputFilename");
mustache.execute(writer, templateData);
String outputFilename=writer.toString();
String outputFilename=this.templateProcessor.targetPath(templateData,templateName);
File target = Paths.get(this.config.getOutputDir(),outputFilename).toFile();
if (ignoreProcessor.allowsFile(target)) {
......
......@@ -21,6 +21,7 @@ import cn.ibizlab.codegen.ignore.rules.DirectoryRule;
import cn.ibizlab.codegen.ignore.rules.Rule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import java.io.*;
import java.nio.charset.StandardCharsets;
......@@ -34,90 +35,64 @@ import java.util.Locale;
*/
public class CodegenIgnoreProcessor {
private final Logger LOGGER = LoggerFactory.getLogger(CodegenIgnoreProcessor.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CodegenIgnoreProcessor.class);
private File ignoreFile = null;
private List<Rule> exclusionRules = new ArrayList<>();
private List<Rule> inclusionRules = new ArrayList<>();
/**
* Loads the default ignore file (.openapi-generator-ignore) from the specified path.
*
* @param baseDirectory The base directory of the files to be processed. This contains the ignore file.
*/
public CodegenIgnoreProcessor(final String baseDirectory) {
this(baseDirectory, ".ibizlab-generator-ignore");
}
/**
* Loads the specified ignore file by name ([ignoreFile]) from the specified path.
*
* @param baseDirectory The base directory of the files to be processed. This contains the ignore file.
* @param ignoreFile The file containing ignore patterns.
*/
@SuppressWarnings("WeakerAccess")
public CodegenIgnoreProcessor(final String baseDirectory, final String ignoreFile) {
final File directory = new File(baseDirectory);
final File targetIgnoreFile = new File(directory, ignoreFile);
if (directory.exists() && directory.isDirectory()) {
loadFromFile(targetIgnoreFile);
} else {
LOGGER.info("Output directory ({}) does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.", baseDirectory);
}
}
/**
* Constructs an instance of {@link CodegenIgnoreProcessor} from an ignore file defined by {@code targetIgnoreFile}.
*
* @param targetIgnoreFile The ignore file location.
*/
public CodegenIgnoreProcessor(final File targetIgnoreFile) {
loadFromFile(targetIgnoreFile);
}
private void loadFromFile(File targetIgnoreFile) {
if (targetIgnoreFile.exists() && targetIgnoreFile.isFile()) {
try {
loadCodegenRules(targetIgnoreFile);
this.ignoreFile = targetIgnoreFile;
} catch (IOException e) {
LOGGER.error(String.format(Locale.ROOT, "Could not process %s.", targetIgnoreFile.getName()), e.getMessage());
}
} else {
// log info message
LOGGER.info(String.format(Locale.ROOT, "No %s file found.", targetIgnoreFile.getName()));
}
}
void loadCodegenRules(final File codegenIgnore) throws IOException {
try (FileInputStream fileInputStream = new FileInputStream(codegenIgnore);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(inputStreamReader)) {
String line;
// NOTE: Comments that start with a : (e.g. //:) are pulled from git documentation for .gitignore
// see: https://github.com/git/git/blob/90f7b16b3adc78d4bbabbd426fb69aa78c714f71/Documentation/gitignore.txt
while ((line = reader.readLine()) != null) {
if(
//: A blank line matches no files, so it can serve as a separator for readability.
line.length() == 0
) continue;
Rule rule = Rule.create(line);
// rule could be null here if it's a COMMENT, for example
if(rule != null) {
if (Boolean.TRUE.equals(rule.getNegated())) {
inclusionRules.add(rule);
} else {
exclusionRules.add(rule);
public static CodegenIgnoreProcessor getInstance(final String... baseDirectorys) {
for(String baseDirectory:baseDirectorys)
{
if(StringUtils.isEmpty(baseDirectory))
continue;
final File directory = new File(baseDirectory);
final File targetIgnoreFile = new File(directory, ".ibizlab-generator-ignore");
if (directory.exists() && directory.isDirectory() && targetIgnoreFile.exists() && targetIgnoreFile.isFile()) {
CodegenIgnoreProcessor processor = new CodegenIgnoreProcessor();
try {
try (FileInputStream fileInputStream = new FileInputStream(targetIgnoreFile);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(inputStreamReader)) {
String line;
// NOTE: Comments that start with a : (e.g. //:) are pulled from git documentation for .gitignore
// see: https://github.com/git/git/blob/90f7b16b3adc78d4bbabbd426fb69aa78c714f71/Documentation/gitignore.txt
while ((line = reader.readLine()) != null) {
if(
//: A blank line matches no files, so it can serve as a separator for readability.
line.length() == 0
) continue;
Rule rule = Rule.create(line);
// rule could be null here if it's a COMMENT, for example
if(rule != null) {
if (Boolean.TRUE.equals(rule.getNegated())) {
processor.inclusionRules.add(rule);
} else {
processor.exclusionRules.add(rule);
}
}
}
}
processor.ignoreFile = targetIgnoreFile;
} catch (IOException e) {
LOGGER.error(String.format(Locale.ROOT, "Could not process %s.", targetIgnoreFile.getName()), e.getMessage());
}
return processor;
}
}
LOGGER.info("Output directory ({}) does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.", baseDirectorys);
return new CodegenIgnoreProcessor();
}
/**
* Determines whether or not a file defined by {@code toEvaluate} is allowed,
* under the exclusion rules from the ignore file being processed.
......
......@@ -177,6 +177,7 @@ public class DynamicModelStorage {
Assert.notNull(dataEntity,"未找到对应的实体模型:"+entity);
EntityModel entityModel=new EntityModel();
entityModel.setNode(dataEntity);
entityModel.setStorageMode(dataEntity.getStorageMode());
if(dataEntity.isLogicValid())
{
......
......@@ -498,4 +498,31 @@ public class EntityModel {
@JsonIgnore
@JSONField(serialize = false)
private Object node;
private String storageMode="SQL";
public void setStorageMode(Integer type)
{
switch(type){
case 0:
this.storageMode="NONE";
break;
case 1:
this.storageMode="SQL";
break;
case 2:
this.storageMode="NoSQL";
break;
case 4:
this.storageMode="ServiceAPI";
break;
default:
this.storageMode="SQL";
break;
}
}
public void setStorageMode(String type)
{
this.storageMode=type;
}
}
package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.CodegenConstants;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class CliData extends DataObj
{
public CliData set(String key, Object value)
{
this.put(key,value);
return this;
}
public CliData setAll(Map map)
{
if(map!=null)
this.putAll(map);
else if(this.size()==0)
return null;
return this;
}
private List<CliOption> options;
public List<CliOption> getOptions()
{
return options;
}
public CliData setOptions(List<CliOption> options) {
options.forEach(opt->addOption(opt));
return this;
}
public CliData addOption(CliOption option) {
if(this.options==null)
this.options=new ArrayList<>();
this.options.add(option);
List<CliOption> subTypes=null;
Object sub=this.get(option.getCliSubType());
if(sub==null)
{
subTypes=new ArrayList<>();
this.set(option.getCliSubType(),subTypes);
}
else
subTypes=(List<CliOption>)sub;
subTypes.add(option);
return this;
}
}
......@@ -10,7 +10,16 @@ import java.util.Map;
@JsonIgnoreProperties(ignoreUnknown = true)
public class CliOption extends DataObj
{
public CliOption setCliSubType(String type)
{
this.set("_cli-sub-type",type);
return this;
}
public String getCliSubType()
{
return this.getStringValue("_cli-sub-type","default");
}
public CliOption set(String key, Object value)
{
......@@ -36,8 +45,13 @@ public class CliOption extends DataObj
return this.set(CodegenConstants.PROJECT_NAME,projectName);
}
public CliOption setProjectDesc(String projectDesc)
{
return this.set(CodegenConstants.PROJECT_DESC,projectDesc);
}
public String getPackageName(){
return this.getStringValue("packageName");
return this.getStringValue("packageName","cn.ibizlab");
}
public CliOption setPackageName(String packageName)
......
......@@ -9,6 +9,7 @@ import cn.ibizlab.codegen.CodegenConstants;
import cn.ibizlab.codegen.templating.TemplateFileType;
import net.ibizsys.model.IPSSystem;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import java.nio.file.Paths;
import java.util.*;
......@@ -33,20 +34,25 @@ public class ModelStorage {
public ModelStorage config(CodegenConfig config)
{
this.config=config;
DynamicModelStorage.getInstance().modelPath(config.getInputSpec());
return this;
}
private DynamicModelStorage dynamicService=DynamicModelStorage.getInstance();
private String system=dynamicService.getDstSystemModel().getPssystemid();
public CliOption newCliOption()
{
CliOption opt=new CliOption();
opt.putAll(config.getAdditionalProperties());
IPSSystem ipsSystem=dynamicService.getPSSystem();
opt.setProjectName(config.getAdditionalProperties().getOrDefault(CodegenConstants.PROJECT_NAME,ipsSystem.getCodeName().toLowerCase()).toString());
opt.setPackageName(config.getAdditionalProperties().getOrDefault(CodegenConstants.PACKAGE_NAME,ipsSystem.getCodeName().toLowerCase()).toString());
if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_NAME)))
opt.setProjectName(ipsSystem.getCodeName().toLowerCase()).toString();
if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_DESC)))
opt.setProjectDesc(ipsSystem.getName().toLowerCase()).toString();
if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PACKAGE_NAME)))
opt.setPackageName(ipsSystem.getCodeName().toLowerCase()).toString();
return opt;
}
......@@ -71,20 +77,20 @@ public class ModelStorage {
return schema;
}
private Map<TemplateFileType,List<CliOption>> templateData=new HashMap<>();
private Map<TemplateFileType,CliData> templateData=new HashMap<>();
public List<CliOption> getTemplateData(TemplateFileType type)
public CliData getTemplateData(TemplateFileType type)
{
if(!templateData.containsKey(type))
{
List<CliOption> rt=new ArrayList();
CliData rt=new CliData();
if(type.equals(TemplateFileType.api))
{
if(dynamicService.getPSSystem().getAllPSSysServiceAPIs()!=null)
{
dynamicService.getPSSystem().getAllPSSysServiceAPIs().forEach(item->{
CliOption opt=newCliOption().set(TemplateFileType.api.toString(),item).set(TemplateFileType.api.value(),item.getCodeName().toLowerCase());
rt.add(opt);
rt.addOption(opt);
});
}
}
......@@ -94,7 +100,7 @@ public class ModelStorage {
{
dynamicService.getPSSystem().getAllPSApps().forEach(item->{
CliOption opt=newCliOption().set(TemplateFileType.app.toString(),item).set(TemplateFileType.app.value(),item.getCodeName().toLowerCase());
rt.add(opt);
rt.addOption(opt);
});
}
}
......@@ -105,7 +111,7 @@ public class ModelStorage {
{
api.getPSDEServiceAPIs().forEach(item->{
CliOption opt=newCliOption().set(TemplateFileType.serviceApi.toString(),item).set(TemplateFileType.serviceApi.value(),item.getCodeName());
rt.add(opt);
rt.addOption(opt);
});
}
});
......@@ -114,15 +120,26 @@ public class ModelStorage {
{
dynamicService.getPSSystem().getAllPSDataEntities().forEach(item->{
PojoSchema pojoSchema=this.getEntitySchema(item.getName());
CliOption opt=newCliOption().setModule(pojoSchema.getModule())
CliOption opt=newCliOption().setModule(pojoSchema.getModule()).setCliSubType(pojoSchema.getStorageMode())
.set(TemplateFileType.entity.toString(),pojoSchema).set(TemplateFileType.entity.value(),item.getCodeName());
rt.add(opt);
rt.addOption(opt);
});
}
else if(type.equals(TemplateFileType.module))
{
dynamicService.getPSSystem().getAllPSSystemModules().forEach(item->{
CliOption opt=newCliOption()
.set(TemplateFileType.module.toString(),item).set(TemplateFileType.module.value(),item.getCodeName());
rt.addOption(opt);
});
}
else if(type.equals(TemplateFileType.supportingFiles))
{
CliOption opt=newCliOption();
rt.add(opt);
opt.set(TemplateFileType.app.value(),getTemplateData(TemplateFileType.app));
opt.set(TemplateFileType.api.value(),getTemplateData(TemplateFileType.api));
opt.set(TemplateFileType.module.value(),getTemplateData(TemplateFileType.module));
rt.addOption(opt);
}
templateData.put(type,rt);
}
......
......@@ -81,6 +81,14 @@ public class PojoOption extends DataObj
return this.set("ds_types",dsTypes);
}
public PojoOption setStorageMode(String storageMode){
return this.set("storage_mode",storageMode);
}
public String getStorageMode(){
return this.getStringValue("storage_mode","SQL");
}
public String getDefaultQueryScript()
{
return this.getStringValue("default_query_script");
......
......@@ -104,6 +104,11 @@ public class PojoSchema {
@JsonIgnore
private Object node;
public String getStorageMode(){
return this.getOptions().getStorageMode();
}
@JSONField(serialize = false)
@JsonIgnore
public IPSDataEntity getDataEntity()
......
......@@ -16,7 +16,7 @@ public class TransUtils {
public static PojoSchema EntityModelModel2Schema(EntityModel entityModel)
{
PojoSchema pojoSchema=new PojoSchema().setName(entityModel.getEntityName()).setType("object").setTitle(entityModel.getLogicName()).setId(entityModel.getEntityId())
.setOptions(new PojoOption().setDsTypes(String.join(",",entityModel.getDsTypes())).setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal()));
.setOptions(new PojoOption().setDsTypes(String.join(",",entityModel.getDsTypes())).setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal()).setStorageMode(entityModel.getStorageMode()));
pojoSchema.getOptions().setAll(JSONObject.parseObject(JSON.toJSONString(entityModel.getEntity()))).remove("ext_params");
pojoSchema.setNode(entityModel.getNode());
......
......@@ -62,6 +62,17 @@ public class MustacheEngineAdapter implements TemplatingEngineAdapter {
return tmpl.execute(bundle);
}
@Override
public String compilePath(TemplatingExecutor executor, Map<String, Object> bundle, String templateFile) throws IOException {
Template tmpl = compiler
.withLoader(name -> findTemplate(executor, name))
.defaultValue("")
.compile(templateFile);
return tmpl.execute(bundle);
}
@SuppressWarnings("java:S108") // catch-all is expected, and is later thrown
public Reader findTemplate(TemplatingExecutor generator, String templateName) {
try {
......
package cn.ibizlab.codegen.templating;
import cn.ibizlab.codegen.model.CliData;
import cn.ibizlab.codegen.model.CliOption;
import cn.ibizlab.codegen.model.ModelStorage;
import lombok.Getter;
......@@ -22,7 +23,9 @@ public class TemplateDefinition {
protected TemplateFileType templateType;
protected List<CliOption> templateDatas;
private String subType="default";
protected CliData templateDatas;
public TemplateDefinition(String templateFile) {
if (templateFile == null) throw new IllegalArgumentException("templateFile may not be null.");
......
......@@ -2,14 +2,14 @@ package cn.ibizlab.codegen.templating;
public enum TemplateFileType {
api(Constants.APIS),
app(Constants.APPS),
entity(Constants.ENTITIES),
serviceApi(Constants.SERVICE_APIS),
ctrl(Constants.CTRLS),
page(Constants.PAGES),
appEntity(Constants.APP_ENTITIES),
serviceApi(Constants.SERVICE_APIS),
entity(Constants.ENTITIES),
module(Constants.MODULES),
page(Constants.PAGES),
ctrl(Constants.CTRLS),
api(Constants.APIS),
app(Constants.APPS),
supportingFiles(Constants.SUPPORTING_FILES);
private final String templateType;
......
......@@ -156,6 +156,12 @@ public class TemplateManager implements TemplatingExecutor, TemplateProcessor {
return writeToFile(target.getPath(), templateContent);
}
@Override
public String targetPath(Map<String, Object> data, String template) throws IOException {
String templateContent = this.engineAdapter.compilePath(this, data, template);
return templateContent;
}
@Override
public void ignore(Path path, String context) {
LOGGER.info("Ignored {} ({})", path, context);
......
......@@ -21,6 +21,8 @@ public interface TemplateProcessor {
*/
File write(Map<String, Object> data, String template, File target) throws IOException;
String targetPath(Map<String, Object> data, String template) throws IOException;
/**
* Write bytes to a file
*
......
......@@ -48,6 +48,9 @@ public interface TemplatingEngineAdapter {
String compileTemplate(TemplatingExecutor executor, Map<String, Object> bundle,
String templateFile) throws IOException;
String compilePath(TemplatingExecutor executor, Map<String, Object> bundle,
String templateFile) throws IOException;
/**
* Determines whether the template file with supported extensions exists. This may be on the filesystem,
* external filesystem, or classpath (implementation is up to TemplatingGenerator).
......
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
* Copyright 2018 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ibizlab.codegen.utils;
public class ImplementationVersion {
public static String read() {
// Assumes this version is required at runtime. This could be modified to use a properties file like the CLI.
String compiledVersion = ImplementationVersion.class.getPackage().getImplementationVersion();
if (compiledVersion != null) {
return compiledVersion;
}
// When running non-JARed class within an IDE the implementation version is not available, so we provide a means
// to set it externally via a system property so that generated artefacts contain the correct version.
return System.getProperty("openapitools.implementation.version", "unset");
}
}
......@@ -15,7 +15,9 @@
<packaging>pom</packaging>
<modules>
<module>{{projectName}}-app-web</module>
{{#apps}}
<module>{{projectName}}-app-{{apps}}</module>
{{/apps}}
</modules>
<dependencies>
......
......@@ -19,16 +19,22 @@
<artifactId>{{projectName}}-core</artifactId>
<version>${project.version}</version>
</dependency>
{{#apis}}
<dependency>
<groupId>{{packageName}}</groupId>
<artifactId>{{projectName}}-provider-{{apis}}</artifactId>
<version>${project.version}</version>
</dependency>
{{/apis}}
{{#apps}}
<dependency>
<groupId>{{packageName}}</groupId>
<artifactId>{{projectName}}-provider-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>{{packageName}}</groupId>
<artifactId>{{projectName}}-app-web</artifactId>
<artifactId>{{projectName}}-app-{{apps}}</artifactId>
<version>${project.version}</version>
</dependency>
{{/apps}}
</dependencies>
<!--由于boot是通过dependency来关联所有子项目,页面和配置等信息都存在与子项目中,
......
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>{{projectName}}</artifactId>
<groupId>{{packageName}}</groupId>
<version>1.0.0.0</version>
</parent>
<artifactId>{{projectName}}-provider</artifactId>
<name>{{projectDesc}} Provider</name>
<packaging>pom</packaging>
<description>{{projectDesc}} Provider</description>
<modules>
{{#apis}}
<module>{{projectName}}-provider-{{apis}}</module>
{{/apis}}
</modules>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>{{projectName}}-provider</artifactId>
<groupId>{{packageName}}</groupId>
<version>1.0.0.0</version>
</parent>
<artifactId>{{projectName}}-provider-{{apis}}</artifactId>
<name>{{projectDesc}} Microservice {{apis}}</name>
<description> microservice</description>
<packaging>${project.packaging}</packaging>
<dependencies>
<dependency>
<groupId>{{packageName}}</groupId>
<artifactId>{{projectName}}-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<properties>
<project.packaging>jar</project.packaging>
<docker.image.prefix>registry.cn-shanghai.aliyuncs.com/ibizsys</docker.image.prefix>
</properties>
<profiles>
<profile>
<id>{{apis}}</id>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>{{projectName}}-provider-api</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>{{packageName}}.api.{{projectName}}{{apis}}Application</mainClass>
<outputDirectory>../../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<serverId>ibiz-dev</serverId>
<imageName>${docker.image.prefix}/${project.artifactId}:latest</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>../../</directory>
<include>${project.artifactId}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>prepare</id>
<configuration>
<executable>cp</executable>
<arguments>
<argument>../../${project.artifactId}.jar</argument>
<argument>${project.basedir}/src/main/docker/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>buildpush</id>
<configuration>
<executable>docker</executable>
<arguments>
<argument>buildx</argument>
<argument>build</argument>
<argument>--platform</argument>
<argument>linux/amd64,linux/arm64</argument>
<argument>-t</argument>
<argument>${docker.image.prefix}/${project.artifactId}:latest</argument>
<argument>${project.basedir}/src/main/docker</argument>
<argument>--push</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>{{apis}}-war</id>
<properties>
<project.packaging>war</project.packaging>
</properties>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>{{projectName}}-provider-api</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>{{packageName}}.api.{{projectName}}{{apis}}Application</mainClass>
<outputDirectory>../../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<serverId>ibiz-dev</serverId>
<imageName>${docker.image.prefix}/${project.artifactId}:latest</imageName>
<dockerDirectory>${project.basedir}/src/main/dockerwar</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>../../</directory>
<include>${project.artifactId}.war</include>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>prepare</id>
<configuration>
<executable>cp</executable>
<arguments>
<argument>../../${project.artifactId}.war</argument>
<argument>${project.basedir}/src/main/dockerwar/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>buildpush</id>
<configuration>
<executable>docker</executable>
<arguments>
<argument>buildx</argument>
<argument>build</argument>
<argument>--platform</argument>
<argument>linux/arm64</argument>
<argument>-t</argument>
<argument>${docker.image.prefix}/${project.artifactId}:latest</argument>
<argument>${project.basedir}/src/main/dockerwar</argument>
<argument>--push</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>{{projectName}}</artifactId>
<groupId>{{packageName}}</groupId>
<version>1.0.0.0</version>
</parent>
<artifactId>{{projectName}}-util</artifactId>
<name>{{projectDesc}} Util</name>
<description>{{projectDesc}} Util</description>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem-spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo-shaded</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!-- Swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<!-- drools -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-json-converter</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-conf</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册