cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [2/6] cayenne git commit: CAY-2301 + gradle plugin for cgen, cdbgen and cdbimport
Date Mon, 29 May 2017 13:37:33 GMT
CAY-2301 + gradle plugin for cgen, cdbgen and cdbimport


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/95f11997
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/95f11997
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/95f11997

Branch: refs/heads/master
Commit: 95f11997f1cba0a0d5ae508a362f071450070d1f
Parents: f3f0126
Author: Maxim Petrusevich <maks1464@gmail.com>
Authored: Thu May 25 19:00:15 2017 +0300
Committer: Maxim Petrusevich <maks1464@gmail.com>
Committed: Thu May 25 19:00:15 2017 +0300

----------------------------------------------------------------------
 .gitignore                                      |   2 +
 .travis.yml                                     |   2 +-
 assembly/pom.xml                                |   2 +-
 .../resources/assemblies/assembly-generic.xml   |   2 +
 cayenne-gradle-plugin/build.gradle              |  58 +++
 .../gradle/wrapper/gradle-wrapper.jar           | Bin 0 -> 54783 bytes
 .../gradle/wrapper/gradle-wrapper.properties    |   6 +
 cayenne-gradle-plugin/gradlew                   | 172 ++++++++
 cayenne-gradle-plugin/gradlew.bat               |  84 ++++
 cayenne-gradle-plugin/pom.xml                   | 130 ++++++
 cayenne-gradle-plugin/settings.gradle           |  20 +
 .../apache/cayenne/tools/BaseCayenneTask.java   |  75 ++++
 .../java/org/apache/cayenne/tools/CgenTask.java | 393 +++++++++++++++++++
 .../apache/cayenne/tools/DbGenerateTask.java    | 232 +++++++++++
 .../org/apache/cayenne/tools/DbImportTask.java  | 170 ++++++++
 .../cayenne/tools/GradleCayenneExtension.java   | 131 +++++++
 .../org/apache/cayenne/tools/GradlePlugin.java  |  46 +++
 .../cayenne/tools/model/DataSourceConfig.java   |  96 +++++
 .../cayenne/tools/model/DbImportConfig.java     | 273 +++++++++++++
 .../cayenne/tools/model/FilterContainer.java    | 157 ++++++++
 .../cayenne/tools/model/IncludeTable.java       |  78 ++++
 .../cayenne/tools/model/PatternParam.java       |  83 ++++
 .../cayenne/tools/model/SchemaContainer.java    |  63 +++
 .../org.apache.cayenne.properties               |  19 +
 .../org/apache/cayenne/tools/BaseTaskIT.java    |  71 ++++
 .../org/apache/cayenne/tools/CgenTaskIT.java    |  89 +++++
 .../org/apache/cayenne/tools/CgenTaskTest.java  | 102 +++++
 .../apache/cayenne/tools/DbGenerateTaskIT.java  |  99 +++++
 .../org/apache/cayenne/tools/DbImportIT.java    | 113 ++++++
 .../apache/cayenne/tools/DbImportTaskTest.java  | 126 ++++++
 .../apache/cayenne/tools/GradlePluginIT.java    |  50 +++
 .../apache/cayenne/tools/GradlePluginTest.java  |  45 +++
 .../cayenne/tools/model/DbImportConfigTest.java | 114 ++++++
 .../tools/model/FilterContainerTest.java        | 121 ++++++
 .../cayenne/tools/model/IncludeTableTest.java   |  95 +++++
 .../cayenne/tools/model/PatternParamTest.java   |  79 ++++
 .../apache/cayenne/tools/cdbgen_custom.gradle   |  41 ++
 .../apache/cayenne/tools/cdbgen_failure.gradle  |  22 ++
 .../apache/cayenne/tools/cdbgen_simple.gradle   |  35 ++
 .../cayenne/tools/cgen_custom_config.gradle     |  31 ++
 .../cayenne/tools/cgen_default_config.gradle    |  27 ++
 .../cayenne/tools/dbimport_empty_db.gradle      |  35 ++
 .../cayenne/tools/dbimport_failure.gradle       |  22 ++
 .../cayenne/tools/dbimport_simple_db.gradle     |  39 ++
 .../apache/cayenne/tools/test_datamap.map.xml   |  44 +++
 .../org/apache/cayenne/tools/test_map_db.sql    |  53 +++
 docs/doc/pom.xml                                |   2 +-
 modeler/cayenne-modeler-win/pom.xml             |   2 +-
 pom.xml                                         |   1 +
 49 files changed, 3748 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index ac5c0e5..6fc0825 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,5 @@ bin/
 .idea
 *.iml
 .factorypath
+build
+.gradle

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 8929e43..3b8a5f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -36,7 +36,7 @@ jdk:
   - oraclejdk7
 
 script:
-  - mvn verify -q -DcayenneTestConnection=$DB_PROFILE -DcayenneLogLevel=ERROR
+  - mvn install -q -DcayenneTestConnection=$DB_PROFILE -DcayenneLogLevel=ERROR
 
 # prevent Travis from unneeded "mvn install" run
 install: /bin/true

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/assembly/pom.xml
----------------------------------------------------------------------
diff --git a/assembly/pom.xml b/assembly/pom.xml
index f60baf8..01b8da6 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -159,7 +159,7 @@
 	</build>
 
 	<profiles>
-		<!-- SOURCE assembly - the base assembly of a release build -->
+		<!-- SOURCE assembly - the base assembly of a relebuilduild -->
 		<profile>
 			<id>src</id>
 			<build>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/assembly/src/main/resources/assemblies/assembly-generic.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/assemblies/assembly-generic.xml b/assembly/src/main/resources/assemblies/assembly-generic.xml
