Skip to content

Commit a2befea

Browse files
committed
Merge branch 'master' into 5.0.x
# Conflicts: # application.properties # grails-app/conf/BuildConfig.groovy # src/docs/introduction.adoc # src/docs/tutorial.adoc # src/main/groovy/grails/plugin/reveng/DbReverseEngineerGrailsPlugin.groovy # test-app/grails-app/conf/BuildConfig.groovy
2 parents d6aaf9b + 2e54c5e commit a2befea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+967
-560
lines changed

.gitignore

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
*.iml
2+
*.ipr
3+
*.iws
14
*.log
2-
.classpath
3-
.project
4-
.settings
5-
target
6-
/grails-db-reverse-engineer-*.zip
7-
/grails-db-reverse-engineer-*.zip.sha1
8-
/plugin.xml
5+
*.sublime-workspace
6+
.asscache
7+
.DS_Store
8+
.gradle
9+
.idea
10+
build
11+
cobertura.ser
912
/test-app/grails-app/domain
10-
/test-app/web-app/WEB-INF/tld
11-
/web-app

.settings/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

LICENSE.txt renamed to LICENSE

File renamed without changes.

build.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
buildscript {
2+
ext {
3+
grailsVersion = project.grailsVersion
4+
}
5+
repositories {
6+
mavenLocal()
7+
maven { url 'https://repo.grails.org/grails/core' }
8+
jcenter()
9+
}
10+
dependencies {
11+
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
12+
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.2'
13+
classpath 'org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.4'
14+
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.9'
15+
}
16+
}
17+
18+
plugins {
19+
id 'io.spring.dependency-management' version '0.5.4.RELEASE'
20+
id 'com.jfrog.bintray' version '1.2'
21+
}
22+
23+
apply from: 'gradle/plugin.gradle'
24+
25+
dependencies {
26+
27+
provided 'org.grails:grails-core'
28+
29+
compile 'org.hibernate:hibernate-tools:4.3.1.Final', {
30+
['ant', 'common', 'freemarker', 'org.eclipse.jdt.core', 'runtime', 'text'].each { exclude module: it }
31+
}
32+
33+
compile 'org.freemarker:freemarker:2.3.23'
34+
35+
compile 'org.hibernate:hibernate-core:4.3.10.Final'
36+
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
grailsVersion=3.0.11
2+
vcsUrl=https://github.com/grails-plugins/grails-db-reverse-engineer

gradle/common.gradle

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
def versionTxt = file('version.txt')
2+
version = versionTxt.exists() ? versionTxt.text.trim() : '0.1'
3+
4+
project.ext.setIfNotSet = { String name, value, boolean ext = true ->
5+
if (!project.ext.has(name) || !project[name]) {
6+
(ext ? project.ext : project)[name] = value
7+
}
8+
}
9+
10+
setIfNotSet 'gradleWrapperVersion', '2.10'
11+
setIfNotSet 'group', 'org.grails.plugins', false
12+
setIfNotSet 'sourceCompatibility', 1.7
13+
setIfNotSet 'targetCompatibility', 1.7
14+
15+
apply plugin: 'idea'
16+
apply plugin: 'war'
17+
apply plugin: 'org.grails.grails-gsp'
18+
19+
repositories {
20+
mavenLocal()
21+
mavenCentral()
22+
maven { url 'https://repo.grails.org/grails/core' }
23+
}
24+
25+
dependencyManagement {
26+
imports {
27+
mavenBom "org.grails:grails-bom:$grailsVersion"
28+
}
29+
applyMavenExclusions false
30+
}
31+
32+
dependencies {
33+
testCompile 'org.grails:grails-plugin-testing'
34+
}
35+
36+
// deletes everything from the build directory except for test reports
37+
task cleanBuild {
38+
if (!buildDir.exists()) return
39+
40+
buildDir.eachFile {
41+
if (it.file) {
42+
it.delete()
43+
}
44+
else if (it.name != 'reports' && !it.name.startsWith('geb-reports') && !it.name.startsWith('test-results')) {
45+
it.deleteDir()
46+
}
47+
}
48+
}
49+
50+
test {
51+
testLogging {
52+
exceptionFormat = 'full'
53+
events 'failed', 'standardOut', 'standardError'
54+
}
55+
56+
beforeTest { descriptor -> logger.quiet " -- $descriptor" }
57+
}
58+
59+
task wrapper(type: Wrapper) {
60+
gradleVersion = gradleWrapperVersion
61+
}

gradle/plugin.gradle

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apply from: 'gradle/common.gradle'
2+
3+
apply plugin: 'maven-publish'
4+
apply plugin: 'spring-boot'
5+
apply plugin: 'org.grails.grails-plugin'
6+
apply plugin: 'org.asciidoctor.convert'
7+
8+
apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/grailsCentralPublishing.gradle'
9+
apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle'
10+
11+
setIfNotSet 'issueTrackerUrl', project.vcsUrl + '/issues'
12+
setIfNotSet 'websiteUrl', project.vcsUrl
13+
14+
dependencies {
15+
provided 'javax.servlet:javax.servlet-api:3.1.0'
16+
provided 'org.grails:grails-dependencies'
17+
provided 'org.grails:grails-web-boot'
18+
provided 'org.springframework.boot:spring-boot-starter-logging'
19+
}
20+
21+
asciidoctor {
22+
separateOutputDirs = false
23+
sourceDir = file('src/docs')
24+
sources {
25+
include 'index.adoc'
26+
}
27+
outputDir new File(buildDir, 'docs')
28+
backends 'html5', 'pdf', 'epub3'
29+
attributes 'source-highlighter': 'prettify',
30+
icons: 'font',
31+
setanchors: 'true',
32+
idprefix: '',
33+
idseparator: '-',
34+
toc2: '',
35+
numbered: '',
36+
revnumber: project.version
37+
}
38+
39+
task docs(dependsOn: asciidoctor) << {
40+
File dir = new File(buildDir, 'docs')
41+
42+
['pdf', 'epub'].each { String ext ->
43+
File f = new File(dir, 'index.' + ext)
44+
if (f.exists()) {
45+
f.renameTo new File(dir, project.name + '-' + project.version + '.' + ext)
46+
}
47+
}
48+
49+
new File(buildDir, 'docs/ghpages.html') << file('src/docs/index.tmpl').text.replaceAll('@VERSION@', project.version)
50+
51+
copy {
52+
from 'src/docs'
53+
into new File(buildDir, 'docs').path
54+
include '**/*.png'
55+
}
56+
}

gradle/testapp.gradle

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
File pluginDir = file('.').parentFile
2+
File versionTxt
3+
while (true) {
4+
versionTxt = new File(pluginDir, 'version.txt')
5+
if (versionTxt.exists()) {
6+
break
7+
}
8+
pluginDir = pluginDir.parentFile
9+
}
10+
11+
apply plugin: 'org.grails.grails-web'
12+
13+
apply from: new File(pluginDir, 'gradle/common.gradle').path
14+
15+
project.ext.pluginVersion = versionTxt.text.trim()
16+
project.ext.pluginName = pluginDir.name - 'grails-'
17+
18+
dependencies {
19+
compile "org.grails.plugins:$pluginName:$pluginVersion"
20+
compile 'com.h2database:h2:1.4.190'
21+
compile 'org.grails:grails-dependencies'
22+
compile 'org.springframework.boot:spring-boot-autoconfigure'
23+
compile 'org.springframework.boot:spring-boot-starter-logging'
24+
compile 'org.springframework.boot:spring-boot-starter-tomcat'
25+
console 'org.grails:grails-console'
26+
runtime 'org.grails.plugins:asset-pipeline'
27+
testCompile 'org.gebish:geb-core:0.12.2'
28+
testCompile 'org.grails.plugins:geb'
29+
30+
String seleniumVersion = '2.48.2'
31+
// testCompile 'com.github.detro:phantomjsdriver:1.2.0'
32+
testCompile 'com.codeborne:phantomjsdriver:1.2.1' // TODO switch back to com.github.detro:phantomjsdriver when this
33+
// issue is resolved: https://github.com/detro/ghostdriver/issues/397
34+
35+
testCompile "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
36+
['chrome', 'firefox'].each { String name ->
37+
testCompile "org.seleniumhq.selenium:selenium-${name}-driver:$seleniumVersion"
38+
}
39+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/* Copyright 2010-2015 the original author or authors.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
package grails.plugin.reveng
16+
17+
import grails.core.GrailsApplication
18+
import grails.dev.commands.ApplicationCommand
19+
import grails.dev.commands.ExecutionContext
20+
21+
/**
22+
* @author <a href='mailto:[email protected]'>Burt Beckwith</a>
23+
*/
24+
class DbReverseEngineerCommand implements ApplicationCommand {
25+
26+
final String description = 'Reverse-engineers a database and creates domain classes'
27+
28+
boolean handle(ExecutionContext executionContext) {
29+
RevengRunner runner = new RevengRunner()
30+
def mergedConfig = buildMergedConfig(executionContext)
31+
32+
println "Starting database reverse engineering, connecting to '$mergedConfig.url' as '$mergedConfig.username' ..."
33+
34+
runner.run mergedConfig
35+
36+
println 'Finished database reverse engineering'
37+
38+
true
39+
}
40+
41+
protected Map buildMergedConfig(ExecutionContext ctx) {
42+
43+
GrailsApplication grailsApplication = applicationContext.getBean(GrailsApplication)
44+
def config = grailsApplication.config
45+
46+
def mergedConfig = [
47+
alwaysMapManyToManyTables: false,
48+
defaultCatalog: '',
49+
defaultSchema: '',
50+
excludeColumnAntPatterns: [:],
51+
excludeColumnRegexes: [:],
52+
excludeColumns: [:],
53+
excludeTableAntPatterns: [],
54+
excludeTableRegexes: [],
55+
excludeTables: [],
56+
includeTableAntPatterns: [],
57+
includeTableRegexes: [],
58+
includeTables: [],
59+
manyToManyBelongsTos: [:],
60+
manyToManyTables: [],
61+
mappedManyToManyTables: [],
62+
overwriteExisting: true,
63+
versionColumns: [:]
64+
]
65+
66+
def dsConfig = config.dataSource
67+
68+
mergedConfig.driverClassName = dsConfig.driverClassName ?: 'org.h2.Driver'
69+
mergedConfig.password = dsConfig.password ?: ''
70+
mergedConfig.username = dsConfig.username ?: 'sa'
71+
mergedConfig.url = dsConfig.url ?: 'jdbc:h2:mem:testDB'
72+
if (dsConfig.dialect instanceof CharSequence) {
73+
mergedConfig.dialect = dsConfig.dialect.toString()
74+
}
75+
else if (dsConfig.dialect instanceof Class) {
76+
mergedConfig.dialect = dsConfig.dialect.name
77+
}
78+
79+
def revengConfig = config.grails.plugin.reveng
80+
mergedConfig.packageName = revengConfig.packageName ?:
81+
config.grails.codegen.defaultPackage ?:
82+
grailsApplication.metadata.getApplicationName()
83+
mergedConfig.destDir = new File(ctx.baseDir, revengConfig.destDir ?: 'grails-app/domain').canonicalPath
84+
if (revengConfig.defaultSchema) {
85+
mergedConfig.defaultSchema = revengConfig.defaultSchema
86+
}
87+
if (revengConfig.defaultCatalog) {
88+
mergedConfig.defaultCatalog = revengConfig.defaultCatalog
89+
}
90+
if (revengConfig.overwriteExisting instanceof Boolean) {
91+
mergedConfig.overwriteExisting = revengConfig.overwriteExisting
92+
}
93+
94+
if (revengConfig.alwaysMapManyToManyTables instanceof Boolean) {
95+
mergedConfig.alwaysMapManyToManyTables = revengConfig.alwaysMapManyToManyTables
96+
}
97+
98+
for (String name in ['versionColumns', 'manyToManyTables', 'manyToManyBelongsTos',
99+
'includeTables', 'includeTableRegexes', 'includeTableAntPatterns',
100+
'excludeTables', 'excludeTableRegexes', 'excludeTableAntPatterns',
101+
'excludeColumns', 'excludeColumnRegexes', 'excludeColumnAntPatterns',
102+
'mappedManyToManyTables']) {
103+
if (revengConfig[name]) {
104+
mergedConfig[name] = revengConfig[name]
105+
}
106+
}
107+
108+
mergedConfig
109+
}
110+
}

grails-app/conf/Config.groovy

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)