Created
February 28, 2013 11:59
-
-
Save ben-manes/5056275 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply from: "${rootDir}/gradle/java.gradle" | |
dependencies { | |
compile libraries.guava | |
compile libraries.guice | |
compile libraries.jooq | |
} | |
buildscript { | |
repositories { | |
maven { | |
url = "https://oss.sonatype.org/content/repositories/snapshots" | |
} | |
mavenCentral() | |
} | |
dependencies { | |
classpath "org.jooq:jooq-codegen:3.0.0-SNAPSHOT" | |
classpath "org.jooq:jooq-meta:3.0.0-SNAPSHOT" | |
classpath "com.h2database:h2:1.3.167" | |
} | |
} | |
import org.jooq.util.GenerationTool | |
import org.jooq.util.jaxb.Configuration as JooqConfiguration | |
import org.jooq.util.jaxb.Database | |
import org.jooq.util.jaxb.Generator | |
import org.jooq.util.jaxb.Jdbc | |
import javax.xml.bind.JAXB | |
import org.h2.jdbcx.JdbcDataSource; | |
task generateJooq() << { | |
def jdbc = new Jdbc(); | |
def generator = new Generator(); | |
def configuration = new JooqConfiguration(); | |
java.sql.DriverManager.registerDriver(Thread.currentThread().getContextClassLoader().loadClass('org.h2.Driver').load()) | |
jdbc.setDriver('org.h2.Driver') | |
jdbc.setUrl("jdbc:h2:mem:jooq") | |
jdbc.setUser("su") | |
Database database = new Database() | |
database.setName("org.jooq.util.h2.H2Database") | |
database.setIncludes(".*") | |
database.setExcludes("") | |
database.setInputSchema("jooq") | |
generator.setDatabase(database) | |
configuration.setGenerator(generator) | |
configuration.setJdbc(jdbc); | |
StringWriter writer = new StringWriter(); | |
JAXB.marshal(configuration, writer); | |
println("Using this configuration:\n" + writer.toString()); | |
def dataSource = new JdbcDataSource(); | |
dataSource.setURL("jdbc:h2:mem:jooq"); | |
GenerationTool.setConnection(dataSource.getConnection()); | |
GenerationTool.main(configuration); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gradle generateJooq | |
:infra:libraries:jooq:generateJooq | |
Using this configuration: | |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.0.0.xsd"> | |
<jdbc> | |
<driver>org.h2.Driver</driver> | |
<url>jdbc:h2:mem:jooq</url> | |
<user>su</user> | |
</jdbc> | |
<generator> | |
<name>org.jooq.util.DefaultGenerator</name> | |
<database> | |
<name>org.jooq.util.h2.H2Database</name> | |
<includes>.*</includes> | |
<excludes></excludes> | |
<recordVersionFields></recordVersionFields> | |
<recordTimestampFields></recordTimestampFields> | |
<dateAsTimestamp>false</dateAsTimestamp> | |
<unsignedTypes>true</unsignedTypes> | |
<inputSchema>jooq</inputSchema> | |
</database> | |
</generator> | |
</configuration> | |
No schemata were loaded : Please check your connection settings, and whether your database (and your database version!) is really supported by jOOQ. Also, check the case-sensitivity in your configured <inputSchema/> elements : [jooq] | |
BUILD SUCCESSFUL | |
Total time: 8.791 secs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment