Browse Source

Split into modules

Travis Burtrum 1 year ago
parent
commit
849a85f1be
24 changed files with 155 additions and 41 deletions
  1. 27
    0
      common/pom.xml
  2. 0
    0
      common/src/main/java/com/moparisthebest/jdbc/Cleaner.java
  3. 0
    0
      common/src/main/java/com/moparisthebest/jdbc/Finishable.java
  4. 0
    0
      common/src/main/java/com/moparisthebest/jdbc/TryClose.java
  5. 1
    4
      common/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapper.java
  6. 0
    0
      common/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperFactory.java
  7. 1
    1
      common/src/main/java/com/moparisthebest/jdbc/codegen/SQLParser.java
  8. 5
    7
      common/src/main/java/com/moparisthebest/jdbc/util/ResultSetUtil.java
  9. 71
    0
      jdbcmapper/pom.xml
  10. 3
    1
      jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/AbstractSQLParser.java
  11. 0
    0
      jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java
  12. 0
    3
      jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java
  13. 1
    1
      jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/SimpleSQLParser.java
  14. 0
    0
      jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/JdbcMapperTest.java
  15. 0
    0
      jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAO.java
  16. 0
    2
      jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/SqlParserTest.java
  17. 3
    0
      pom.xml
  18. 17
    21
      querymapper/pom.xml
  19. 25
    0
      runtime-compiler/pom.xml
  20. 0
    0
      runtime-compiler/src/main/java/com/moparisthebest/classgen/Compiler.java
  21. 0
    0
      runtime-compiler/src/main/java/com/moparisthebest/classgen/MultiCompiler.java
  22. 0
    0
      runtime-compiler/src/main/java/com/moparisthebest/classgen/StringJavaFileObject.java
  23. 0
    0
      runtime-compiler/src/test/java/com/moparisthebest/classgentest/Calculator.java
  24. 1
    1
      runtime-compiler/src/test/java/com/moparisthebest/classgentest/CompilerTest.java

+ 27
- 0
common/pom.xml View File

@@ -0,0 +1,27 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<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">
3
+    <modelVersion>4.0.0</modelVersion>
4
+    <parent>
5
+        <groupId>com.moparisthebest.jdbcmapper</groupId>
6
+        <artifactId>jdbcmapper-parent</artifactId>
7
+        <version>1.0-SNAPSHOT</version>
8
+    </parent>
9
+    <artifactId>common</artifactId>
10
+    <name>${project.artifactId}</name>
11
+    <dependencies>
12
+        <dependency>
13
+            <groupId>junit</groupId>
14
+            <artifactId>junit</artifactId>
15
+            <scope>test</scope>
16
+        </dependency>
17
+        <dependency>
18
+            <groupId>org.apache.derby</groupId>
19
+            <artifactId>derby</artifactId>
20
+            <scope>test</scope>
21
+            <optional>true</optional>
22
+        </dependency>
23
+    </dependencies>
24
+    <build>
25
+        <finalName>${project.artifactId}</finalName>
26
+    </build>
27
+</project>

querymapper/src/main/java/com/moparisthebest/jdbc/Cleaner.java → common/src/main/java/com/moparisthebest/jdbc/Cleaner.java View File


querymapper/src/main/java/com/moparisthebest/jdbc/Finishable.java → common/src/main/java/com/moparisthebest/jdbc/Finishable.java View File


querymapper/src/main/java/com/moparisthebest/jdbc/TryClose.java → common/src/main/java/com/moparisthebest/jdbc/TryClose.java View File


querymapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapper.java → common/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapper.java View File

@@ -1,8 +1,5 @@
1 1
 package com.moparisthebest.jdbc.codegen;
2 2
 
3
-import com.moparisthebest.classgen.AbstractSQLParser;
4
-import com.moparisthebest.classgen.SQLParser;
5
-
6 3
 import java.io.Closeable;
7 4
 import java.lang.annotation.ElementType;
8 5
 import java.lang.annotation.Retention;
@@ -30,7 +27,7 @@ public interface JdbcMapper extends Closeable {
30 27
 
31 28
 		boolean cachePreparedStatements() default true;
32 29
 
33
-		Class<? extends SQLParser> sqlParser() default AbstractSQLParser.class;
30
+		Class<? extends SQLParser> sqlParser() default SQLParser.class;
34 31
 	}
35 32
 
36 33
 	@Retention(RetentionPolicy.SOURCE)

querymapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperFactory.java → common/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperFactory.java View File


querymapper/src/main/java/com/moparisthebest/classgen/SQLParser.java → common/src/main/java/com/moparisthebest/jdbc/codegen/SQLParser.java View File

@@ -1,4 +1,4 @@
1
-package com.moparisthebest.classgen;
1
+package com.moparisthebest.jdbc.codegen;
2 2
 
3 3
 /**
4 4
  * Created by mopar on 5/25/17.

querymapper/src/main/java/com/moparisthebest/jdbc/util/ResultSetUtil.java → common/src/main/java/com/moparisthebest/jdbc/util/ResultSetUtil.java View File

@@ -1,21 +1,19 @@
1 1
 package com.moparisthebest.jdbc.util;
2 2
 
3
-import com.moparisthebest.jdbc.MapperException;
4
-
5 3
 import java.sql.ResultSet;
6 4
 import java.sql.SQLException;
7 5
 import java.sql.Time;
8 6
 import java.sql.Timestamp;
9 7
 import java.util.Calendar;
10 8
 
11
-import static com.moparisthebest.jdbc.UpdateableDTO.NO;
12
-import static com.moparisthebest.jdbc.UpdateableDTO.YES;
13
-
14 9
 /**
15 10
  * Created by mopar on 5/16/17.
16 11
  */
