Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
b6d3c63c
提交
b6d3c63c
编写于
6月 29, 2022
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
129
上级
a881b53d
变更
24
显示空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
260 行增加
和
24 行删除
+260
-24
IbizLabGenerator.java
...li/src/main/java/cn/ibizlab/codegen/IbizLabGenerator.java
+1
-0
Generate.java
...or-cli/src/main/java/cn/ibizlab/codegen/cmd/Generate.java
+7
-0
ListCommand.java
...cli/src/main/java/cn/ibizlab/codegen/cmd/ListCommand.java
+79
-0
CodegenConfig.java
...-core/src/main/java/cn/ibizlab/codegen/CodegenConfig.java
+55
-1
CodegenConfigurator.java
...n/java/cn/ibizlab/codegen/config/CodegenConfigurator.java
+11
-4
CommonTemplateContentLocator.java
...zlab/codegen/templating/CommonTemplateContentLocator.java
+51
-1
GeneratorTemplateContentLocator.java
...b/codegen/templating/GeneratorTemplateContentLocator.java
+2
-1
TemplateManager.java
...n/java/cn/ibizlab/codegen/templating/TemplateManager.java
+12
-5
pom.xml.hbs
...rator-core/src/main/resources/templ/ibiz-boot/pom.xml.hbs
+2
-6
pom.xml.hbs
...esources/templ/ibiz-boot/{{projectName}}-boot/pom.xml.hbs
+6
-3
.ibizlab-generator-ignore
.../main/resources/templ/ibiz-boot/.ibizlab-generator-ignore
+3
-0
pom.xml.hbs
...esources/templ/ibiz-boot/{{projectName}}-core/pom.xml.hbs
+23
-0
MybatisConfiguration.java.hbs
...{{packageName}}/util/config/MybatisConfiguration.java.hbs
+0
-0
{{entities@NONE}}TypeHandler.java.hbs
...s}}/domain/handlers/{{entities@NONE}}TypeHandler.java.hbs
+0
-0
{{entities@NONE}}.java.hbs
...ckageName}}/{{modules}}/domain/{{entities@NONE}}.java.hbs
+0
-0
{{entities@SQL}}.java.hbs
...ackageName}}/{{modules}}/domain/{{entities@SQL}}.java.hbs
+0
-0
{{entities@ServiceAPI}}.java.hbs
...ame}}/{{modules}}/domain/{{entities@ServiceAPI}}.java.hbs
+0
-0
{{entities}}SearchContext.java.hbs
...e}}/{{modules}}/filter/{{entities}}SearchContext.java.hbs
+0
-0
{{entities@SQL}}Mapper.java.hbs
...Name}}/{{modules}}/mapper/{{entities@SQL}}Mapper.java.hbs
+0
-0
I{{entities@SQL}}Service.java.hbs
...e}}/{{modules}}/service/I{{entities@SQL}}Service.java.hbs
+0
-0
{{entities@SQL}}ServiceImpl.java.hbs
...dules}}/service/impl/{{entities@SQL}}ServiceImpl.java.hbs
+0
-0
{{entities@SQL}}Mapper.xml.hbs
...r/{{modules}}/{{entities}}/{{entities@SQL}}Mapper.xml.hbs
+0
-0
pom.xml
modules/ibizlab-generator-plugin/pom.xml
+1
-3
GenerateMojo.java
...plugin/src/main/java/cn/ibizlab/codegen/GenerateMojo.java
+7
-0
未找到文件。
modules/ibizlab-generator-cli/src/main/java/cn/ibizlab/codegen/IbizLabGenerator.java
浏览文件 @
b6d3c63c
...
@@ -26,6 +26,7 @@ public class IbizLabGenerator {
...
@@ -26,6 +26,7 @@ public class IbizLabGenerator {
Generate
.
class
,
Generate
.
class
,
HelpCommand
.
class
,
HelpCommand
.
class
,
Version
.
class
,
Version
.
class
,
ListCommand
.
class
,
CompletionCommand
.
class
CompletionCommand
.
class
);
);
...
...
modules/ibizlab-generator-cli/src/main/java/cn/ibizlab/codegen/cmd/Generate.java
浏览文件 @
b6d3c63c
...
@@ -45,6 +45,9 @@ public class Generate extends IbizLabGeneratorCommand {
...
@@ -45,6 +45,9 @@ public class Generate extends IbizLabGeneratorCommand {
"(or multiple options, each with -t /templateA -t /tmp/templateB)"
)
"(or multiple options, each with -t /templateA -t /tmp/templateB)"
)
private
List
<
String
>
templateDirs
;
private
List
<
String
>
templateDirs
;
@Option
(
name
=
{
"--template-name"
},
title
=
"template name"
,
description
=
"special template name, e.g. r7 or r8 or ibiz-boot or doc, sets template name properties that can be load inner template from class-path/resources "
)
private
String
templateName
;
@Option
(
name
=
{
"--template-path"
},
title
=
"template files relative path"
,
@Option
(
name
=
{
"--template-path"
},
title
=
"template files relative path"
,
description
=
"special template file's relative path, multiple paths are supported, the format of /folderA/README.md.hbs,/folderB/sub/file.json.hbs "
+
description
=
"special template file's relative path, multiple paths are supported, the format of /folderA/README.md.hbs,/folderB/sub/file.json.hbs "
+
...
@@ -169,6 +172,10 @@ public class Generate extends IbizLabGeneratorCommand {
...
@@ -169,6 +172,10 @@ public class Generate extends IbizLabGeneratorCommand {
configurator
.
setTemplateDirs
(
templateDirs
);
configurator
.
setTemplateDirs
(
templateDirs
);
}
}
if
(!
StringUtils
.
isEmpty
(
templateName
))
{
configurator
.
setTemplateName
(
templateName
);
}
if
(!
ObjectUtils
.
isEmpty
(
templatePaths
))
{
if
(!
ObjectUtils
.
isEmpty
(
templatePaths
))
{
configurator
.
setTemplatePaths
(
templatePaths
);
configurator
.
setTemplatePaths
(
templatePaths
);
}
}
...
...
modules/ibizlab-generator-cli/src/main/java/cn/ibizlab/codegen/cmd/ListCommand.java
0 → 100644
浏览文件 @
b6d3c63c
package
cn
.
ibizlab
.
codegen
.
cmd
;
import
cn.ibizlab.codegen.templating.TemplateManager
;
import
io.airlift.airline.Command
;
import
io.airlift.airline.Option
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
import
org.springframework.util.StringUtils
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Scanner
;
@SuppressWarnings
({
"unused"
,
"java:S106"
})
@Command
(
name
=
"ls"
,
description
=
"Show list information used in tooling"
)
public
class
ListCommand
extends
IbizLabGeneratorCommand
{
@Option
(
name
=
{
"-n"
,
"--template-name"
},
description
=
"sepc template list"
)
private
String
template
;
@Option
(
name
=
{
"-a"
,
"--all"
},
description
=
"template list"
)
private
Boolean
all
;
@Override
public
void
execute
()
{
List
<
String
>
retList
=
new
ArrayList
<>();
if
(!
StringUtils
.
isEmpty
(
template
))
{
getList
(
"templ/"
+
template
,
""
,
retList
,
true
);
}
else
{
getList
(
"templ"
,
""
,
retList
,
false
);
}
retList
.
forEach
(
item
->
System
.
out
.
println
(
item
));
}
private
ResourcePatternResolver
resourceResolver
=
new
PathMatchingResourcePatternResolver
();
public
void
getList
(
String
rootDir
,
String
templateDir
,
List
<
String
>
list
,
boolean
recu
)
{
try
{
if
(
templateDir
.
endsWith
(
"//"
))
return
;
URL
url
=
this
.
getClass
().
getClassLoader
().
getResource
(
rootDir
+
"/"
+
templateDir
);
if
(
url
!=
null
)
{
InputStream
stream
=
this
.
getClass
().
getClassLoader
().
getResourceAsStream
(
rootDir
+
"/"
+
templateDir
);
try
(
Scanner
scanner
=
new
Scanner
(
stream
))
{
while
(
scanner
.
hasNextLine
())
{
String
str
=
scanner
.
nextLine
();
if
(!
StringUtils
.
isEmpty
(
str
))
{
String
newPath
=
str
;
if
(!
StringUtils
.
isEmpty
(
templateDir
))
newPath
=
templateDir
+
"/"
+
str
;
if
(
recu
&&(!
str
.
endsWith
(
".hbs"
))&&(!
str
.
endsWith
(
".ibizlab-generator-ignore"
))&&(
str
.
indexOf
(
"."
)<
0
))
getList
(
rootDir
,
newPath
,
list
,
recu
);
else
list
.
add
(
newPath
);
}
}
}
catch
(
Exception
e
)
{
}
}
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
}
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/CodegenConfig.java
浏览文件 @
b6d3c63c
...
@@ -18,6 +18,7 @@ import org.springframework.util.ObjectUtils;
...
@@ -18,6 +18,7 @@ import org.springframework.util.ObjectUtils;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.net.URL
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -32,6 +33,7 @@ public class CodegenConfig {
...
@@ -32,6 +33,7 @@ public class CodegenConfig {
private
String
inputSpec
;
private
String
inputSpec
;
private
String
outputDir
;
private
String
outputDir
;
private
List
<
String
>
filters
;
private
List
<
String
>
filters
;
...
@@ -39,6 +41,9 @@ public class CodegenConfig {
...
@@ -39,6 +41,9 @@ public class CodegenConfig {
private
CliFilter
cliFilter
;
private
CliFilter
cliFilter
;
private
List
<
String
>
templateDirs
;
private
List
<
String
>
templateDirs
;
private
String
templateName
;
private
String
auth
;
private
String
auth
;
private
List
<
String
>
templatePaths
;
private
List
<
String
>
templatePaths
;
...
@@ -161,6 +166,23 @@ public class CodegenConfig {
...
@@ -161,6 +166,23 @@ public class CodegenConfig {
private
TemplateManager
templateProcessor
;
private
TemplateManager
templateProcessor
;
private
CommonTemplateContentLocator
commonTemplateContentLocator
;
public
CommonTemplateContentLocator
getCommonTemplateContentLocator
()
{
if
((!
StringUtils
.
isEmpty
(
templateName
))&&
commonTemplateContentLocator
==
null
)
{
String
loc
=
TemplateManager
.
getCPResourcePath
(
Paths
.
get
(
"templ"
,
templateName
).
toString
());
URL
url
=
this
.
getClass
().
getClassLoader
().
getResource
(
loc
);
if
(
url
!=
null
)
{
commonTemplateContentLocator
=
new
CommonTemplateContentLocator
(
loc
);
LOGGER
.
info
(
"Loaded embed template from resources ({})."
,
loc
);
}
else
{
LOGGER
.
error
(
"Failed to Load embed template from resources ({}), not found."
,
loc
);
}
}
return
commonTemplateContentLocator
;
}
public
TemplateManager
getTemplateProcessor
()
public
TemplateManager
getTemplateProcessor
()
{
{
if
(
templateProcessor
==
null
)
if
(
templateProcessor
==
null
)
...
@@ -171,7 +193,9 @@ public class CodegenConfig {
...
@@ -171,7 +193,9 @@ public class CodegenConfig {
this
.
getTemplateDirs
().
forEach
(
templateDir
->{
this
.
getTemplateDirs
().
forEach
(
templateDir
->{
list
.
add
(
new
GeneratorTemplateContentLocator
(
templateDir
));
list
.
add
(
new
GeneratorTemplateContentLocator
(
templateDir
));
});
});
list
.
add
(
new
CommonTemplateContentLocator
());
if
(
getCommonTemplateContentLocator
()!=
null
)
{
list
.
add
(
commonTemplateContentLocator
);
}
this
.
templateProcessor
=
new
TemplateManager
(
this
.
templateProcessor
=
new
TemplateManager
(
new
TemplateManagerOptions
(
this
.
isEnableMinimalUpdate
(),
this
.
isSkipOverwrite
()),
new
TemplateManagerOptions
(
this
.
isEnableMinimalUpdate
(),
this
.
isSkipOverwrite
()),
templatingEngine
,
templatingEngine
,
...
@@ -233,6 +257,7 @@ public class CodegenConfig {
...
@@ -233,6 +257,7 @@ public class CodegenConfig {
}
}
scanEmbedTemplate
(
templates
);
}
}
return
templates
.
values
();
return
templates
.
values
();
...
@@ -293,6 +318,35 @@ public class CodegenConfig {
...
@@ -293,6 +318,35 @@ public class CodegenConfig {
}
}
}
}
private
void
scanEmbedTemplate
(
Map
<
String
,
TemplateDefinition
>
templateDefinitions
)
{
if
(
this
.
getCommonTemplateContentLocator
()!=
null
)
{
this
.
getCommonTemplateContentLocator
().
getTemplatePaths
().
forEach
(
item
->{
String
path
=
item
;
if
(!
path
.
startsWith
(
"/"
))
path
=
"/"
+
path
;
if
(!
ObjectUtils
.
isEmpty
(
this
.
templateFilters
))
{
boolean
matched
=
false
;
for
(
String
filter:
this
.
templateFilters
)
{
if
(
path
.
matches
(
filter
))
{
matched
=
true
;
break
;
}
}
if
(!
matched
)
return
;
}
if
(!
templateDefinitions
.
containsKey
(
path
)){
TemplateDefinition
templateDefinition
=
new
TemplateDefinition
(
path
,
this
.
getCommonTemplateContentLocator
().
getResourceLocation
());
templateDefinitions
.
put
(
path
,
templateDefinition
);
}
});
}
}
@SuppressWarnings
(
"static-method"
)
@SuppressWarnings
(
"static-method"
)
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/config/CodegenConfigurator.java
浏览文件 @
b6d3c63c
...
@@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
...
@@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Paths
;
import
java.util.*
;
import
java.util.*
;
import
static
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotEmpty
;
import
static
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotEmpty
;
...
@@ -40,6 +41,7 @@ public final class CodegenConfigurator {
...
@@ -40,6 +41,7 @@ public final class CodegenConfigurator {
private
String
outputDir
;
private
String
outputDir
;
private
List
<
String
>
filters
;
private
List
<
String
>
filters
;
private
List
<
String
>
templateDirs
;
private
List
<
String
>
templateDirs
;
private
String
templateName
;
private
List
<
String
>
templatePaths
;
private
List
<
String
>
templatePaths
;
private
List
<
String
>
templateFilters
;
private
List
<
String
>
templateFilters
;
private
String
auth
;
private
String
auth
;
...
@@ -202,19 +204,21 @@ public final class CodegenConfigurator {
...
@@ -202,19 +204,21 @@ public final class CodegenConfigurator {
return
this
;
return
this
;
}
}
public
CodegenConfigurator
setOutputDir
(
String
outputDir
)
{
public
CodegenConfigurator
setOutputDir
(
String
outputDir
)
{
this
.
outputDir
=
outputDir
;
this
.
outputDir
=
outputDir
;
return
this
;
return
this
;
}
}
public
CodegenConfigurator
setTemplateDirs
(
List
<
String
>
templateDirs
)
{
public
CodegenConfigurator
setTemplateDirs
(
List
<
String
>
templateDirs
)
{
this
.
templateDirs
=
templateDirs
;
this
.
templateDirs
=
templateDirs
;
return
this
;
return
this
;
}
}
public
CodegenConfigurator
setTemplateName
(
String
templateName
)
{
this
.
templateName
=
templateName
;
return
this
;
}
public
CodegenConfigurator
setTemplatePaths
(
List
<
String
>
templatePaths
)
{
public
CodegenConfigurator
setTemplatePaths
(
List
<
String
>
templatePaths
)
{
this
.
templatePaths
=
templatePaths
;
this
.
templatePaths
=
templatePaths
;
return
this
;
return
this
;
...
@@ -260,6 +264,10 @@ public final class CodegenConfigurator {
...
@@ -260,6 +264,10 @@ public final class CodegenConfigurator {
config
.
setTemplateDirs
(
this
.
templateDirs
);
config
.
setTemplateDirs
(
this
.
templateDirs
);
}
}
if
(!
StringUtils
.
isEmpty
(
templateName
))
{
config
.
setTemplateName
(
this
.
templateName
);
}
if
(!
ObjectUtils
.
isEmpty
(
templatePaths
))
{
if
(!
ObjectUtils
.
isEmpty
(
templatePaths
))
{
config
.
setTemplatePaths
(
this
.
templatePaths
);
config
.
setTemplatePaths
(
this
.
templatePaths
);
}
}
...
@@ -274,5 +282,4 @@ public final class CodegenConfigurator {
...
@@ -274,5 +282,4 @@ public final class CodegenConfigurator {
return
config
;
return
config
;
}
}
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/CommonTemplateContentLocator.java
浏览文件 @
b6d3c63c
...
@@ -3,7 +3,12 @@ package cn.ibizlab.codegen.templating;
...
@@ -3,7 +3,12 @@ package cn.ibizlab.codegen.templating;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.net.URL
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Scanner
;
/**
/**
* Locates generator-agnostic templates from a common built-in location.
* Locates generator-agnostic templates from a common built-in location.
...
@@ -27,6 +32,10 @@ public class CommonTemplateContentLocator implements TemplatePathLocator {
...
@@ -27,6 +32,10 @@ public class CommonTemplateContentLocator implements TemplatePathLocator {
this
.
resourceLocation
=
resourceLocation
;
this
.
resourceLocation
=
resourceLocation
;
}
}
public
String
getResourceLocation
()
{
return
resourceLocation
;
}
/**
/**
* Get the full path to a relative template file.
* Get the full path to a relative template file.
*
*
...
@@ -36,7 +45,7 @@ public class CommonTemplateContentLocator implements TemplatePathLocator {
...
@@ -36,7 +45,7 @@ public class CommonTemplateContentLocator implements TemplatePathLocator {
@Override
@Override
public
String
getFullTemplatePath
(
String
relativeTemplateFile
)
{
public
String
getFullTemplatePath
(
String
relativeTemplateFile
)
{
if
(
StringUtils
.
isNotEmpty
(
relativeTemplateFile
))
{
if
(
StringUtils
.
isNotEmpty
(
relativeTemplateFile
))
{
String
loc
=
this
.
resourceLocation
+
File
.
separator
+
relativeTemplateFile
;
String
loc
=
Paths
.
get
(
this
.
resourceLocation
,
relativeTemplateFile
).
toString
()
;
URL
url
=
this
.
getClass
().
getClassLoader
().
getResource
(
TemplateManager
.
getCPResourcePath
(
loc
));
URL
url
=
this
.
getClass
().
getClassLoader
().
getResource
(
TemplateManager
.
getCPResourcePath
(
loc
));
if
(
url
!=
null
)
{
if
(
url
!=
null
)
{
...
@@ -45,4 +54,45 @@ public class CommonTemplateContentLocator implements TemplatePathLocator {
...
@@ -45,4 +54,45 @@ public class CommonTemplateContentLocator implements TemplatePathLocator {
}
}
return
null
;
return
null
;
}
}
public
List
<
String
>
getTemplatePaths
()
{
List
<
String
>
list
=
new
ArrayList
<>();
getList
(
this
.
resourceLocation
,
""
,
list
,
true
);
return
list
;
}
private
void
getList
(
String
rootDir
,
String
templateDir
,
List
<
String
>
list
,
boolean
recu
)
{
try
{
if
(
templateDir
.
endsWith
(
"//"
))
return
;
URL
url
=
this
.
getClass
().
getClassLoader
().
getResource
(
rootDir
+
"/"
+
templateDir
);
if
(
url
!=
null
)
{
InputStream
stream
=
this
.
getClass
().
getClassLoader
().
getResourceAsStream
(
rootDir
+
"/"
+
templateDir
);
try
(
Scanner
scanner
=
new
Scanner
(
stream
))
{
while
(
scanner
.
hasNextLine
())
{
String
str
=
scanner
.
nextLine
();
if
(!
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
str
))
{
String
newPath
=
str
;
if
(!
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
templateDir
))
newPath
=
templateDir
+
"/"
+
str
;
if
(
recu
&&(!
str
.
endsWith
(
".hbs"
))&&(!
str
.
endsWith
(
".ibizlab-generator-ignore"
))&&(
str
.
indexOf
(
"."
)<
0
))
getList
(
rootDir
,
newPath
,
list
,
recu
);
else
list
.
add
(
newPath
);
}
}
}
catch
(
Exception
e
)
{
}
}
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
}
}
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/GeneratorTemplateContentLocator.java
浏览文件 @
b6d3c63c
...
@@ -3,6 +3,7 @@ package cn.ibizlab.codegen.templating;
...
@@ -3,6 +3,7 @@ package cn.ibizlab.codegen.templating;
import
cn.ibizlab.codegen.CodegenConfig
;
import
cn.ibizlab.codegen.CodegenConfig
;
import
java.io.File
;
import
java.io.File
;
import
java.nio.file.Paths
;
/**
/**
* Locates templates according to {@link CodegenConfig} settings.
* Locates templates according to {@link CodegenConfig} settings.
...
@@ -21,7 +22,7 @@ public class GeneratorTemplateContentLocator implements TemplatePathLocator {
...
@@ -21,7 +22,7 @@ public class GeneratorTemplateContentLocator implements TemplatePathLocator {
// check the supplied template main folder for the file
// check the supplied template main folder for the file
// File.separator is necessary here as the file load is OS-specific
// File.separator is necessary here as the file load is OS-specific
final
String
template
=
templateDir
+
File
.
separator
+
relativeTemplateFile
;
final
String
template
=
Paths
.
get
(
templateDir
,
relativeTemplateFile
).
toString
()
;
// looks for user-defined file or classpath
// looks for user-defined file or classpath
// supports template dir which refers to local file system or custom path in classpath as defined by templateDir
// supports template dir which refers to local file system or custom path in classpath as defined by templateDir
if
(
new
File
(
template
).
exists
())
{
if
(
new
File
(
template
).
exists
())
{
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/TemplateManager.java
浏览文件 @
b6d3c63c
...
@@ -147,17 +147,24 @@ public class TemplateManager implements TemplatingExecutor, TemplateProcessor {
...
@@ -147,17 +147,24 @@ public class TemplateManager implements TemplatingExecutor, TemplateProcessor {
*/
*/
@Override
@Override
public
File
write
(
Map
<
String
,
Object
>
data
,
String
template
,
File
target
)
throws
IOException
{
public
File
write
(
Map
<
String
,
Object
>
data
,
String
template
,
File
target
)
throws
IOException
{
String
templateContent
=
""
;
if
(!
this
.
engineAdapter
.
handlesFile
(
template
))
if
(!
this
.
engineAdapter
.
handlesFile
(
template
))
{
{
File
dir
=
target
.
getParentFile
();
File
dir
=
target
.
getParentFile
();
if
(!
dir
.
exists
())
if
(!
dir
.
exists
())
dir
.
mkdirs
();
dir
.
mkdirs
();
Files
.
copy
(
this
.
getFullTemplatePath
(
template
),
Paths
.
get
(
target
.
getPath
()),
StandardCopyOption
.
REPLACE_EXISTING
);
Path
srcPath
=
this
.
getFullTemplatePath
(
template
);
if
(
srcPath
.
toFile
().
exists
())
{
Files
.
copy
(
srcPath
,
Paths
.
get
(
target
.
getPath
()),
StandardCopyOption
.
REPLACE_EXISTING
);
return
target
;
return
target
;
}
}
else
String
templateContent
=
this
.
engineAdapter
.
compileTemplate
(
this
,
data
,
template
);
{
templateContent
=
getFullTemplateContents
(
template
);
}
}
else
templateContent
=
this
.
engineAdapter
.
compileTemplate
(
this
,
data
,
template
);
if
(
StringUtils
.
isEmpty
(
templateContent
))
if
(
StringUtils
.
isEmpty
(
templateContent
))
return
null
;
return
null
;
return
writeToFile
(
target
.
getPath
(),
templateContent
);
return
writeToFile
(
target
.
getPath
(),
templateContent
);
...
...
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/pom.xml.hbs
浏览文件 @
b6d3c63c
...
@@ -16,16 +16,12 @@
...
@@ -16,16 +16,12 @@
<version>
2.4.0
</version>
<version>
2.4.0
</version>
</parent>
</parent>
<modules>
<modules>
<module>
{{
projectName
}}
-
pub
</module>
<module>
{{
projectName
}}
-
core
</module>
<!-- boot -->
<!-- boot -->
<module>
{{
projectName
}}
-boot
</module>
<module>
{{
projectName
}}
-boot
</module>
</modules>
</modules>
<dependencies>
<dependencies>
<dependency>
<groupId>
net.ibizsys.plugin
</groupId>
<artifactId>
ibiz-boot-starter
</artifactId>
<version>
2.4.0.129
</version>
</dependency>
<!--达梦数据库-->
<!--达梦数据库-->
<dependency>
<dependency>
<groupId>
com.dameng
</groupId>
<groupId>
com.dameng
</groupId>
...
...
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-boot/pom.xml.hbs
浏览文件 @
b6d3c63c
...
@@ -10,13 +10,13 @@
...
@@ -10,13 +10,13 @@
</parent>
</parent>
<artifactId>
{{
projectName
}}
-boot
</artifactId>
<artifactId>
{{
projectName
}}
-boot
</artifactId>
<name>
{{
projectDesc
}}
Dev Monolithic Boot
</name>
<name>
{{
projectDesc
}}
Boot [
{{
projectName
}}
-boot]
</name>
<description>
{{
projectDesc
}}
Boot
</description>
<description>
{{
projectDesc
}}
Boot
</description>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
{{
packageName
}}
</groupId>
<groupId>
{{
packageName
}}
</groupId>
<artifactId>
{{
projectName
}}
-
pub
</artifactId>
<artifactId>
{{
projectName
}}
-
core
</artifactId>
<version>
1.0.0.0
</version>
<version>
1.0.0.0
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
@@ -70,8 +70,11 @@
...
@@ -70,8 +70,11 @@
${basedir}/src/main/resources/model/com/sa/jcsc
${basedir}/src/main/resources/model/com/sa/jcsc
</inputSpec>
</inputSpec>
<templateDirs>
<templateDirs>
/Users/mac/workshop/ibizlab-generator/modules/ibizlab-generator-core
/src/main/resources/templ/ibiz-boot
${basedir}
/src/main/resources/templ/ibiz-boot
</templateDirs>
</templateDirs>
<templateName>
ibiz-boot
</templateName>
<packageName>
<packageName>
${project.groupId}
${project.groupId}
</packageName>
</packageName>
...
...
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-boot/src/main/resources/templ/ibiz-boot/.ibizlab-generator-ignore
0 → 100644
浏览文件 @
b6d3c63c
**.ibizlab-generator-ignore
**.DS_Store
**@macro/**
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/pom.xml.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/pom.xml.hbs
浏览文件 @
b6d3c63c
...
@@ -9,8 +9,15 @@
...
@@ -9,8 +9,15 @@
<version>
1.0.0.0
</version>
<version>
1.0.0.0
</version>
</parent>
</parent>
<artifactId>
{{
projectName
}}
-
pub
</artifactId>
<artifactId>
{{
projectName
}}
-
core
</artifactId>
<name>
{{
projectDesc
}}
Generator Code
</name>
<name>
{{
projectDesc
}}
Generator Code
[
{{
projectName
}}
-core]
</name>
<description>
{{
projectDesc
}}
模板生成代码,不要直接修改,修改请在
{{
projectName
}}
-boot项目中重写
</description>
<description>
{{
projectDesc
}}
模板生成代码,
再次发布会覆盖,建议
不要直接修改,修改请在
{{
projectName
}}
-boot项目中重写
</description>
<dependencies>
<dependency>
<groupId>
net.ibizsys.plugin
</groupId>
<artifactId>
ibiz-boot-starter
</artifactId>
<version>
2.4.0.132
</version>
</dependency>
</dependencies>
</project>
</project>
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/util/config/MybatisConfiguration.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/util/config/MybatisConfiguration.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/{{modules}}/domain/handlers/{{entities@NONE}}TypeHandler.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/{{modules}}/domain/handlers/{{entities@NONE}}TypeHandler.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/{{modules}}/domain/{{entities@NONE}}.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/{{modules}}/domain/{{entities@NONE}}.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/{{modules}}/domain/{{entities@SQL}}.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/{{modules}}/domain/{{entities@SQL}}.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/{{modules}}/domain/{{entities@ServiceAPI}}.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/{{modules}}/domain/{{entities@ServiceAPI}}.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/{{modules}}/filter/{{entities}}SearchContext.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/{{modules}}/filter/{{entities}}SearchContext.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/{{modules}}/mapper/{{entities@SQL}}Mapper.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/{{modules}}/mapper/{{entities@SQL}}Mapper.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/{{modules}}/service/I{{entities@SQL}}Service.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/{{modules}}/service/I{{entities@SQL}}Service.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/java/{{packageName}}/{{modules}}/service/impl/{{entities@SQL}}ServiceImpl.java.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/java/{{packageName}}/{{modules}}/service/impl/{{entities@SQL}}ServiceImpl.java.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
pub
/src/main/resources/mapper/{{modules}}/{{entities}}/{{entities@SQL}}Mapper.xml.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/ibiz-boot/{{projectName}}-
core
/src/main/resources/mapper/{{modules}}/{{entities}}/{{entities@SQL}}Mapper.xml.hbs
浏览文件 @
b6d3c63c
文件已移动
modules/ibizlab-generator-plugin/pom.xml
浏览文件 @
b6d3c63c
...
@@ -91,9 +91,7 @@
...
@@ -91,9 +91,7 @@
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
<configuration>
<configuration>
<template>
<!-- <controller>/template/controller.java.vm</controller> -->
</template>
</configuration>
</configuration>
</plugin>
</plugin>
...
...
modules/ibizlab-generator-plugin/src/main/java/cn/ibizlab/codegen/GenerateMojo.java
浏览文件 @
b6d3c63c
...
@@ -3,6 +3,7 @@ package cn.ibizlab.codegen;
...
@@ -3,6 +3,7 @@ package cn.ibizlab.codegen;
import
cn.ibizlab.codegen.config.CodegenConfigurator
;
import
cn.ibizlab.codegen.config.CodegenConfigurator
;
import
cn.ibizlab.codegen.config.CodegenConfiguratorUtils
;
import
cn.ibizlab.codegen.config.CodegenConfiguratorUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.maven.plugin.AbstractMojo
;
import
org.apache.maven.plugin.AbstractMojo
;
import
org.apache.maven.plugin.MojoExecutionException
;
import
org.apache.maven.plugin.MojoExecutionException
;
import
org.apache.maven.plugin.MojoFailureException
;
import
org.apache.maven.plugin.MojoFailureException
;
...
@@ -40,6 +41,8 @@ public class GenerateMojo extends AbstractMojo {
...
@@ -40,6 +41,8 @@ public class GenerateMojo extends AbstractMojo {
@Parameter
@Parameter
private
String
[]
templateDirs
;
private
String
[]
templateDirs
;
@Parameter
private
String
templateName
;
@Parameter
@Parameter
private
String
[]
templatePaths
;
private
String
[]
templatePaths
;
...
@@ -133,6 +136,10 @@ public class GenerateMojo extends AbstractMojo {
...
@@ -133,6 +136,10 @@ public class GenerateMojo extends AbstractMojo {
configurator
.
setTemplateDirs
(
Arrays
.
asList
(
templateDirs
));
configurator
.
setTemplateDirs
(
Arrays
.
asList
(
templateDirs
));
}
}
if
(!
StringUtils
.
isEmpty
(
templateName
))
{
configurator
.
setTemplateName
(
this
.
templateName
);
}
if
(!
ObjectUtils
.
isEmpty
(
templatePaths
))
{
if
(!
ObjectUtils
.
isEmpty
(
templatePaths
))
{
configurator
.
setTemplatePaths
(
Arrays
.
asList
(
templatePaths
));
configurator
.
setTemplatePaths
(
Arrays
.
asList
(
templatePaths
));
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录