Browse Source

Split into modules

moparisthebest 9 months 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
      querymapper/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
      querymapper/src/main/java/com/moparisthebest/classgen/SQLParser.java
  8. 5 7
      querymapper/src/main/java/com/moparisthebest/jdbc/util/ResultSetUtil.java
  9. 71 0
      jdbcmapper/pom.xml
  10. 3 1
      querymapper/src/main/java/com/moparisthebest/classgen/AbstractSQLParser.java
  11. 0 0
      jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java
  12. 0 3
      querymapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java
  13. 1 1
      querymapper/src/main/java/com/moparisthebest/classgen/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
      querymapper/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
      querymapper/src/test/java/com/moparisthebest/classgentest/CalculatorCompiler.java

+ 27 - 0
common/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.moparisthebest.jdbcmapper</groupId>
+        <artifactId>jdbcmapper-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>common</artifactId>
+    <name>${project.artifactId}</name>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <scope>test</scope>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+    <build>
+        <finalName>${project.artifactId}</finalName>
+    </build>
+</project>

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


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


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


+ 1 - 4
querymapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapper.java

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

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


+ 1 - 1
querymapper/src/main/java/com/moparisthebest/classgen/SQLParser.java

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

+ 5 - 7
querymapper/src/main/java/com/moparisthebest/jdbc/util/ResultSetUtil.java

@@ -1,21 +1,19 @@
 package com.moparisthebest.jdbc.util;
 
-import com.moparisthebest.jdbc.MapperException;
-
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Calendar;
 
-import static com.moparisthebest.jdbc.UpdateableDTO.NO;
-import static com.moparisthebest.jdbc.UpdateableDTO.YES;
-
 /**
  * Created by mopar on 5/16/17.
  */
 public class ResultSetUtil {
 
+	public static final String YES = System.getProperty("UpdateableDTO.YES", "Y");
+	public static final String NO = System.getProperty("UpdateableDTO.NO", "N");
+
 	public static Integer getObjectInt(final ResultSet rs, final int index) throws SQLException {
 		final int ret = rs.getInt(index);
 		return rs.wasNull() ? null : ret;
@@ -59,7 +57,7 @@ public class ResultSetUtil {
 			final String bool = rs.getString(index);//.toUpperCase(); // do we want it case-insensitive?
 			final boolean ret = YES.equals(bool);
 			if (!ret && !NO.equals(bool))
-				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));
+				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));
 			return ret;
 		}
 	}
@@ -67,7 +65,7 @@ public class ResultSetUtil {
 	public static boolean getBooleanYN(final ResultSet rs, final int index) throws SQLException {
 		final Boolean ret = getObjectBooleanYN(rs, index);
 		if(ret == null)
-			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));
+			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));
 		return ret;
 	}
 

+ 71 - 0
jdbcmapper/pom.xml

@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.moparisthebest.jdbcmapper</groupId>
+        <artifactId>jdbcmapper-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>jdbcmapper</artifactId>
+    <name>${project.artifactId}</name>
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>querymapper</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>querymapper</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <scope>test</scope>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+    <build>
+        <finalName>${project.artifactId}</finalName>
+
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                    <debug>true</debug>
+                    <!--compilerArgument>-Xlint:unchecked</compilerArgument-->
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>my-testCompile</id>
+                        <phase>test-compile</phase>
+                        <goals>
+                            <goal>testCompile</goal>
+                        </goals>
+                        <configuration>
+                            <annotationProcessors>
+                                <annotationProcessor>com.moparisthebest.jdbc.codegen.JdbcMapperProcessor</annotationProcessor>
+                            </annotationProcessors>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 3 - 1
querymapper/src/main/java/com/moparisthebest/classgen/AbstractSQLParser.java

@@ -1,4 +1,6 @@
-package com.moparisthebest.classgen;
+package com.moparisthebest.jdbc.codegen;
+
+import com.moparisthebest.jdbc.codegen.SQLParser;
 
 /**
  * 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


+ 0 - 3
querymapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java

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

+ 1 - 1
querymapper/src/main/java/com/moparisthebest/classgen/SimpleSQLParser.java

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

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


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


+ 0 - 2
querymapper/src/test/java/com/moparisthebest/jdbc/codegen/SqlParserTest.java

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

+ 3 - 0
pom.xml

@@ -65,7 +65,10 @@
     </properties>
     <packaging>pom</packaging>
     <modules>
+        <module>common</module>
+        <module>runtime-compiler</module>
         <module>querymapper</module>
+        <module>jdbcmapper</module>
     </modules>
     <dependencyManagement>
         <dependencies>

+ 17 - 21
querymapper/pom.xml

@@ -8,12 +8,18 @@
     </parent>
     <artifactId>querymapper</artifactId>
     <name>${project.artifactId}</name>
-    <properties>
-        <maven.test.skip>false</maven.test.skip>
-        <maven.test.failure.ignore>false</maven.test.failure.ignore>
-    </properties>
     <dependencies>
         <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>runtime-compiler</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
@@ -27,31 +33,21 @@
     </dependencies>
     <build>
         <finalName>${project.artifactId}</finalName>
-
         <plugins>
             <plugin>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.1</version>
-                <configuration>
-                    <source>1.6</source>
-                    <target>1.6</target>
-                    <debug>true</debug>
-                    <!--compilerArgument>-Xlint:unchecked</compilerArgument-->
-                </configuration>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.2</version>
                 <executions>
                     <execution>
-                        <id>my-testCompile</id>
-                        <phase>test-compile</phase>
                         <goals>
-                            <goal>testCompile</goal>
+                            <goal>test-jar</goal>
                         </goals>
-                        <configuration>
-                            <annotationProcessors>
-                                <annotationProcessor>com.moparisthebest.jdbc.codegen.JdbcMapperProcessor</annotationProcessor>
-                            </annotationProcessors>
-                        </configuration>
+                        <phase>test-compile</phase>
                     </execution>
                 </executions>
+                <configuration>
+                    <outputDirectory>${basedir}/target</outputDirectory>
+                </configuration>
             </plugin>
         </plugins>
     </build>

+ 25 - 0
runtime-compiler/pom.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.moparisthebest.jdbcmapper</groupId>
+        <artifactId>jdbcmapper-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>runtime-compiler</artifactId>
+    <name>${project.artifactId}</name>
+    <properties>
+        <maven.test.skip>false</maven.test.skip>
+        <maven.test.failure.ignore>false</maven.test.failure.ignore>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <finalName>${project.artifactId}</finalName>
+    </build>
+</project>

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


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


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


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


+ 1 - 1
querymapper/src/test/java/com/moparisthebest/classgentest/CalculatorCompiler.java

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