17 12
 public class ResultSetUtil {
18 13
 
14
+	public static final String YES = System.getProperty("UpdateableDTO.YES", "Y");
15
+	public static final String NO = System.getProperty("UpdateableDTO.NO", "N");
16
+
19 17
 	public static Integer getObjectInt(final ResultSet rs, final int index) throws SQLException {
20 18
 		final int ret = rs.getInt(index);
21 19
 		return rs.wasNull() ? null : ret;
@@ -59,7 +57,7 @@ public class ResultSetUtil {
59 57
 			final String bool = rs.getString(index);//.toUpperCase(); // do we want it case-insensitive?
60 58
 			final boolean ret = YES.equals(bool);
61 59
 			if (!ret && !NO.equals(bool))
62
-				throw new MapperException(String.format("Implicit conversion of database string to boolean failed on column '%d'. Returned string needs to be 'Y' or 'N' and was instead '%s'.", index, bool));
60
+				throw new SQLException(String.format("Implicit conversion of database string to boolean failed on column '%d'. Returned string needs to be '%s' or '%s' and was instead '%s'.", index, YES, NO, bool));
63 61
 			return ret;
64 62
 		}
65 63
 	}
@@ -67,7 +65,7 @@ public class ResultSetUtil {
67 65
 	public static boolean getBooleanYN(final ResultSet rs, final int index) throws SQLException {
68 66
 		final Boolean ret = getObjectBooleanYN(rs, index);
69 67
 		if(ret == null)
70
-			throw new MapperException(String.format("Implicit conversion of database string to boolean failed on column '%d'. Returned string needs to be 'Y' or 'N' and was instead 'null'. If you want to accept null values, make it an object Boolean instead of primitive boolean.", index));
68
+			throw new SQLException(String.format("Implicit conversion of database string to boolean failed on column '%d'. Returned string needs to be '%s' or '%s' and was instead 'null'. If you want to accept null values, make it an object Boolean instead of primitive boolean.", index, YES, NO));
71 69
 		return ret;
72 70
 	}
73 71
 

+ 71
- 0
jdbcmapper/pom.xml View File

@@ -0,0 +1,71 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<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">
3
+    <modelVersion>4.0.0</modelVersion>
4
+    <parent>
5
+        <groupId>com.moparisthebest.jdbcmapper</groupId>
6
+        <artifactId>jdbcmapper-parent</artifactId>
7
+        <version>1.0-SNAPSHOT</version>
8
+    </parent>
9
+    <artifactId>jdbcmapper</artifactId>
10
+    <name>${project.artifactId}</name>
11
+    <dependencies>
12
+        <dependency>
13
+            <groupId>${project.groupId}</groupId>
14
+            <artifactId>common</artifactId>
15
+            <version>${project.version}</version>
16
+        </dependency>
17
+        <dependency>
18
+            <groupId>${project.groupId}</groupId>
19
+            <artifactId>querymapper</artifactId>
20
+            <version>${project.version}</version>
21
+        </dependency>
22
+        <dependency>
23
+            <groupId>${project.groupId}</groupId>
24
+            <artifactId>querymapper</artifactId>
25
+            <version>${project.version}</version>
26
+            <type>test-jar</type>
27
+            <scope>test</scope>
28
+        </dependency>
29
+        <dependency>
30
+            <groupId>junit</groupId>
31
+            <artifactId>junit</artifactId>
32
+            <scope>test</scope>
33
+        </dependency>
34
+        <dependency>
35
+            <groupId>org.apache.derby</groupId>
36
+            <artifactId>derby</artifactId>
37
+            <scope>test</scope>
38
+            <optional>true</optional>
39
+        </dependency>
40
+    </dependencies>
41
+    <build>
42
+        <finalName>${project.artifactId}</finalName>
43
+
44
+        <plugins>
45
+            <plugin>
46
+                <artifactId>maven-compiler-plugin</artifactId>
47
+                <version>3.1</version>
48
+                <configuration>
49
+                    <source>1.6</source>
50
+                    <target>1.6</target>
51
+                    <debug>true</debug>
52
+                    <!--compilerArgument>-Xlint:unchecked</compilerArgument-->
53
+                </configuration>
54
+                <executions>
55
+                    <execution>
56
+                        <id>my-testCompile</id>
57
+                        <phase>test-compile</phase>
58
+                        <goals>
59
+                            <goal>testCompile</goal>
60
+                        </goals>
61
+                        <configuration>
62
+                            <annotationProcessors>
63
+                                <annotationProcessor>com.moparisthebest.jdbc.codegen.JdbcMapperProcessor</annotationProcessor>
64
+                            </annotationProcessors>
65
+                        </configuration>
66
+                    </execution>
67
+                </executions>
68
+            </plugin>
69
+        </plugins>
70
+    </build>
71
+</project>

querymapper/src/main/java/com/moparisthebest/classgen/AbstractSQLParser.java → jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/AbstractSQLParser.java View File

@@ -1,4 +1,6 @@
1
-package com.moparisthebest.classgen;
1
+package com.moparisthebest.jdbc.codegen;
2
+
3
+import com.moparisthebest.jdbc.codegen.SQLParser;
2 4
 
3 5
 /**
4 6
  * Created by mopar on 5/25/17.

querymapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java → jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java View File


querymapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java → jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java View File

@@ -1,8 +1,5 @@
1 1
 package com.moparisthebest.jdbc.codegen;
2 2
 
3
-import com.moparisthebest.classgen.SQLParser;
4
-import com.moparisthebest.classgen.SimpleSQLParser;
5
-
6 3
 import javax.annotation.processing.*;
7 4
 import javax.lang.model.SourceVersion;
8 5
 import javax.lang.model.element.*;

querymapper/src/main/java/com/moparisthebest/classgen/SimpleSQLParser.java → jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/SimpleSQLParser.java View File

@@ -1,4 +1,4 @@
1
-package com.moparisthebest.classgen;
1
+package com.moparisthebest.jdbc.codegen;
2 2
 
3 3
 import java.util.regex.Pattern;
4 4
 

querymapper/src/test/java/com/moparisthebest/jdbc/codegen/JdbcMapperTest.java → jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/JdbcMapperTest.java View File


querymapper/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAO.java → jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAO.java View File


querymapper/src/test/java/com/moparisthebest/jdbc/codegen/SqlParserTest.java → jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/SqlParserTest.java View File

@@ -1,7 +1,5 @@
1 1
 package com.moparisthebest.jdbc.codegen;
2 2
 
3
-import com.moparisthebest.classgen.SQLParser;
4
-import com.moparisthebest.classgen.SimpleSQLParser;
5 3
 import org.junit.Test;
6 4
 
7 5
 import static org.junit.Assert.*;

+ 3
- 0
pom.xml View File

@@ -65,7 +65,10 @@
65 65
     </properties>
66 66
     <packaging>pom</packaging>
67 67
     <modules>
68
+        <module>common</module>
69
+        <module>runtime-compiler</module>
68 70
         <module>querymapper</module>
71
+        <module>jdbcmapper</module>
69 72
     </modules>
70 73
     <dependencyManagement>
71 74
         <dependencies>

+ 17
- 21
querymapper/pom.xml View File

@@ -8,11 +8,17 @@
8 8
     </parent>
9 9
     <artifactId>querymapper</artifactId>
10 10
     <name>${project.artifactId}</name>
11
-    <properties>
12
-        <maven.test.skip>false</maven.test.skip>
13
-        <maven.test.failure.ignore>false</maven.test.failure.ignore>
14
-    </properties>
15 11
     <dependencies>
12
+        <dependency>
13
+            <groupId>${project.groupId}</groupId>
14
+            <artifactId>common</artifactId>
15
+            <version>${project.version}</version>
16
+        </dependency>
17
+        <dependency>
18
+            <groupId>${project.groupId}</groupId>
19
+            <artifactId>runtime-compiler</artifactId>
20
+            <version>${project.version}</version>
21
+        </dependency>
16 22
         <dependency>
17 23
             <groupId>junit</groupId>
18 24
             <artifactId>junit</artifactId>
@@ -27,31 +33,21 @@
27 33
     </dependencies>
28 34
     <build>
29 35
         <finalName>${project.artifactId}</finalName>
30
-
31 36
         <plugins>
32 37
             <plugin>
33
-                <artifactId>maven-compiler-plugin</artifactId>
34
-                <version>3.1</version>
35
-                <configuration>
36
-                    <source>1.6</source>
37
-                    <target>1.6</target>
38
-                    <debug>true</debug>
39
-                    <!--compilerArgument>-Xlint:unchecked</compilerArgument-->
40
-                </configuration>
38
+                <artifactId>maven-jar-plugin</artifactId>
39
+                <version>2.2</version>
41 40
                 <executions>
42 41
                     <execution>
43
-                        <id>my-testCompile</id>
44
-                        <phase>test-compile</phase>
45 42
                         <goals>
46
-                            <goal>testCompile</goal>
43
+                            <goal>test-jar</goal>
47 44
                         </goals>
48
-                        <configuration>
49
-                            <annotationProcessors>
50
-                                <annotationProcessor>com.moparisthebest.jdbc.codegen.JdbcMapperProcessor</annotationProcessor>
51
-                            </annotationProcessors>
52
-                        </configuration>
45
+                        <phase>test-compile</phase>
53 46
                     </execution>
54 47
                 </executions>
48
+                <configuration>
49
+                    <outputDirectory>${basedir}/target</outputDirectory>
50
+                </configuration>
55 51
             </plugin>
56 52
         </plugins>
57 53
     </build>

+ 25
- 0
runtime-compiler/pom.xml View File

@@ -0,0 +1,25 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<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">
3
+    <modelVersion>4.0.0</modelVersion>
4
+    <parent>
5
+        <groupId>com.moparisthebest.jdbcmapper</groupId>
6
+        <artifactId>jdbcmapper-parent</artifactId>
7
+        <version>1.0-SNAPSHOT</version>
8
+    </parent>
9
+    <artifactId>runtime-compiler</artifactId>
10
+    <name>${project.artifactId}</name>
11
+    <properties>
12
+        <maven.test.skip>false</maven.test.skip>
13
+        <maven.test.failure.ignore>false</maven.test.failure.ignore>
14
+    </properties>
15
+    <dependencies>
16
+        <dependency>
17
+            <groupId>junit</groupId>
18
+            <artifactId>junit</artifactId>
19
+            <scope>test</scope>
20
+        </dependency>
21
+    </dependencies>
22
+    <build>
23
+        <finalName>${project.artifactId}</finalName>
24
+    </build>
25
+</project>

querymapper/src/main/java/com/moparisthebest/classgen/Compiler.java → runtime-compiler/src/main/java/com/moparisthebest/classgen/Compiler.java View File


querymapper/src/main/java/com/moparisthebest/classgen/MultiCompiler.java → runtime-compiler/src/main/java/com/moparisthebest/classgen/MultiCompiler.java View File


querymapper/src/main/java/com/moparisthebest/classgen/StringJavaFileObject.java → runtime-compiler/src/main/java/com/moparisthebest/classgen/StringJavaFileObject.java View File


querymapper/src/test/java/com/moparisthebest/classgentest/Calculator.java → runtime-compiler/src/test/java/com/moparisthebest/classgentest/Calculator.java View File


querymapper/src/test/java/com/moparisthebest/classgentest/CalculatorCompiler.java → runtime-compiler/src/test/java/com/moparisthebest/classgentest/CompilerTest.java View File

@@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals;
23 23
  *
24 24
  * @author moparisthebest
25 25
  */
26
-public class CalculatorCompiler {
26
+public class CompilerTest {
27 27
 
28 28
 	@Test
29 29
 	public void testSingle() throws InterruptedException {