Skip to content

Commit

Permalink
Add a DbSetup-kotlin module
Browse files Browse the repository at this point in the history
Switch to latest gradle version
  • Loading branch information
jnizet committed May 30, 2016
1 parent 20e7b44 commit 610a499
Show file tree
Hide file tree
Showing 63 changed files with 673 additions and 257 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

/.project
/.gradle
/.settings
/bin
/build
build/
/.classpath
/.classpath.idea/
/.java-version
DbSetup.iml
*.iml
.idea
out
classes
81 changes: 81 additions & 0 deletions DbSetup-core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
apply plugin : 'pmd'
apply plugin : 'findbugs'
apply plugin : 'jacoco'

description = 'Helps you setup your database with test data'

check.dependsOn tasks.getByName("jacocoTestReport")

dependencies {
compile 'com.google.code.findbugs:jsr305:2.0.0'
compile 'net.sourceforge.findbugs:annotations:1.3.2'
testCompile 'junit:junit:4.+'
testCompile 'org.mockito:mockito-all:1.9.0'
testCompile 'org.hsqldb:hsqldb:2.3.3'
}

configurations {
compile.transitive = false
testCompile.transitive = false
runtime.transitive = false
testRuntime.transitive = false
}

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

pmd {
sourceSets = [sourceSets.main]
}

pmdMain {
ignoreFailures = true
ruleSetFiles = files('config/pmd/ruleset.xml')
}

findbugs {
sourceSets = [sourceSets.main]
ignoreFailures = true
}

findbugsMain {
reports {
xml {
enabled = false
}
html {
enabled = true
}
}
}

jar {
manifest {
instruction 'Bundle-Vendor', 'ninja-squad.com'
instructionReplace 'Export-Package',
'com.ninja_squad.dbsetup',
'com.ninja_squad.dbsetup.bind',
'com.ninja_squad.dbsetup.destination',
'com.ninja_squad.dbsetup.generator',
'com.ninja_squad.dbsetup.operation'
instruction 'Import-Package', '!javax.annotation.*', '*'
}
}

javadoc {
options.overview file('src/main/java/com/ninja_squad/dbsetup/overview.html').path
options.noTimestamp true
options.linkSource true
options.addBooleanOption('Xdoclint:all,-missing', true)
}

