Skip to content

Commit 4522b5f

Browse files
committed
updated to Grails 3
1 parent 77a2ff9 commit 4522b5f

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

+905
-627
lines changed

.gitignore

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1+
*.iml
2+
*.iws
13
*.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
4+
.DS_Store
5+
.gradle
6+
.idea
7+
build
98
/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.

application.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

build.gradle

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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.2.RELEASE'
20+
id 'com.jfrog.bintray' version '1.2'
21+
}
22+
23+
version = file('version.txt').text.trim()
24+
group 'org.grails.plugins'
25+
26+
apply plugin: 'maven-publish'
27+
apply plugin: 'org.grails.grails-plugin'
28+
apply plugin: 'org.asciidoctor.convert'
29+
30+
apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/grailsCentralPublishing.gradle'
31+
apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle'
32+
33+
ext {
34+
grailsVersion = project.grailsVersion
35+
gradleWrapperVersion = project.gradleWrapperVersion
36+
}
37+
38+
sourceCompatibility = targetCompatibility = 1.7
39+
40+
repositories {
41+
mavenLocal()
42+
mavenCentral()
43+
maven { url 'https://repo.grails.org/grails/core' }
44+
}
45+
46+
dependencyManagement {
47+
imports {
48+
mavenBom "org.grails:grails-bom:$grailsVersion"
49+
}
50+
applyMavenExclusions false
51+
}
52+
53+
dependencies {
54+
55+
provided 'org.grails:grails-core'
56+
57+
compile 'org.hibernate:hibernate-tools:4.3.1.Final', {
58+
['ant', 'common', 'freemarker', 'org.eclipse.jdt.core', 'runtime', 'text'].each { exclude module: it }
59+
}
60+
61+
compile 'org.freemarker:freemarker:2.3.23'
62+
63+
compile 'org.hibernate:hibernate-core:4.3.10.Final'
64+
}
65+
66+
asciidoctor {
67+
separateOutputDirs = false
68+
sourceDir = file('src/docs')
69+
sources {
70+
include 'index.adoc'
71+
}
72+
outputDir file('build/docs')
73+
backends 'html5', 'pdf', 'epub3'
74+
attributes 'source-highlighter': 'prettify',
75+
icons: 'font',
76+
setanchors: 'true',
77+
idprefix: '',
78+
idseparator: '-',
79+
toc2: '',
80+
numbered: '',
81+
revnumber: project.version
82+
}
83+
84+
task docs(dependsOn: asciidoctor) << {
85+
File dir = file('build/docs')
86+
87+
['pdf', 'epub'].each { String ext ->
88+
File f = new File(dir, 'index.' + ext)
89+
if (f.exists()) {
90+
f.renameTo new File(dir, project.name + '-' + project.version + '.' + ext)
91+
}
92+
}
93+
94+
file('build/docs/ghpages.html') << file('src/docs/index.tmpl').text.replaceAll('@VERSION@', project.version)
95+
}

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
grailsVersion=3.0.11
2+
gradleWrapperVersion=2.10
3+
4+
websiteUrl=https://github.com/grails-plugins/grails-db-reverse-engineer
5+
issueTrackerUrl=http://jira.grails.org/browse/GPREVERSEENGINEER
6+
vcsUrl=https://github.com/grails-plugins/grails-db-reverse-engineer
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/BuildConfig.groovy

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

grails-app/conf/Config.groovy

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

grails-app/conf/DataSource.groovy

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

grails-app/conf/application.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
grails:
2+
profile: plugin
3+
info:
4+
app:
5+
name: '@info.app.name@'
6+
version: '@info.app.version@'
7+
grailsVersion: '@info.app.grailsVersion@'

grails-app/conf/logback.groovy

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import grails.util.BuildSettings
2+
import grails.util.Environment
3+
4+
String defaultPattern = '%-65(%.-2level %date{HH:mm:ss.SSS} %logger{32}) - %message%n'
5+
6+
appender('STDOUT', ConsoleAppender) {
7+
encoder(PatternLayoutEncoder) {
8+
pattern = defaultPattern
9+
}
10+
}
11+
12+
root ERROR, ['STDOUT']
13+
14+
File targetDir = BuildSettings.TARGET_DIR
15+
if (Environment.developmentMode && targetDir) {
16+
17+
appender('FULL_STACKTRACE', FileAppender) {
18+
file = "$targetDir/stacktrace.log"
19+
append = true
20+
encoder(PatternLayoutEncoder) {
21+
pattern = defaultPattern
22+
}
23+
}
24+
25+
logger 'StackTrace', ERROR, ['FULL_STACKTRACE'], false
26+
}

0 commit comments

Comments
 (0)