index 3e850a2..ad121d3 100644
--- a/assembly/src/main/resources/assemblies/assembly-generic.xml
+++ b/assembly/src/main/resources/assemblies/assembly-generic.xml
@@ -37,6 +37,8 @@
 				<include>tutorial-rop-client/**</include>
 			</includes>
 			<excludes>
+				<exclude>**/.gradle/**</exclude>
+				<exclude>**/build/**</exclude>
 				<exclude>**/target/**</exclude>
 				<exclude>**/derby.log</exclude>
 				<exclude>**/.gitignore</exclude>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/build.gradle
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/build.gradle b/cayenne-gradle-plugin/build.gradle
new file mode 100644
index 0000000..9eb2f73
--- /dev/null
+++ b/cayenne-gradle-plugin/build.gradle
@@ -0,0 +1,58 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+plugins {
+    id 'java-gradle-plugin'
+}
+
+group 'org.apache.cayenne.plugins'
+version projectVersion
+def cayenneVersion = version
+
+apply plugin: 'java'
+
+sourceCompatibility = 1.8
+sourceCompatibility = 1.7
+
+repositories {
+    mavenLocal()
+    mavenCentral()
+}
+
+dependencies {
+    compile gradleApi()
+    compile localGroovy()
+    compile group: 'org.apache.cayenne', name: 'cayenne-cgen', version: cayenneVersion
+    testCompile group: 'junit', name: 'junit', version: '4.11'
+    testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
+    compile group: 'org.apache.derby', name: 'derby', version: '10.12.1.1'
+    testCompile group: 'org.apache.cayenne.build-tools', name: 'cayenne-test-utilities', version: cayenneVersion
+}
+
+// Create file with cayenne-gradle-plugin version
+task versionFile {
+    def resourceOutputDir = file("$buildDir/resources/main/")
+    doFirst {
+        resourceOutputDir.exists() || resourceOutputDir.mkdirs()
+        // file name must be in sync with GradleCayenneExtension
+        def file = file("$buildDir/resources/main/cayenne.version")
+        file.write(cayenneVersion.toString())
+    }
+}
+
+processResources.dependsOn versionFile

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/gradle/wrapper/gradle-wrapper.jar b/cayenne-gradle-plugin/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..50df0b7
Binary files /dev/null and b/cayenne-gradle-plugin/gradle/wrapper/gradle-wrapper.jar differ

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/cayenne-gradle-plugin/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..bfaedcc
--- /dev/null
+++ b/cayenne-gradle-plugin/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Thu May 25 16:50:56 MSK 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/gradlew
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/gradlew b/cayenne-gradle-plugin/gradlew
new file mode 100755
index 0000000..4453cce
--- /dev/null
+++ b/cayenne-gradle-plugin/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save ( ) {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/gradlew.bat
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/gradlew.bat b/cayenne-gradle-plugin/gradlew.bat
new file mode 100644
index 0000000..e95643d
--- /dev/null
+++ b/cayenne-gradle-plugin/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/pom.xml b/cayenne-gradle-plugin/pom.xml
new file mode 100644
index 0000000..3b7fbe4
--- /dev/null
+++ b/cayenne-gradle-plugin/pom.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+	license agreements. See the NOTICE file distributed with this work for additional
+	information regarding copyright ownership. The ASF licenses this file to
+	you under the Apache License, Version 2.0 (the "License"); you may not use
+	this file except in compliance with the License. You may obtain a copy of
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+	by applicable law or agreed to in writing, software distributed under the
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+	OF ANY KIND, either express or implied. See the License for the specific
+	language governing permissions and limitations under the License. -->
+<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">
+
+    <parent>
+        <artifactId>cayenne-parent</artifactId>
+        <groupId>org.apache.cayenne</groupId>
+        <version>4.0.M6-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.cayenne.plugins</groupId>
+    <artifactId>cayenne-gradle-plugin</artifactId>
+    <packaging>pom</packaging>
+    <name>cayenne-gradle-plugin: Cayenne Gradle Plugin</name>
+
+    <properties>
+        <groovy.version>2.4.10</groovy.version>
+        <gradle.version>3.5</gradle.version>
+        <gradle-plugins.version>0.9-preview-3</gradle-plugins.version>
+        <gradle.executable>./gradlew</gradle.executable>
+        <gradle.task>build</gradle.task>
+    </properties>
+
+    <profiles>
+        <profile>
+            <id>windows</id>
+            <activation>
+                <os>
+                    <family>windows</family>
+                </os>
+            </activation>
+            <properties>
+                <gradle.executable>./gradlew.bat</gradle.executable>
+            </properties>
+        </profile>
+        <profile>
+            <id>skipTests</id>
+            <activation>
+                <property>
+                    <name>skipTests</name>
+                    <value>true</value>
+                </property>
+            </activation>
+            <properties>
+                <gradle.task>assemble</gradle.task>
+            </properties>
+        </profile>
+    </profiles>
+
+    <build>
+        <plugins>
+            <!-- GRADLE TASKS EXECUTOR -->
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.6.0</version>
+                <executions>
+                    <execution>
+                        <id>gradle</id>
+                        <phase>prepare-package</phase>
+                        <configuration>
+                            <executable>${gradle.executable}</executable>
+                            <arguments>
+                                <argument>clean</argument>
+                                <argument>${gradle.task}</argument>
+                                <argument>-PprojectVersion=${project.version}</argument>
+                            </arguments>
+                        </configuration>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- ATTACH BUILD LIBS -->
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.12</version>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>build/libs/${project.artifactId}-${project.version}.jar</file>
+                                    <type>jar</type>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.cayenne</groupId>
+            <artifactId>cayenne-cgen</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/settings.gradle
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/settings.gradle b/cayenne-gradle-plugin/settings.gradle
new file mode 100644
index 0000000..6aa012c
--- /dev/null
+++ b/cayenne-gradle-plugin/settings.gradle
@@ -0,0 +1,20 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+rootProject.name = 'cayenne-gradle-plugin'
+

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/BaseCayenneTask.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/BaseCayenneTask.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/BaseCayenneTask.java
new file mode 100644
index 0000000..1a28570
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/BaseCayenneTask.java
@@ -0,0 +1,75 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import java.io.File;
+
+import org.gradle.api.DefaultTask;
+import org.gradle.api.InvalidUserDataException;
+import org.gradle.api.tasks.Internal;
+
+/**
+ * @since 4.0
+ */
+public class BaseCayenneTask extends DefaultTask {
+
+    @Internal
+    private File map;
+
+    @Internal
+    private String mapFileName;
+
+    public File getMap() {
+        return map;
+    }
+
+    public void setMap(File mapFile) {
+        map = mapFile;
+    }
+
+    public void setMap(String mapFileName) {
+        this.mapFileName = mapFileName;
+    }
+
+    public void map(String mapFileName) {
+        setMap(mapFileName);
+    }
+
+    public void map(File mapFile) {
+        setMap(mapFile);
+    }
+
+    @Internal
+    public File getDataMapFile() {
+        if (map != null) {
+            return map;
+        }
+
+        if (mapFileName == null) {
+            mapFileName = getProject().getExtensions().getByType(GradleCayenneExtension.class).getDefaultDataMap();
+        }
+
+        if (mapFileName != null) {
+            return getProject().file(mapFileName);
+        }
+
+        throw new InvalidUserDataException("No datamap configured in task or in cayenne.defaultDataMap.");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
new file mode 100644
index 0000000..59cd930
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
@@ -0,0 +1,393 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.Set;
+
+import groovy.lang.Reference;
+import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
+import org.apache.cayenne.gen.ClassGenerationAction;
+import org.apache.cayenne.gen.ClientClassGenerationAction;
+import org.apache.cayenne.map.DataMap;
+import org.gradle.api.Action;
+import org.gradle.api.GradleException;
+import org.gradle.api.InvalidUserDataException;
+import org.gradle.api.file.FileCollection;
+import org.gradle.api.plugins.JavaPlugin;
+import org.gradle.api.tasks.Input;
+import org.gradle.api.tasks.InputDirectory;
+import org.gradle.api.tasks.InputFile;
+import org.gradle.api.tasks.Optional;
+import org.gradle.api.tasks.OutputDirectory;
+import org.gradle.api.tasks.SourceSetContainer;
+import org.gradle.api.tasks.TaskAction;
+
+/**
+ * @since 4.0
+ */
+public class CgenTask extends BaseCayenneTask {
+
+    private static final File[] NO_FILES = new File[0];
+
+    private File additionalMaps;
+
+    @Input
+    private boolean client;
+
+    private File destDir;
+
+    @Input
+    @Optional
+    private String encoding;
+
+    @Input
+    @Optional
+    private String excludeEntities;
+
+    @Input
+    @Optional
+    private String includeEntities;
+
+    @Input
+    private boolean makePairs = true;
+
+    @Input
+    private String mode = "entity";
+
+    @Input
+    private String outputPattern = "*.java";
+
+    @Input
+    private boolean overwrite;
+
+    @Input
+    @Optional
+    private String superPkg;
+
+    @Input
+    @Optional
+    private String superTemplate;
+
+    @Input
+    @Optional
+    private String template;
+
+    @Input
+    @Optional
+    private String embeddableSuperTemplate;
+
+    @Input
+    @Optional
+    private String embeddableTemplate;
+
+    @Input
+    private boolean usePkgPath = true;
+
+    @Input
+    private boolean createPropertyNames;
+
+    private String destDirName;
+
+    @TaskAction
+    public void generate() {
+        File dataMapFile = getDataMapFile();
+        CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction();
+        loaderAction.setMainDataMapFile(dataMapFile);
+
+        CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
+        filterAction.setClient(client);
+        filterAction.setNameFilter(NamePatternMatcher.build(getLogger(), includeEntities, excludeEntities));
+
+        try {
+            loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
+
+            ClassGenerationAction generator = this.createGenerator();
+            DataMap dataMap = loaderAction.getMainDataMap();
+
+            generator.setLogger(getLogger());
+            generator.setTimestamp(dataMapFile.lastModified());
+            generator.setDataMap(dataMap);
+            generator.addEntities(filterAction.getFilteredEntities(dataMap));
+            generator.addEmbeddables(dataMap.getEmbeddables());
+            generator.addQueries(dataMap.getQueryDescriptors());
+            generator.execute();
+        } catch (Exception exception) {
+            throw new GradleException("Error generating classes: ", exception);
+        }
+    }
+
+    private File[] convertAdditionalDataMaps() throws Exception {
+        if (additionalMaps == null) {
+            return NO_FILES;
+        }
+
+        if (!additionalMaps.isDirectory()) {
+            throw new GradleException("'additionalMaps' must be a directory.");
+        }
+
+        FilenameFilter mapFilter = new FilenameFilter() {
+            public boolean accept(File dir, String name) {
+                return name != null && name.toLowerCase().endsWith(".map.xml");
+            }
+
+        };
+        return additionalMaps.listFiles(mapFilter);
+    }
+
+    ClassGenerationAction newGeneratorInstance() {
+        return client ? new ClientClassGenerationAction() : new ClassGenerationAction();
+    }
+
+    ClassGenerationAction createGenerator() {
+        ClassGenerationAction action = newGeneratorInstance();
+
+        action.setDestDir(getDestDirFile());
+        action.setEncoding(encoding);
+        action.setMakePairs(makePairs);
+        action.setArtifactsGenerationMode(mode);
+        action.setOutputPattern(outputPattern);
+        action.setOverwrite(overwrite);
+        action.setSuperPkg(superPkg);
+        action.setSuperTemplate(superTemplate);
+        action.setTemplate(template);
+        action.setEmbeddableSuperTemplate(embeddableSuperTemplate);
+        action.setEmbeddableTemplate(embeddableTemplate);
+        action.setUsePkgPath(usePkgPath);
+        action.setCreatePropertyNames(createPropertyNames);
+
+        return action;
+    }
+
+    @OutputDirectory
+    protected File getDestDirFile() {
+        final Reference<File> javaSourceDir = new Reference<>(null);
+
+        if (destDir != null) {
+            javaSourceDir.set(destDir);
+        } else if (destDirName != null) {
+            javaSourceDir.set(getProject().file(destDirName));
+        } else {
+            getProject().getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
+                @Override
+                public void execute(final JavaPlugin plugin) {
+                    SourceSetContainer sourceSets = (SourceSetContainer)getProject().getProperties().get("sourceSets");
+
+                    final FileCollection directories = sourceSets.getByName("main").getJava().getSourceDirectories();
+                    Set<File> sourceDirs = (directories == null ? null : directories.getFiles());
+                    if (sourceDirs != null && !sourceDirs.isEmpty()) {
+                        // find java directory, if there is no such dir, take first
+                        for(File dir : sourceDirs) {
+                            if(dir.getName().endsWith("java")) {
+                                javaSourceDir.set(dir);
+                                break;
+                            }
+                        }
+
+                        if (javaSourceDir.get() == null) {
+                            javaSourceDir.set(sourceDirs.iterator().next());
+                        }
+                    }
+                }
+            });
+        }
+
+        if (javaSourceDir.get() == null) {
+            throw new InvalidUserDataException("cgen.destDir is not set and there is no Java source sets found.");
+        }
+
+        if (!javaSourceDir.get().exists()) {
+            javaSourceDir.get().mkdirs();
+        }
+
+        return javaSourceDir.get();
+    }
+
+    @InputFile
+    public File getDataMapFile() {
+        return super.getDataMapFile();
+    }
+
+    @Optional
+    @OutputDirectory
+    public File getDestDir() {
+        return destDir;
+    }
+
+    public void setDestDir(File destDir) {
+        this.destDir = destDir;
+    }
+
+    public void setDestDir(String destDir) {
+        this.destDirName = destDir;
+    }
+
+    @Optional
+    @InputDirectory
+    public File getAdditionalMaps() {
+        return additionalMaps;
+    }
+
+    public void setAdditionalMaps(File additionalMaps) {
+        this.additionalMaps = additionalMaps;
+    }
+
+    public boolean getClient() {
+        return client;
+    }
+
+    public boolean isClient() {
+        return client;
+    }
+
+    public void setClient(boolean client) {
+        this.client = client;
+    }
+
+    public String getEncoding() {
+        return encoding;
+    }
+
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
+    }
+
+    public String getExcludeEntities() {
+        return excludeEntities;
+    }
+
+    public void setExcludeEntities(String excludeEntities) {
+        this.excludeEntities = excludeEntities;
+    }
+
+    public String getIncludeEntities() {
+        return includeEntities;
+    }
+
+    public void setIncludeEntities(String includeEntities) {
+        this.includeEntities = includeEntities;
+    }
+
+    public boolean getMakePairs() {
+        return makePairs;
+    }
+
+    public boolean isMakePairs() {
+        return makePairs;
+    }
+
+    public void setMakePairs(boolean makePairs) {
+        this.makePairs = makePairs;
+    }
+
+    public String getMode() {
+        return mode;
+    }
+
+    public void setMode(String mode) {
+        this.mode = mode;
+    }
+
+    public String getOutputPattern() {
+        return outputPattern;
+    }
+
+    public void setOutputPattern(String outputPattern) {
+        this.outputPattern = outputPattern;
+    }
+
+    public boolean getOverwrite() {
+        return overwrite;
+    }
+
+    public boolean isOverwrite() {
+        return overwrite;
+    }
+
+    public void setOverwrite(boolean overwrite) {
+        this.overwrite = overwrite;
+    }
+
+    public String getSuperPkg() {
+        return superPkg;
+    }
+
+    public void setSuperPkg(String superPkg) {
+        this.superPkg = superPkg;
+    }
+
+    public String getSuperTemplate() {
+        return superTemplate;
+    }
+
+    public void setSuperTemplate(String superTemplate) {
+        this.superTemplate = superTemplate;
+    }
+
+    public String getTemplate() {
+        return template;
+    }
+
+    public void setTemplate(String template) {
+        this.template = template;
+    }
+
+    public String getEmbeddableSuperTemplate() {
+        return embeddableSuperTemplate;
+    }
+
+    public void setEmbeddableSuperTemplate(String embeddableSuperTemplate) {
+        this.embeddableSuperTemplate = embeddableSuperTemplate;
+    }
+
+    public String getEmbeddableTemplate() {
+        return embeddableTemplate;
+    }
+
+    public void setEmbeddableTemplate(String embeddableTemplate) {
+        this.embeddableTemplate = embeddableTemplate;
+    }
+
+    public boolean getUsePkgPath() {
+        return usePkgPath;
+    }
+
+    public boolean isUsePkgPath() {
+        return usePkgPath;
+    }
+
+    public void setUsePkgPath(boolean usePkgPath) {
+        this.usePkgPath = usePkgPath;
+    }
+
+    public boolean getCreatePropertyNames() {
+        return createPropertyNames;
+    }
+
+    public boolean isCreatePropertyNames() {
+        return createPropertyNames;
+    }
+
+    public void setCreatePropertyNames(boolean createPropertyNames) {
+        this.createPropertyNames = createPropertyNames;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java
new file mode 100644
index 0000000..4e5ec39
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java
@@ -0,0 +1,232 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import groovy.lang.Closure;
+import org.apache.cayenne.access.DbGenerator;
+import org.apache.cayenne.datasource.DataSourceBuilder;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.dbsync.DbSyncModule;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.log.NoopJdbcEventLogger;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.MapLoader;
+import org.apache.cayenne.tools.model.DataSourceConfig;
+import org.apache.cayenne.util.Util;
+import org.gradle.api.GradleException;
+import org.gradle.api.tasks.Input;
+import org.gradle.api.tasks.InputFile;
+import org.gradle.api.tasks.Internal;
+import org.gradle.api.tasks.Optional;
+import org.gradle.api.tasks.TaskAction;
+import org.xml.sax.InputSource;
+
+import java.io.File;
+import javax.sql.DataSource;
+
+/**
+ * @since 4.0
+ */
+public class DbGenerateTask extends BaseCayenneTask {
+
+    @Input
+    @Optional
+    private String adapter;
+
+    @Internal
+    private DataSourceConfig dataSource = new DataSourceConfig();
+
+    @Input
+    @Optional
+    private boolean dropTables;
+
+    @Input
+    @Optional
+    private boolean dropPK;
+
+    @Input
+    @Optional
+    private boolean createTables = true;
+
+    @Input
+    @Optional
+    private boolean createPK = true;
+
+    @Input
+    @Optional
+    private boolean createFK = true;
+
+    @InputFile
+    public File getDataMapFile() {
+        return super.getDataMapFile();
+    }
+
+    @TaskAction
+    public void generateDb() throws GradleException {
+
+        dataSource.validate();
+
+        getLogger().info("connection settings - [driver: {}, url: {}, username: {}]",
+                dataSource.getDriver(), dataSource.getUrl(), dataSource.getUsername());
+
+        getLogger().info("generator options - " +
+                        "[dropTables: {}, dropPK: {}, createTables: {}, createPK: {}, createFK: {}]",
+                dropTables, dropPK, createTables, createPK, createFK);
+
+        try {
+            DbGenerator generator = createGenerator(loadDataMap());
+            generator.runGenerator(createDataSource());
+        } catch (Exception ex) {
+            Throwable th = Util.unwindException(ex);
+            String message = "Error generating database";
+            if (th.getLocalizedMessage() != null) {
+                message += ": " + th.getLocalizedMessage();
+            }
+
+            getLogger().error(message);
+            throw new GradleException(message, th);
+        }
+    }
+
+    DbGenerator createGenerator(DataMap dataMap) {
+        DbGenerator generator = new DbGenerator(createDbAdapter(), dataMap, NoopJdbcEventLogger.getInstance());
+        generator.setShouldCreateFKConstraints(createFK);
+        generator.setShouldCreatePKSupport(createPK);
+        generator.setShouldCreateTables(createTables);
+        generator.setShouldDropPKSupport(dropPK);
+        generator.setShouldDropTables(dropTables);
+        return generator;
+    }
+
+    DbAdapter createDbAdapter() {
+        Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(getLogger()));
+        AdhocObjectFactory objectFactory = injector.getInstance(AdhocObjectFactory.class);
+
+        return (adapter == null)
+                ? objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName())
+                : objectFactory.newInstance(DbAdapter.class, adapter);
+    }
+
+    DataSource createDataSource() {
+        return DataSourceBuilder.url(dataSource.getUrl())
+                .driver(dataSource.getDriver())
+                .userName(dataSource.getUsername())
+                .password(dataSource.getPassword())
+                .build();
+    }
+
+    DataMap loadDataMap() throws Exception {
+        File dataMapFile = getDataMapFile();
+        InputSource inputSource = new InputSource(dataMapFile.getCanonicalPath());
+        return new MapLoader().loadDataMap(inputSource);
+    }
+
+    // setters and getters that will be used by .gradle scripts
+
+    public String getAdapter() {
+        return adapter;
+    }
+
+    public void setAdapter(String adapter) {
+        this.adapter = adapter;
+    }
+
+    public void adapter(String adapter) {
+        setAdapter(adapter);
+    }
+
+    public DataSourceConfig getDataSource() {
+        return dataSource;
+    }
+
+    public void setDataSource(DataSourceConfig dataSource) {
+        this.dataSource = dataSource;
+    }
+
+    public DataSourceConfig dataSource(Closure closure) {
+        dataSource = new DataSourceConfig();
+        getProject().configure(dataSource, closure);
+        return dataSource;
+    }
+
+    public boolean isDropTables() {
+        return dropTables;
+    }
+
+    public void setDropTables(boolean dropTables) {
+        this.dropTables = dropTables;
+    }
+
+    public void dropTables(boolean dropTables) {
+        setDropTables(dropTables);
+    }
+
+    public boolean isDropPK() {
+        return dropPK;
+    }
+
+    public void setDropPK(boolean dropPK) {
+        this.dropPK = dropPK;
+    }
+
+    public void dropPK(boolean dropPK) {
+        setDropPK(dropPK);
+    }
+
+    public boolean isCreateTables() {
+        return createTables;
+    }
+
+    public void setCreateTables(boolean createTables) {
+        this.createTables = createTables;
+    }
+
+    public void createTables(boolean createTables) {
+        setCreateTables(createTables);
+    }
+
+    public boolean isCreatePK() {
+        return createPK;
+    }
+
+    public void setCreatePK(boolean createPK) {
+        this.createPK = createPK;
+    }
+
+    public void createPK(boolean createPK) {
+        setCreatePK(createPK);
+    }
+
+    public boolean isCreateFK() {
+        return createFK;
+    }
+
+    public void setCreateFK(boolean createFK) {
+        this.createFK = createFK;
+    }
+
+    public void createFK(boolean createFK) {
+        setCreateFK(createFK);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbImportTask.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbImportTask.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbImportTask.java
new file mode 100644
index 0000000..c640439
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbImportTask.java
@@ -0,0 +1,170 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import java.io.File;
+
+import groovy.lang.Closure;
+import org.apache.cayenne.dbsync.DbSyncModule;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportAction;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfigurationValidator;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule;
+import org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering;
+import org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.tools.model.DataSourceConfig;
+import org.apache.cayenne.tools.model.DbImportConfig;
+import org.apache.cayenne.util.Util;
+import org.gradle.api.Task;
+import org.gradle.api.specs.Spec;
+import org.gradle.api.tasks.Input;
+import org.gradle.api.tasks.Internal;
+import org.gradle.api.tasks.Optional;
+import org.gradle.api.tasks.OutputFile;
+import org.gradle.api.tasks.TaskAction;
+import org.gradle.api.tasks.TaskExecutionException;
+
+/**
+ * @since 4.0
+ */
+public class DbImportTask extends BaseCayenneTask {
+
+    @Input
+    @Optional
+    private String adapter;
+
+    @Internal
+    private DataSourceConfig dataSource = new DataSourceConfig();
+
+    @Internal
+    private DbImportConfig config = new DbImportConfig();
+
+    @Internal
+    private ReverseEngineering reverseEngineering;
+
+    public DbImportTask() {
+        // this task should be executed every invocation, so it is never up to date.
+        getOutputs().upToDateWhen(new Spec<Task>() {
+            @Override
+            public boolean isSatisfiedBy(Task task) {
+                return false;
+            }
+        });
+    }
+
+    @TaskAction
+    public void runImport() {
+        dataSource.validate();
+
+        DbImportConfiguration config = createConfig();
+
+        Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(getLogger()), new DbImportModule());
+
+        DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);
+        try {
+            validator.validate();
+        } catch (Exception ex) {
+            throw new TaskExecutionException(this, ex);
+        }
+
+        try {
+            injector.getInstance(DbImportAction.class).execute(config);
+        } catch (Exception ex) {
+            Throwable th = Util.unwindException(ex);
+
+            String message = "Error importing database schema";
+
+            if (th.getLocalizedMessage() != null) {
+                message += ": " + th.getLocalizedMessage();
+            }
+
+            getLogger().error(message);
+            throw new TaskExecutionException(this, th);
+        }
+    }
+
+    DbImportConfiguration createConfig() {
+
+        reverseEngineering = config.toReverseEngineering();
+
+        DbImportConfiguration config = new DbImportConfiguration();
+        config.setAdapter(adapter);
+        config.setDefaultPackage(reverseEngineering.getDefaultPackage());
+        config.setDriver(dataSource.getDriver());
+        config.setFiltersConfig(new FiltersConfigBuilder(reverseEngineering).build());
+        config.setForceDataMapCatalog(reverseEngineering.isForceDataMapCatalog());
+        config.setForceDataMapSchema(reverseEngineering.isForceDataMapSchema());
+        config.setLogger(getLogger());
+        config.setMeaningfulPkTables(reverseEngineering.getMeaningfulPkTables());
+        config.setNamingStrategy(reverseEngineering.getNamingStrategy());
+        config.setPassword(dataSource.getPassword());
+        config.setSkipRelationshipsLoading(reverseEngineering.getSkipRelationshipsLoading());
+        config.setSkipPrimaryKeyLoading(reverseEngineering.getSkipPrimaryKeyLoading());
+        config.setStripFromTableNames(reverseEngineering.getStripFromTableNames());
+        config.setTableTypes(reverseEngineering.getTableTypes());
+        config.setTargetDataMap(getDataMapFile());
+        config.setUrl(dataSource.getUrl());
+        config.setUsername(dataSource.getUsername());
+        config.setUsePrimitives(reverseEngineering.isUsePrimitives());
+        config.setUseJava7Types(reverseEngineering.isUseJava7Types());
+
+        return config;
+    }
+
+    @OutputFile
+    public File getDataMapFile() {
+        return super.getDataMapFile();
+    }
+
+    public void dbImport(Closure<?> closure) {
+        getProject().configure(config, closure);
+    }
+
+    public void dbimport(Closure<?> closure) {
+        dbImport(closure);
+    }
+
+    public void dataSource(Closure<?> closure) {
+        getProject().configure(dataSource, closure);
+    }
+
+    public DataSourceConfig getDataSource() {
+        return dataSource;
+    }
+
+    public DbImportConfig getConfig() {
+        return config;
+    }
+
+    public String getAdapter() {
+        return adapter;
+    }
+
+    public void setAdapter(String adapter) {
+        this.adapter = adapter;
+    }
+
+    public void adapter(String adapter) {
+        setAdapter(adapter);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/GradleCayenneExtension.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/GradleCayenneExtension.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/GradleCayenneExtension.java
new file mode 100644
index 0000000..78c0477
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/GradleCayenneExtension.java
@@ -0,0 +1,131 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.codehaus.groovy.runtime.ResourceGroovyMethods;
+import org.gradle.api.GradleException;
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Dependency;
+import org.gradle.api.artifacts.dsl.DependencyHandler;
+
+/**
+ * Cayenne DSL for gradle
+ * <p>
+ * - dependency management
+ * - utility methods
+ *
+ * @since 4.0
+ */
+public class GradleCayenneExtension {
+
+    public static final String GROUP = "org.apache.cayenne";
+    private static final String VERSION_FILE = "/cayenne.version";
+
+    private String version;
+    private final DependencyHandler dependencies;
+
+    /**
+     * Shortcut for the cgen task.
+     * Can be used in defining additional tasks like:
+     * <pre>{@code
+     * task customCgen(type: cayenne.cgen) {
+     *     //...
+     * }
+     * }</pre>
+     */
+    private final Class<CgenTask> cgen = CgenTask.class;
+
+    /**
+     * Shortcut for the cdbimport task.
+     * Can be used in defining additional tasks like:
+     * <pre>{@code
+     * task customCdbimport(type: cayenne.cdbimport) {
+     *     //...
+     * }
+     * }</pre>
+     */
+    private final Class<DbImportTask> cdbimport = DbImportTask.class;
+
+    /**
+     * Shortcut for the cdbgen task.
+     * Can be used in defining additional tasks like:
+     * <pre>{@code
+     * task customCdbgen(type: cayenne.cdbgen) {
+     *     //...
+     * }
+     * }</pre>
+     */
+    private final Class<DbGenerateTask> cdbgen = DbGenerateTask.class;
+
+    /**
+     * Default data map that will be used in all tasks.
+     * Can be overridden per task.
+     */
+    private String defaultDataMap;
+
+    public GradleCayenneExtension(Project project) {
+        this.dependencies = project.getDependencies();
+        try {
+            readVersion(project);
+        } catch (IOException ex) {
+            throw new GradleException("Cayenne version not found", ex);
+        }
+    }
+
+    private void readVersion(Project project) throws IOException {
+        URL versionFileUrl = getClass().getResource(VERSION_FILE);
+        if(versionFileUrl == null) {
+            this.version = project.getVersion().toString();
+        } else {
+            this.version = ResourceGroovyMethods.getText(versionFileUrl).trim();
+        }
+    }
+
+    public Dependency dependency(final String name) {
+        return dependencies.create(GROUP + ":cayenne-" + name + ":" + version);
+    }
+
+    public String getDefaultDataMap() {
+        return defaultDataMap;
+    }
+
+    public void setDefaultDataMap(String defaultDataMap) {
+        this.defaultDataMap = defaultDataMap;
+    }
+
+    public Class<CgenTask> getCgen() {
+        return cgen;
+    }
+
+    public Class<DbImportTask> getCdbimport() {
+        return cdbimport;
+    }
+
+    public Class<DbGenerateTask> getCdbgen() {
+        return cdbgen;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/GradlePlugin.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/GradlePlugin.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/GradlePlugin.java
new file mode 100644
index 0000000..d15888c
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/GradlePlugin.java
@@ -0,0 +1,46 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+
+public class GradlePlugin implements Plugin<Project> {
+    public void apply(Project project) {
+        // Add DSL extension
+        project.getExtensions().create("cayenne", GradleCayenneExtension.class, project);
+
+        // Register tasks
+        Map<String, Object> map = new HashMap<>(1);
+        map.put("type", CgenTask.class);
+        project.task(map, "cgen");
+
+        Map<String, Object> map1 = new HashMap<>(1);
+        map1.put("type", DbImportTask.class);
+        project.task(map1, "cdbimport");
+
+        Map<String, Object> map2 = new HashMap<>(1);
+        map2.put("type", DbGenerateTask.class);
+        project.task(map2, "cdbgen");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/DataSourceConfig.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/DataSourceConfig.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/DataSourceConfig.java
new file mode 100644
index 0000000..1fb3bd4
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/DataSourceConfig.java
@@ -0,0 +1,96 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools.model;
+
+import org.gradle.api.InvalidUserDataException;
+
+/**
+ * @since 4.0
+ */
+public class DataSourceConfig {
+
+    private String driver;
+    private String url;
+    private String username;
+    private String password;
+
+    public void validate() {
+        if (driver == null && url == null && username == null && password == null) {
+            throw new InvalidUserDataException("Missing dataSource configuration.");
+        }
+
+        if (driver == null) {
+            throw new InvalidUserDataException("Missing required 'driver' parameter in dataSource.");
+        }
+
+        if (url == null) {
+            throw new InvalidUserDataException("Missing required 'url' parameter in dataSource.");
+        }
+    }
+
+    public String getDriver() {
+        return driver;
+    }
+
+    public void setDriver(String driver) {
+        this.driver = driver;
+    }
+
+    public void driver(String driver) {
+        setDriver(driver);
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public void url(String url) {
+        setUrl(url);
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public void username(String username) {
+        setUsername(username);
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void password(String password) {
+        setPassword(password);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/DbImportConfig.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/DbImportConfig.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/DbImportConfig.java
new file mode 100644
index 0000000..a29a38b
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/DbImportConfig.java
@@ -0,0 +1,273 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools.model;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+
+import groovy.lang.Closure;
+import org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering;
+import org.apache.cayenne.dbsync.reverse.dbimport.Schema;
+import org.gradle.util.ConfigureUtil;
+
+/**
+ * @since 4.0
+ */
+public class DbImportConfig extends SchemaContainer {
+
+    private boolean skipRelationshipsLoading;
+
+    private boolean skipPrimaryKeyLoading;
+
+    private String defaultPackage;
+
+    /**
+     * <p>
+     * Automatically tagging each DbEntity with the actual DB catalog/schema (default behavior) may sometimes be undesirable.
+     * If this is the case then setting forceDataMapCatalog to true will set DbEntity catalog to one in the DataMap.
+     * </p>
+     * <p>
+     * Default value is <b>false</b>.
+     * </p>
+     */
+    private boolean forceDataMapCatalog;
+
+    /**
+     * <p>
+     * Automatically tagging each DbEntity with the actual DB catalog/schema (default behavior) may sometimes be undesirable.
+     * If this is the case then setting forceDataMapSchema to true will set DbEntity schema to one in the DataMap.
+     * </p>
+     * <p>
+     * Default value is <b>false</b>.
+     * </p>
+     */
+    private boolean forceDataMapSchema;
+
+    /**
+     * <p>
+     * A comma-separated list of Perl5 patterns that defines which imported tables should have their primary key columns
+     * mapped as ObjAttributes.
+     * </p>
+     * <p><b>"*"</b> would indicate all tables.</p>
+     */
+    private String meaningfulPkTables;
+
+    /**
+     * <p>
+     * Object layer naming generator implementation.
+     * Should be fully qualified Java class name implementing "org.apache.cayenne.dbsync.naming.ObjectNameGenerator".
+     * </p>
+     * <p>
+     * The default is "org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator".
+     * </p>
+     */
+    private String namingStrategy = "org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator";
+
+    /**
+     * A regular expression that should match the part of the table name to strip before generating DB names.
+     */
+    private String stripFromTableNames = "";
+
+    /**
+     * <p>If true, would use primitives instead of numeric and boolean classes.</p>
+     * <p>Default is <b>"true"</b>, i.e. primitives will be used.</p>
+     */
+    private boolean usePrimitives = true;
+
+    /**
+     * Use old Java 7 date types
+     */
+    private boolean useJava7Types = false;
+
+    /**
+     * Typical types are: <ul>
+     * <li> "TABLE"
+     * <li> "VIEW"
+     * <li> "SYSTEM TABLE"
+     * <li> "GLOBAL TEMPORARY",
+     * <li> "LOCAL TEMPORARY"
+     * <li> "ALIAS"
+     * <li> "SYNONYM"
+     * </ul>
+     */
+    private Collection<String> tableTypes = new LinkedList<>();
+
+    private Collection<SchemaContainer> catalogs = new LinkedList<>();
+
+    public void catalog(String name) {
+        catalogs.add(new SchemaContainer(name));
+    }
+
+    public void catalog(Closure<?> closure) {
+        catalogs.add(ConfigureUtil.configure(closure, new SchemaContainer()));
+    }
+
+    public void catalog(String name, Closure<?> closure) {
+        catalogs.add(ConfigureUtil.configure(closure, new SchemaContainer(name)));
+    }
+
+    public ReverseEngineering toReverseEngineering() {
+        final ReverseEngineering reverseEngineering = new ReverseEngineering();
+        reverseEngineering.setSkipRelationshipsLoading(skipRelationshipsLoading);
+        reverseEngineering.setSkipPrimaryKeyLoading(skipPrimaryKeyLoading);
+        reverseEngineering.setForceDataMapCatalog(forceDataMapCatalog);
+        reverseEngineering.setForceDataMapSchema(forceDataMapSchema);
+        reverseEngineering.setDefaultPackage(defaultPackage);
+        reverseEngineering.setMeaningfulPkTables(meaningfulPkTables);
+        reverseEngineering.setNamingStrategy(namingStrategy);
+        reverseEngineering.setStripFromTableNames(stripFromTableNames);
+        reverseEngineering.setUsePrimitives(usePrimitives);
+        reverseEngineering.setUseJava7Types(useJava7Types);
+        reverseEngineering.setTableTypes(tableTypes);
+
+        for(SchemaContainer catalog : catalogs) {
+            reverseEngineering.addCatalog(catalog.toCatalog());
+        }
+
+        for(FilterContainer schema : schemas) {
+            reverseEngineering.addSchema(schema.fillContainer(new Schema()));
+        }
+
+        fillContainer(reverseEngineering);
+
+        return reverseEngineering;
+    }
+
+    public boolean getSkipRelationshipsLoading() {
+        return skipRelationshipsLoading;
+    }
+
+    public boolean isSkipRelationshipsLoading() {
+        return skipRelationshipsLoading;
+    }
+
+    public void setSkipRelationshipsLoading(boolean skipRelationshipsLoading) {
+        this.skipRelationshipsLoading = skipRelationshipsLoading;
+    }
+
+    public boolean getSkipPrimaryKeyLoading() {
+        return skipPrimaryKeyLoading;
+    }
+
+    public boolean isSkipPrimaryKeyLoading() {
+        return skipPrimaryKeyLoading;
+    }
+
+    public void setSkipPrimaryKeyLoading(boolean skipPrimaryKeyLoading) {
+        this.skipPrimaryKeyLoading = skipPrimaryKeyLoading;
+    }
+
+    public String getDefaultPackage() {
+        return defaultPackage;
+    }
+
+    public void setDefaultPackage(String defaultPackage) {
+        this.defaultPackage = defaultPackage;
+    }
+
+    public boolean getForceDataMapCatalog() {
+        return forceDataMapCatalog;
+    }
+
+    public boolean isForceDataMapCatalog() {
+        return forceDataMapCatalog;
+    }
+
+    public void setForceDataMapCatalog(boolean forceDataMapCatalog) {
+        this.forceDataMapCatalog = forceDataMapCatalog;
+    }
+
+    public boolean getForceDataMapSchema() {
+        return forceDataMapSchema;
+    }
+
+    public boolean isForceDataMapSchema() {
+        return forceDataMapSchema;
+    }
+
+    public void setForceDataMapSchema(boolean forceDataMapSchema) {
+        this.forceDataMapSchema = forceDataMapSchema;
+    }
+
+    public String getMeaningfulPkTables() {
+        return meaningfulPkTables;
+    }
+
+    public void setMeaningfulPkTables(String meaningfulPkTables) {
+        this.meaningfulPkTables = meaningfulPkTables;
+    }
+
+    public String getNamingStrategy() {
+        return namingStrategy;
+    }
+
+    public void setNamingStrategy(String namingStrategy) {
+        this.namingStrategy = namingStrategy;
+    }
+
+    public String getStripFromTableNames() {
+        return stripFromTableNames;
+    }
+
+    public void setStripFromTableNames(String stripFromTableNames) {
+        this.stripFromTableNames = stripFromTableNames;
+    }
+
+    public boolean getUsePrimitives() {
+        return usePrimitives;
+    }
+
+    public boolean isUsePrimitives() {
+        return usePrimitives;
+    }
+
+    public void setUsePrimitives(boolean usePrimitives) {
+        this.usePrimitives = usePrimitives;
+    }
+
+    public boolean getUseJava7Types() {
+        return useJava7Types;
+    }
+
+    public boolean isUseJava7Types() {
+        return useJava7Types;
+    }
+
+    public void setUseJava7Types(boolean useJava7Types) {
+        this.useJava7Types = useJava7Types;
+    }
+
+    public Collection<String> getTableTypes() {
+        return tableTypes;
+    }
+
+    public void setTableTypes(Collection<String> tableTypes) {
+        this.tableTypes = tableTypes;
+    }
+
+    public void tableType(String tableType) {
+        tableTypes.add(tableType);
+    }
+
+    public void tableTypes(String... tableTypes) {
+        this.tableTypes.addAll(Arrays.asList(tableTypes));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/FilterContainer.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/FilterContainer.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/FilterContainer.java
new file mode 100644
index 0000000..734ca70
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/FilterContainer.java
@@ -0,0 +1,157 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools.model;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import groovy.lang.Closure;
+import org.gradle.util.ConfigureUtil;
+
+/**
+ * @since 4.0
+ */
+public class FilterContainer {
+
+    private String name;
+    private Collection<IncludeTable> includeTables = new LinkedList<>();
+    private Collection<PatternParam> excludeTables = new LinkedList<>();
+    private Collection<PatternParam> includeColumns = new LinkedList<>();
+    private Collection<PatternParam> excludeColumns = new LinkedList<>();
+    private Collection<PatternParam> includeProcedures = new LinkedList<>();
+    private Collection<PatternParam> excludeProcedures = new LinkedList<>();
+
+    FilterContainer() {
+    }
+
+    FilterContainer(String name) {
+        this.name = name;
+    }
+
+    public void name(String name) {
+        this.name = name;
+    }
+
+    public void includeTable(String pattern) {
+        includeTables.add(new IncludeTable(pattern));
+    }
+
+    public void includeTable(Closure<?> closure) {
+        includeTables.add(ConfigureUtil.configure(closure, new IncludeTable()));
+    }
+
+    public void includeTable(String pattern, Closure<?> closure) {
+        includeTables.add(ConfigureUtil.configure(closure, new IncludeTable(pattern)));
+    }
+
+    public void includeTables(String... patterns) {
+        for(String pattern: patterns) {
+            includeTable(pattern);
+        }
+    }
+
+    public void excludeTable(String pattern) {
+        addToCollection(excludeTables, pattern);
+    }
+
+    public void excludeTables(String... patterns) {
+        for(String pattern: patterns) {
+            excludeTable(pattern);
+        }
+    }
+
+    public void includeColumn(String pattern) {
+        addToCollection(includeColumns, pattern);
+    }
+
+    public void includeColumns(String... patterns) {
+        for(String pattern: patterns) {
+            includeColumn(pattern);
+        }
+    }
+
+    public void excludeColumn(String pattern) {
+        addToCollection(excludeColumns, pattern);
+    }
+
+    public void excludeColumns(String... patterns) {
+        for(String pattern: patterns) {
+            excludeColumn(pattern);
+        }
+    }
+
+    public void includeProcedure(String pattern) {
+        addToCollection(includeProcedures, pattern);
+    }
+
+    public void includeProcedures(String... patterns) {
+        for(String pattern: patterns) {
+            includeProcedure(pattern);
+        }
+    }
+
+    public void excludeProcedure(String pattern) {
+        addToCollection(excludeProcedures, pattern);
+    }
+
+    public void excludeProcedures(String... patterns) {
+        for(String pattern: patterns) {
+            excludeProcedure(pattern);
+        }
+    }
+
+    private static void addToCollection(Collection<PatternParam> collection, String name) {
+        collection.add(new PatternParam(name));
+    }
+
+    <C extends org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer> C fillContainer(final C container) {
+        container.setName(name);
+        for(IncludeTable table : includeTables) {
+            container.addIncludeTable(table.toIncludeTable());
+        }
+        for(PatternParam table : excludeTables) {
+            container.addExcludeTable(table.toExcludeTable());
+        }
+
+        for(PatternParam column : includeColumns) {
+            container.addIncludeColumn(column.toIncludeColumn());
+        }
+        for(PatternParam column : excludeColumns) {
+            container.addExcludeColumn(column.toExcludeColumn());
+        }
+
+        for(PatternParam procedure : includeProcedures) {
+            container.addIncludeProcedure(procedure.toIncludeProcedure());
+        }
+        for(PatternParam procedure : excludeProcedures) {
+            container.addExcludeProcedure(procedure.toExcludeProcedure());
+        }
+        return container;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/IncludeTable.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/IncludeTable.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/IncludeTable.java
new file mode 100644
index 0000000..137f0cd
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/IncludeTable.java
@@ -0,0 +1,78 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools.model;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+/**
+ * @since 4.0
+ */
+public class IncludeTable extends PatternParam {
+
+    private Collection<PatternParam> includeColumns = new LinkedList<>();
+    private Collection<PatternParam> excludeColumns = new LinkedList<>();
+
+    IncludeTable() {
+    }
+
+    IncludeTable(String pattern) {
+        super(pattern);
+    }
+
+    public void name(String name) {
+        setPattern(name);
+    }
+
+    public void includeColumn(String pattern) {
+        includeColumns.add(new PatternParam(pattern));
+    }
+
+    public void includeColumns(String... patterns) {
+        for(String pattern: patterns) {
+            includeColumn(pattern);
+        }
+    }
+
+    public void excludeColumn(String pattern) {
+        excludeColumns.add(new PatternParam(pattern));
+    }
+
+    public void excludeColumns(String... patterns) {
+        for(String pattern: patterns) {
+            excludeColumn(pattern);
+        }
+    }
+
+    org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable toIncludeTable() {
+        org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable table
+                = new org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable();
+        table.setPattern(getPattern());
+
+        for(PatternParam includeColumn : includeColumns) {
+            table.addIncludeColumn(includeColumn.toIncludeColumn());
+        }
+        for(PatternParam excludeColumn : excludeColumns) {
+            table.addExcludeColumn(excludeColumn.toExcludeColumn());
+        }
+
+        return table;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/PatternParam.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/PatternParam.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/PatternParam.java
new file mode 100644
index 0000000..d6f7dfb
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/PatternParam.java
@@ -0,0 +1,83 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools.model;
+
+import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn;
+import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure;
+import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable;
+import org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn;
+import org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure;
+
+/**
+ * @since 4.0
+ */
+public class PatternParam {
+
+    private String pattern;
+
+    PatternParam() {
+    }
+
+    PatternParam(String pattern) {
+        this.pattern = pattern;
+    }
+
+    public void pattern(String pattern) {
+        this.pattern = pattern;
+    }
+
+    ExcludeTable toExcludeTable() {
+        ExcludeTable table = new ExcludeTable();
+        table.setPattern(pattern);
+        return table;
+    }
+
+    IncludeColumn toIncludeColumn() {
+        IncludeColumn column = new IncludeColumn();
+        column.setPattern(pattern);
+        return column;
+    }
+
+    ExcludeColumn toExcludeColumn() {
+        ExcludeColumn column = new ExcludeColumn();
+        column.setPattern(pattern);
+        return column;
+    }
+
+    IncludeProcedure toIncludeProcedure() {
+        IncludeProcedure procedure = new IncludeProcedure();
+        procedure.setPattern(pattern);
+        return procedure;
+    }
+
+    ExcludeProcedure toExcludeProcedure() {
+        ExcludeProcedure procedure = new ExcludeProcedure();
+        procedure.setPattern(pattern);
+        return procedure;
+    }
+
+    public String getPattern() {
+        return pattern;
+    }
+
+    public void setPattern(String pattern) {
+        this.pattern = pattern;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/95f11997/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/SchemaContainer.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/SchemaContainer.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/SchemaContainer.java
new file mode 100644
index 0000000..1a1af16
--- /dev/null
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/model/SchemaContainer.java
@@ -0,0 +1,63 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools.model;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import groovy.lang.Closure;
+import org.apache.cayenne.dbsync.reverse.dbimport.Catalog;
+import org.apache.cayenne.dbsync.reverse.dbimport.Schema;
+import org.gradle.util.ConfigureUtil;
+
+/**
+ * @since 4.0
+ */
+public class SchemaContainer extends FilterContainer {
+
+    Collection<FilterContainer> schemas = new LinkedList<>();
+
+    SchemaContainer() {
+    }
+
+    SchemaContainer(String name) {
+        this.setName(name);
+    }
+
+    public void schema(String name) {
+        schemas.add(new FilterContainer(name));
+    }
+
+    public void schema(Closure<?> closure) {
+        schemas.add(ConfigureUtil.configure(closure, new FilterContainer()));
+    }
+
+    public void schema(String name, Closure<?> closure) {
+        schemas.add(ConfigureUtil.configure(closure, new FilterContainer(name)));
+    }
+
+    Catalog toCatalog() {
+        Catalog catalog = fillContainer(new Catalog());
+        for(FilterContainer container : schemas) {
+            catalog.addSchema(container.fillContainer(new Schema()));
+        }
+        return catalog;
+    }
+}
\ No newline at end of file


Mime
View raw message