Gradle plugin for generate DDL scripts from JPA entities using Hibernate SchemaExport tool.
Supports only generation from annotated entities without persistence.xml or hibernate.cfg.xml.
Built and tested with Hibernate 5.2.2.Final.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.deathman92.plugin:hibernate-schema-gradle-plugin:1.0.0")
}
}
apply plugin: 'java'
apply plugin: 'hibernate-schema-generate' // or 'com.github.deathman92.plugin.hibernate-schema-generate'
generateSchema {
// properties (see Setting later)
}
To generate schema, run
gradle generateSchema
or
./gradlew generateSchema
generateSchema {
outputDir = file('src/main/resources/db/schema') // folder where output file will be written
outputFileName = 'schema.ddl' // name of output file
packageNames = ['com.example.domain'] // required
dialect = 'org.hibernate.dialect.PostgreSQLDialect' // required
implicitStrategy = 'org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl'
physicalStrategy = 'org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl'
properties = [
'key' : 'value'
]
}