Split into modules

This commit is contained in:
Travis Burtrum 2017-05-28 18:01:00 -04:00
parent 59cf4ff2cd
commit 849a85f1be
24 changed files with 155 additions and 41 deletions

27
common/pom.xml Normal file
View File

@ -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>

View File

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

View File

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

View File

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

71
jdbcmapper/pom.xml Normal file
View File

@ -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>

View File

@ -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. * Created by mopar on 5/25/17.

View File

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

View File

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

View File

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

View File

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

View File

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

25
runtime-compiler/pom.xml Normal file
View File

@ -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>

View File

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