def configurePomDependencies(pom) {
// we don't care about test dependencies
pom.dependencies = pom.dependencies.findAll {it.scope != 'test'}
// we don't care about findbugs annotations
pom.dependencies = pom.dependencies.findAll {it.groupId != 'net.sourceforge.findbugs' && it.artifactId != 'annotations'}
// we don't care about JSR305 annotations
pom.dependencies = pom.dependencies.findAll {it.groupId != 'com.google.code.findbugs' && it.artifactId != 'jsr305'}
// all dependencies are compile time dependencies, and there is no need to say it
pom.dependencies*.scope = null
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

<module name="MissingDeprecated">
</module>

<module name="MissingOverride">
</module>

<module name="PackageAnnotation">
</module>

<!-- See http:https://checkstyle.sf.net/config_blocks.html -->
<!-- Checks for empty blocks. -->
<!-- <property name="option" value="stmt"/> -->
Expand All @@ -35,9 +35,9 @@
</module>
<module name="EmptyBlock">
<property name="tokens" value="LITERAL_CATCH"/>
<property name="option" value="text"/>
<property name="option" value="text"/>
</module>

<!-- See http:https://checkstyle.sf.net/config_blocks.html -->
<!--
Checks for the placement of left curly braces ('{') for code
Expand Down Expand Up @@ -87,7 +87,7 @@
<!-- <property name="allowInSwitchCase" value="false"/> -->
<module name="AvoidNestedBlocks">
</module>

<!-- See http:https://checkstyle.sf.net/config_design.html -->
<!-- Checks visibility of class members. -->
<!-- <property name="packageAllowed" value="false"/> -->
Expand Down Expand Up @@ -148,7 +148,7 @@
<!-- Detects empty statements (standalone ;). -->
<module name="EmptyStatement">
</module>

<module name="EqualsAvoidNull">
</module>

Expand Down Expand Up @@ -274,11 +274,11 @@
value="java.lang.Exception, java.lang.Throwable,
java.lang.RuntimeException"/>
-->
<!-- Disabled because already checked by PMD
<!-- Disabled because already checked by PMD
<module name="IllegalCatch">
</module>
-->

<module name="IllegalThrows">
</module>

Expand Down Expand Up @@ -356,7 +356,7 @@
<!-- Checks for the use of unnecessary parentheses. -->
<module name="UnnecessaryParentheses">
</module>

<!-- See http:https://checkstyle.sf.net/config_import.html -->
<!--
Checks that there are no import statements that use the *
Expand All @@ -368,7 +368,7 @@

<module name="AvoidStaticImport">
</module>

<!-- See http:https://checkstyle.sf.net/config_import.html -->
<!-- Checks for imports from a set of illegal packages. -->
<!-- <property name="illegalPkgs" value="sun"/> -->
Expand All @@ -385,7 +385,7 @@
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>

<!-- See http:https://checkstyle.sf.net/config_javadoc.html#JavadocType -->
<!-- Checks Javadoc comments for class and interface definitions. -->
<!-- <property name="scope" value="private"/> -->
Expand All @@ -395,7 +395,7 @@
<!-- <property name="tokens" value="INTERFACE_DEF, CLASS_DEF"/> -->
<module name="JavadocType">
</module>

<!-- module name="JavadocMethod">
</module -->

Expand All @@ -404,7 +404,7 @@

<!-- module name="JavadocStyle">
</module -->

<!-- See http:https://checkstyle.sf.net/config_misc.html -->
<!--
Checks that long constants are defined with an upper ell.
Expand All @@ -418,7 +418,7 @@
<!-- <property name="javaStyle" value="true"/> -->
<module name="ArrayTypeStyle">
</module>

<!-- See http:https://checkstyle.sf.net/config_misc.html -->
<!-- Checks correct indentation of Java Code. -->
<!-- <property name="basicOffset" value="4"/> -->
Expand All @@ -441,7 +441,7 @@
<!-- <property name="tokens" value="METHOD_DEF, VARIABLE_DEF"/> -->
<module name="RedundantModifier">
</module>

<!-- See http:https://checkstyle.sf.net/config_naming.html -->
<!-- Checks for Naming Conventions. -->
<!-- <property name="format" value="^Abstract.*$|^.*Factory$"/> -->
Expand Down Expand Up @@ -527,10 +527,10 @@

<module name="OuterTypeNumber">
</module>

<module name="GenericWhitespace">
</module>

<!-- See http:https://checkstyle.sf.net/config_whitespace.html -->
<!--
Checks the padding between the identifier of a method
Expand Down Expand Up @@ -611,17 +611,17 @@
SR_ASSIGN, STAR, STAR_ASSIGN"/>
</module>
</module>

<!-- See http:https://checkstyle.sf.net/config_whitespace.html -->
<!--
Checks that there are no tab characters ('\t') in the source
code.
-->
<module name="FileTabCharacter">
</module>

<module name="Header">
<property name="headerFile" value="config/checkstyle/java.header"/>
<property name="headerFile" value="${headerFile}"/>
<property name="ignoreLines" value="4"/>
<property name="fileExtensions" value="java"/>
</module>
Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions DbSetup-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.2"
}
}

apply plugin: 'kotlin'

description = 'Kotlin extensions for DbSetup'

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.2"
compile project(':DbSetup')
testCompile 'junit:junit:4.11'
}

checkstyleMain {
source sourceSets.main.kotlin
}

def configurePomDependencies(pom) {
// we don't care about test dependencies
pom.dependencies = pom.dependencies.findAll {it.scope != 'test'}
// all dependencies are compile time dependencies, and there is no need to say it
pom.dependencies*.scope = null
}

15 changes: 15 additions & 0 deletions DbSetup-kotlin/config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>

<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.1//EN"
"http:https://www.puppycrawl.com/dtds/configuration_1_1.dtd">

<module name="Checker">
<property name="severity" value="warning"/>

<module name="Header">
<property name="headerFile" value="${headerFile}"/>
<property name="ignoreLines" value="4"/>
<property name="fileExtensions" value="kt"/>
</module>
</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* The MIT License
*
* Copyright (c) 2016, Ninja Squad
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.ninja_squad.dbsetup_kotlin

import com.ninja_squad.dbsetup.DbSetup
import com.ninja_squad.dbsetup.DbSetupTracker

/**
* Extension function of DbSetup allowing to launch it with a tracker. This allows launching the setup in an easier way:
* instead of doing
*
* ```
* val theSetup = dbSetup {
* ...
* }
* tracker.launchIfNecessary(theSetup)
* ```
*
* you can simply do
*
* ```
* dbSetup {
* ...
* }.launchWith(tracker)
* ```
*
* @author JB Nizet
*/
fun DbSetup.launchWith(tracker: DbSetupTracker) {
tracker.launchIfNecessary(this)
}
Loading

0 comments on commit 610a499

Please sign in to comment.