Compare commits

...
5 Commits
Author SHA1 Message Date
hewei bf3a12e952 [maven-release-plugin] prepare release V1.1.0 2017-12-28 16:12:50 +08:00
hewei 60b160dd4f V1.1.0 2017-12-28 16:11:00 +08:00
hewei f8d728f4ed V1.0.20 2017-12-28 16:09:37 +08:00
hewei ff41844450 升级mybatis-generator到最新版本1.3.6 2017-12-28 15:28:54 +08:00
hewei 09c947db35 [maven-release-plugin] prepare for next development iteration 2017-09-28 18:30:14 +08:00
4 changed files with 100 additions and 14 deletions
+3 -3
View File
@@ -19,7 +19,7 @@
* [自定义注释插件(CommentPlugin)](#13-自定义注释插件)
* [增量插件(IncrementsPlugin)](#14-增量插件)
* [查询结果选择性返回插件(SelectSelectivePlugin)](#15-查询结果选择性返回插件)
* [官方ConstructorBased配置BUG临时修正插件(ConstructorBasedBugFixPlugin)](#16-官方constructorbased配置bug临时修正插件)
* [~~官方ConstructorBased配置BUG临时修正插件(ConstructorBasedBugFixPlugin)~~](#16-官方constructorbased配置bug临时修正插件)
---------------------------------------
Maven引用:
@@ -27,7 +27,7 @@ Maven引用:
<dependency>
<groupId>com.itfsw</groupId>
<artifactId>mybatis-generator-plugin</artifactId>
<version>1.0.19</version>
<version>1.1.0</version>
</dependency>
```
---------------------------------------
@@ -37,7 +37,7 @@ MyBatis Generator 参考配置(插件依赖应该配置在mybatis-generator-ma
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<version>1.3.6</version>
<configuration>
<!-- 配置文件 -->
<configurationFile>src/main/resources/mybatis-generator.xml</configurationFile>
+3 -3
View File
@@ -3,7 +3,7 @@
<groupId>com.itfsw</groupId>
<artifactId>mybatis-generator-plugin</artifactId>
<version>1.0.19</version>
<version>1.1.0</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
@@ -32,7 +32,7 @@
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
<version>1.3.6</version>
<scope>provided</scope>
</dependency>
<!-- 日志 -->
@@ -212,7 +212,7 @@
<connection>scm:git:https://github.com/itfsw/mybatis-generator-plugin.git</connection>
<developerConnection>scm:git:https://github.com/itfsw/mybatis-generator-plugin.git</developerConnection>
<url>https://github.com/itfsw/mybatis-generator-plugin</url>
<tag>V1.0.19</tag>
<tag>V1.1.0</tag>
</scm>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++distribution++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -24,20 +24,23 @@ import org.dom4j.io.SAXReader;
import org.mybatis.generator.api.CommentGenerator;
import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.api.dom.java.*;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.config.MergeConstants;
import org.mybatis.generator.config.PropertyRegistry;
import org.mybatis.generator.internal.util.StringUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.bind.DatatypeConverter;
import java.io.File;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.*;
import static org.mybatis.generator.internal.util.StringUtility.isTrue;
/**
* ---------------------------------------------------------------------------
@@ -52,6 +55,10 @@ public class TemplateCommentGenerator implements CommentGenerator {
private Map<EnumNode, Template> templates = new HashMap<>(); // 模板
private boolean suppressDate = false;
private boolean suppressAllComments = false;
/**
* 构造函数
* @param templatePath 模板路径
@@ -196,7 +203,11 @@ public class TemplateCommentGenerator implements CommentGenerator {
*/
@Override
public void addConfigurationProperties(Properties properties) {
suppressDate = isTrue(properties
.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE));
suppressAllComments = isTrue(properties
.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_ALL_COMMENTS));
}
/**
@@ -466,6 +477,80 @@ public class TemplateCommentGenerator implements CommentGenerator {
addXmlElementComment(rootElement, map, EnumNode.ADD_ROOT_COMMENT);
}
@Override
public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable,
Set<FullyQualifiedJavaType> imports) {
imports.add(new FullyQualifiedJavaType("javax.annotation.Generated")); //$NON-NLS-1$
String comment = "Source Table: " + introspectedTable.getFullyQualifiedTable().toString(); //$NON-NLS-1$
method.addAnnotation(getGeneratedAnnotation(comment));
}
@Override
public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable,
IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) {
imports.add(new FullyQualifiedJavaType("javax.annotation.Generated")); //$NON-NLS-1$
String comment = "Source field: " //$NON-NLS-1$
+ introspectedTable.getFullyQualifiedTable().toString()
+ "." //$NON-NLS-1$
+ introspectedColumn.getActualColumnName();
method.addAnnotation(getGeneratedAnnotation(comment));
}
@Override
public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable,
Set<FullyQualifiedJavaType> imports) {
imports.add(new FullyQualifiedJavaType("javax.annotation.Generated")); //$NON-NLS-1$
String comment = "Source Table: " + introspectedTable.getFullyQualifiedTable().toString(); //$NON-NLS-1$
field.addAnnotation(getGeneratedAnnotation(comment));
}
@Override
public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable,
IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) {
imports.add(new FullyQualifiedJavaType("javax.annotation.Generated")); //$NON-NLS-1$
String comment = "Source field: " //$NON-NLS-1$
+ introspectedTable.getFullyQualifiedTable().toString()
+ "." //$NON-NLS-1$
+ introspectedColumn.getActualColumnName();
field.addAnnotation(getGeneratedAnnotation(comment));
}
@Override
public void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable,
Set<FullyQualifiedJavaType> imports) {
imports.add(new FullyQualifiedJavaType("javax.annotation.Generated")); //$NON-NLS-1$
String comment = "Source Table: " + introspectedTable.getFullyQualifiedTable().toString(); //$NON-NLS-1$
innerClass.addAnnotation(getGeneratedAnnotation(comment));
}
private String getGeneratedAnnotation(String comment) {
StringBuilder buffer = new StringBuilder();
buffer.append("@Generated("); //$NON-NLS-1$
if (suppressAllComments) {
buffer.append('\"');
} else {
buffer.append("value=\""); //$NON-NLS-1$
}
buffer.append(MyBatisGenerator.class.getName());
buffer.append('\"');
if (!suppressDate && !suppressAllComments) {
buffer.append(", date=\""); //$NON-NLS-1$
buffer.append(DatatypeConverter.printDateTime(Calendar.getInstance()));
buffer.append('\"');
}
if (!suppressAllComments) {
buffer.append(", comments=\""); //$NON-NLS-1$
buffer.append(comment);
buffer.append('\"');
}
buffer.append(')');
return buffer.toString();
}
/**
* 评论模板节点ID
*/
@@ -67,7 +67,6 @@ public abstract class AbstractShellCallback implements ShellCallback {
/**
* 重载项目
*
* @param sqlSession
* @param loader
* @param packagz
@@ -92,7 +91,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
}
StringBuilder sb = new StringBuilder();
StringTokenizer st = new StringTokenizer(targetPackage, ".");
StringTokenizer st = new StringTokenizer(targetPackage, ".");
while (st.hasMoreTokens()) {
sb.append(st.nextToken());
sb.append(File.separatorChar);
@@ -112,6 +111,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
/* (non-Javadoc)
* @see org.mybatis.generator.api.ShellCallback#isMergeSupported()
*/
@Override
public boolean isMergeSupported() {
return false;
}
@@ -119,6 +119,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
/* (non-Javadoc)
* @see org.mybatis.generator.api.ShellCallback#isOverwriteEnabled()
*/
@Override
public boolean isOverwriteEnabled() {
return true;
}
@@ -126,9 +127,9 @@ public abstract class AbstractShellCallback implements ShellCallback {
/* (non-Javadoc)
* @see org.mybatis.generator.api.ShellCallback#mergeJavaFile(java.lang.String, java.lang.String, java.lang.String[], java.lang.String)
*/
public String mergeJavaFile(String newFileSource,
String existingFileFullPath, String[] javadocTags, String fileEncoding)
throws ShellException {
@Override
public String mergeJavaFile(String newFileSource, File existingFile,
String[] javadocTags, String fileEncoding) throws ShellException {
throw new UnsupportedOperationException();
}
}