diff --git a/.gitignore b/.gitignore index b83d22266ac8aa2f8df2edef68082c789727841d..4c60d817183d75ec6d9c42006007bc2d0d7f0a86 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,33 @@ -/target/ +### Maven ### +target/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Extra ### +note/ diff --git a/src/main/java/cn/org/atool/generator/database/config/impl/DbConfig.java b/src/main/java/cn/org/atool/generator/database/config/impl/DbConfig.java index ab69a660359f98c40a827cb071c473e1215c7009..d524cacbf21ddb5f5754e065374e32ea8f0eae7c 100644 --- a/src/main/java/cn/org/atool/generator/database/config/impl/DbConfig.java +++ b/src/main/java/cn/org/atool/generator/database/config/impl/DbConfig.java @@ -52,7 +52,7 @@ public class DbConfig { public DbConfig(DbType dbType, String driverName, String url, String username, String password) { if (url == null) { - throw new RuntimeException("请设置数据库链接信息 url"); + throw new RuntimeException("Database connection url cannot cannot be null"); } this.dbType = dbType; this.driverName = driverName; @@ -121,9 +121,9 @@ public class DbConfig { Class.forName(driverName); return DriverManager.getConnection(url, username, password); } catch (ClassNotFoundException | SQLException e) { - throw new RuntimeException("getConn error:" + e.getMessage(), e); + throw new RuntimeException("Get Connection error:" + e.getMessage(), e); } } return this.connection; } -} \ No newline at end of file +} diff --git a/src/main/java/cn/org/atool/generator/database/config/impl/GlobalConfig.java b/src/main/java/cn/org/atool/generator/database/config/impl/GlobalConfig.java index 7130fff5bf966fb9c6676d1f6ecff9cbd8426d92..76f3c250d8e97838dbd903a41a1e2999fd2c959e 100644 --- a/src/main/java/cn/org/atool/generator/database/config/impl/GlobalConfig.java +++ b/src/main/java/cn/org/atool/generator/database/config/impl/GlobalConfig.java @@ -92,7 +92,7 @@ public class GlobalConfig implements IGlobalConfigSet { public String getBasePackage() { if (GeneratorHelper.isBlank(basePackage)) { - throw new RuntimeException("the base package should be set."); + throw new RuntimeException("The base package should be set."); } return basePackage; } @@ -117,7 +117,7 @@ public class GlobalConfig implements IGlobalConfigSet { @Override public IGlobalConfigSet setDataSource(String url, String username, String password) { - return this.setDataSource(DbType.MYSQL, "com.mysql.jdbc.Driver", url, username, password, null); + return this.setDataSource(DbType.MYSQL, "com.mysql.cj.jdbc.Driver", url, username, password, null); } @Override @@ -152,4 +152,4 @@ public class GlobalConfig implements IGlobalConfigSet { return fieldName.startsWith("is"); } } -} \ No newline at end of file +} diff --git a/src/main/java/cn/org/atool/generator/database/config/impl/TableConfigSet.java b/src/main/java/cn/org/atool/generator/database/config/impl/TableConfigSet.java index 21402206915a006b82dc15ac4ad04e157726d5c8..88a37ac098072d35e26465e9deb416aa0569d832 100644 --- a/src/main/java/cn/org/atool/generator/database/config/impl/TableConfigSet.java +++ b/src/main/java/cn/org/atool/generator/database/config/impl/TableConfigSet.java @@ -86,7 +86,7 @@ public class TableConfigSet implements ITableConfigSet { Set all = this.getTables().keySet(); for (String table : all) { if (!existed.contains(table)) { - System.err.println("表 " + table + " 在数据库中不存在!!!"); + System.err.println("Table '" + table + "' not exist in database !!!"); this.getTables().remove(table); } } @@ -94,7 +94,7 @@ public class TableConfigSet implements ITableConfigSet { entry.getValue().initTable(); } } catch (SQLException e) { - throw new RuntimeException(e); + throw new RuntimeException("Failed to initialize table: " + e.getMessage(), e); } } @@ -133,4 +133,4 @@ public class TableConfigSet implements ITableConfigSet { return tablesSql; } } -} \ No newline at end of file +} diff --git a/src/main/java/cn/org/atool/generator/database/config/impl/TableSetter.java b/src/main/java/cn/org/atool/generator/database/config/impl/TableSetter.java index d5637cc5f5465f399557340e624afbb84fc5fcb2..0287e674b07889eaa14cdb358791482fccdee562 100644 --- a/src/main/java/cn/org/atool/generator/database/config/impl/TableSetter.java +++ b/src/main/java/cn/org/atool/generator/database/config/impl/TableSetter.java @@ -207,7 +207,7 @@ public class TableSetter implements ITableSetter { private DefinedColumn getDefinedColumn(String column) { if (isBlank(column)) { - throw new RuntimeException("the column can't be null."); + throw new RuntimeException("The column can't be null."); } if (!this.columns.containsKey(column)) { this.columns.put(column, new DefinedColumn(column)); @@ -469,4 +469,4 @@ public class TableSetter implements ITableSetter { public String getBasePackage() { return globalConfig.getBasePackage(); } -} \ No newline at end of file +} diff --git a/src/main/java/cn/org/atool/generator/javafile/AbstractFile.java b/src/main/java/cn/org/atool/generator/javafile/AbstractFile.java index d090eb4ffa508cfd8937eb2605a61623e0c00784..701578befa7d39e190e892cbbfd24f2cb643372f 100644 --- a/src/main/java/cn/org/atool/generator/javafile/AbstractFile.java +++ b/src/main/java/cn/org/atool/generator/javafile/AbstractFile.java @@ -43,7 +43,7 @@ public abstract class AbstractFile { this.staticImport(javaBuilder); javaBuilder.build().writeTo(srcDir); } catch (IOException e) { - throw new RuntimeException(e); + throw new RuntimeException("Failed to generate java file: " + e.getMessage(), e); } } diff --git a/src/main/java/cn/org/atool/generator/javafile/AnnotationGenerator.java b/src/main/java/cn/org/atool/generator/javafile/AnnotationGenerator.java index 71a50927f6d414d609d1425497be736e40268a63..89f3e91b3af1abafe55c5af128e28f948492561a 100644 --- a/src/main/java/cn/org/atool/generator/javafile/AnnotationGenerator.java +++ b/src/main/java/cn/org/atool/generator/javafile/AnnotationGenerator.java @@ -25,7 +25,7 @@ public class AnnotationGenerator { public static void generate(Class clazz) { Tables tables = (Tables) clazz.getAnnotation(Tables.class); if (tables.tables().length == 0) { - throw new RuntimeException("the @Tables Annotation not found."); + throw new RuntimeException("The @Tables Annotation not found."); } AnnotationGenerator generator = new AnnotationGenerator(tables); IGlobalConfig globalConfig = generator.globalConfig(); @@ -165,4 +165,4 @@ public class AnnotationGenerator { private boolean isDefined(String[] value) { return value.length != 1 || !Objects.equals(value[0], NOT_DEFINED); } -} \ No newline at end of file +} diff --git a/src/main/java/cn/org/atool/generator/javafile/TemplateGenerator.java b/src/main/java/cn/org/atool/generator/javafile/TemplateGenerator.java index c9ebb3aecd992fec5a61d437a4737153e00ce215..073bab443c1788663b96b365367f9e0737b6d47d 100644 --- a/src/main/java/cn/org/atool/generator/javafile/TemplateGenerator.java +++ b/src/main/java/cn/org/atool/generator/javafile/TemplateGenerator.java @@ -43,7 +43,7 @@ public class TemplateGenerator implements IGlobalConfig, ITableConfig { public static IGlobalConfig build(boolean withEntity, boolean withTest) { if (!withEntity && !withTest) { - throw new RuntimeException("生成Entity和Test辅助类不能同时为假"); + throw new RuntimeException("At last one of Entity or Test generation must be true"); } TemplateGenerator generator = new TemplateGenerator(); generator.withTest = withTest; @@ -79,10 +79,10 @@ public class TemplateGenerator implements IGlobalConfig, ITableConfig { @Override public void execute() { if (globalConfig == null) { - throw new RuntimeException("the global config not set."); + throw new RuntimeException("The global config not set."); } - if (tableConfigs == null || tableConfigs.isEmpty()) { - throw new RuntimeException("the table config not set."); + if (tableConfigs.isEmpty()) { + throw new RuntimeException("The table config is empty."); } List tables = new ArrayList<>(); for (TableConfigSet config : this.tableConfigs) { diff --git a/src/main/java/cn/org/atool/generator/properties/ConfigGeneratorHelper.java b/src/main/java/cn/org/atool/generator/properties/ConfigGeneratorHelper.java index 247068f4e90cf5156578d13952eb354c1a319b73..a05a1dc2178a8d99dc47beeb3b9205fc2ed7870b 100644 --- a/src/main/java/cn/org/atool/generator/properties/ConfigGeneratorHelper.java +++ b/src/main/java/cn/org/atool/generator/properties/ConfigGeneratorHelper.java @@ -23,7 +23,7 @@ final class ConfigGeneratorHelper { } else if (file.endsWith(".properties")) { } else { - throw new RuntimeException("not support file"); + throw new RuntimeException("Not support file"); } } } @@ -39,9 +39,9 @@ final class ConfigGeneratorHelper { } else if (value instanceof Map) { all.putAll(yaml(prefix + entry.getKey() + ".", (Map) value)); } else { - throw new RuntimeException("not support type: " + value.getClass().getName()); + throw new RuntimeException("Not support type: " + value.getClass().getName()); } } return all; } -} \ No newline at end of file +} diff --git a/src/main/java/cn/org/atool/generator/util/GeneratorHelper.java b/src/main/java/cn/org/atool/generator/util/GeneratorHelper.java index 15f552d23d8db1af7b970bbf89e25fb0a6652800..2f478e268a5beac75a8c5cad9b7ac4428c9639a7 100644 --- a/src/main/java/cn/org/atool/generator/util/GeneratorHelper.java +++ b/src/main/java/cn/org/atool/generator/util/GeneratorHelper.java @@ -18,14 +18,14 @@ public class GeneratorHelper { */ public static void convertPath(File path) { if (!path.isDirectory() || !path.exists()) { - info("文件夹不存在"); + info("File not exist: " + path.getAbsolutePath()); return; } File[] files = path.listFiles(); for (File file : files) { if (file.isFile()) { convertFile(file); - info("转换文件[" + file.getName() + "]成功"); + info("Convert file [" + file.getName() + "] success"); } else if (file.isDirectory()) { convertPath(file); } @@ -118,7 +118,7 @@ public class GeneratorHelper { return list.toArray(new String[0]); } } catch (IOException e) { - throw new RuntimeException(e); + throw new RuntimeException("Fail to read file" + e.getMessage(), e); } } @@ -130,7 +130,7 @@ public class GeneratorHelper { try (FileWriter writer = new FileWriter(file, false)) { writer.write(content); } catch (IOException e) { - throw new RuntimeException(e); + throw new RuntimeException("Fail to write file: " + e.getMessage(), e); } } -} \ No newline at end of file +}