Skip to content

Commit

Permalink
Merge pull request mybatis#515 from jeffgbutler/kotlin
Browse files Browse the repository at this point in the history
Add Simple Kotlin DOM and Generator Runtime for Kotlin
  • Loading branch information
jeffgbutler authored Nov 22, 2019
2 parents 997abf4 + 866b0e1 commit f739ced
Show file tree
Hide file tree
Showing 126 changed files with 13,113 additions and 256 deletions.
19 changes: 7 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,18 @@
/core/mybatis-generator-systests-mybatis3-java8/.settings
/core/mybatis-generator-systests-mybatis3-java8/target

# /core/mybatis-generator-systests-ibatis2-java2/
/core/mybatis-generator-systests-ibatis2-java2/.classpath
/core/mybatis-generator-systests-ibatis2-java2/.project
/core/mybatis-generator-systests-ibatis2-java2/.settings
/core/mybatis-generator-systests-ibatis2-java2/target

# /core/mybatis-generator-systests-ibatis2-java5/
/core/mybatis-generator-systests-ibatis2-java5/.classpath
/core/mybatis-generator-systests-ibatis2-java5/.project
/core/mybatis-generator-systests-ibatis2-java5/.settings
/core/mybatis-generator-systests-ibatis2-java5/target

# /core/mybatis-generator-systests-domtests/
/core/mybatis-generator-systests-domtests/.classpath
/core/mybatis-generator-systests-domtests/.project
/core/mybatis-generator-systests-domtests/.settings
/core/mybatis-generator-systests-domtests/target

# /core/mybatis-generator-systests-kotlin/
/core/mybatis-generator-systests-kotlin/.classpath
/core/mybatis-generator-systests-kotlin/.project
/core/mybatis-generator-systests-kotlin/.settings
/core/mybatis-generator-systests-kotlin/target

/.project
.idea
*.iml
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ MyBatis Generator (MBG)

![mybatis-generator](http://mybatis.github.io/images/mybatis-logo.png)

Code generator for MyBatis.
This is a code generator for MyBatis.

This library will generate code for use with MyBatis. It will introspect a database table (or many tables) and will generate artifacts that can be used to access the table(s). This lessens the initial nuisance of setting up objects and configuration files to interact with database tables. MBG seeks to make a major impact on the large percentage of database operations that are simple CRUD (Create, Retrieve, Update, Delete).

MBG can generate code in multiple styles (or "runtimes"). MBG can generate code for Java based projects, or for Kotlin based projects.
24 changes: 24 additions & 0 deletions core/mybatis-generator-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Overview

MyBatis Generator (MBG) is a code generator for the MyBatis SQL
mapping framework. MBG will introspect database tables (through JDBC
DatabaseMetaData) and generate SQL Map XML files, Java model object (POJOs)
that match the table, and (optionally) Java client classes that use the other
generated objects.

MBG can also generate Kotlin code for MyBatis.

For full documentation, please refer to the user's manual at http://www.mybatis.org/generator/

## Dependencies

There are no dependencies beyond the JRE. Java 8 or above is required.
Also required is a JDBC driver that implements the DatabaseMetaData interface,
especially the "getColumns" and "getPrimaryKeys" methods.

## Support

Support is provided through the user mailing list. Mail
questions or bug reports to:

[email protected]
39 changes: 0 additions & 39 deletions core/mybatis-generator-core/README.txt

This file was deleted.

3 changes: 2 additions & 1 deletion core/mybatis-generator-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2006-2018 the original author or authors.
Copyright 2006-2019 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -222,6 +222,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2006-2017 the original author or authors.
* Copyright 2006-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,10 @@
import org.mybatis.generator.api.dom.java.InnerEnum;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.TopLevelClass;
import org.mybatis.generator.api.dom.kotlin.KotlinFile;
import org.mybatis.generator.api.dom.kotlin.KotlinFunction;
import org.mybatis.generator.api.dom.kotlin.KotlinProperty;
import org.mybatis.generator.api.dom.kotlin.KotlinType;
import org.mybatis.generator.api.dom.xml.XmlElement;

/**
Expand Down Expand Up @@ -92,6 +96,17 @@ void addFieldComment(Field field,
void addModelClassComment(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable);

/**
* Adds a comment for a model class.
*
* @param modelClass
* the generated KotlinType for the model
* @param introspectedTable
* the introspected table
*/
default void addModelClassComment(KotlinType modelClass,
IntrospectedTable introspectedTable) {}

/**
* Adds the inner class comment.
*
Expand Down Expand Up @@ -279,4 +294,21 @@ void addFieldAnnotation(Field field, IntrospectedTable introspectedTable,
*/
void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable,
Set<FullyQualifiedJavaType> imports);

/**
* This method is called to add a file level comment to a generated Kotlin file. This method
* could be used to add a general file comment (such as a copyright notice).
*
* <p>The default implementation does nothing.
*
* @param kotlinFile
* the Kotlin file
*/
default void addFileComment(KotlinFile kotlinFile) {}

default void addGeneralFunctionComment(KotlinFunction kf, IntrospectedTable introspectedTable,
Set<String> imports) {}

default void addGeneralPropertyComment(KotlinProperty property, IntrospectedTable introspectedTable,
Set<String> imports) {}
}
Loading

0 comments on commit f739ced

Please sign in to comment.