Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 73 lines (61 sloc) 2.428 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
import org.apache.tools.ant.filters.ReplaceTokens

apply plugin: 'java'

dependencies {
    shrinkwrapVersion = '1.0.0-alpha-6'

    compile( project(':hibernate-core') )
    compile( libraries.dom4j )
    compile( libraries.commons_annotations )
    compile( libraries.jpa )
    compile( libraries.jta )
    compile( libraries.javassist )
    testCompile( project(':hibernate-testing') )
    testCompile( libraries.junit )
    testCompile( libraries.shrinkwrap_api )
    testCompile( libraries.shrinkwrap )
    testCompile( libraries.validation )
    testRuntime( libraries.validator )
}

aptDumpDir = file( buildDirName + "/temp/apt" )

sourceSets.test {
    originalJavaSrcDirs = java.srcDirs
    generatedJpaMetamodelSrcDir = file( "${buildDir}/generated-src/jpamodelgen/${name}" )
    java.srcDir generatedJpaMetamodelSrcDir
}

task generateJpaMetamodelClasses(type: Compile) {
    classpath = compileTestJava.classpath + configurations.hibernateJpaModelGenTool
    source = sourceSets.test.originalJavaSrcDirs
    destinationDir = aptDumpDir
    options.define(
            compilerArgs: [
                    "-proc:only",
                    "-processor", "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor",
                    "-s", "$sourceSets.test.generatedJpaMetamodelSrcDir.absolutePath"
            ]
    );
    outputs.dir sourceSets.test.generatedJpaMetamodelSrcDir;
    doFirst {
        sourceSets.test.generatedJpaMetamodelSrcDir.mkdirs()
    }
}

// for the time being eat the annoying output from running the annotation processors
generateJpaMetamodelClasses.logging.captureStandardError(LogLevel.INFO)

compileTestJava.dependsOn generateJpaMetamodelClasses
compileTestJava.options.define(compilerArgs: ["-proc:none"])


bundlesTargetDir = file( "$buildDirName/bundles" )
task copyBundleResources (type: Copy) {
    from file('src/test/bundles')
    into bundlesTargetDir
    filter(ReplaceTokens, tokens: [
            buildDirName: buildDir.absolutePath,
            'db.dialect': 'org.hibernate.dialect.H2Dialect',
            'jdbc.driver': 'org.h2.Driver',
            'jdbc.user': 'sa',
            'jdbc.pass': '',
            'jdbc.url': 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE',
    ]);
    doFirst {
        bundlesTargetDir.mkdirs()
    }
}

// make sure that the bundles for the packaged test (PackagingTestCase) are copied as well
processTestResources.dependsOn copyBundleResources
Something went wrong with that request. Please try again.