読者です 読者をやめる 読者になる 読者になる

Eclipseでdoma2を使うためのGradleの設定

Version

  • Spring Boot - 1.3.2.RELEASE
  • doma-spring-boot - 1.0.1

Gradleのビルドスクリプト

EclipseのAPT処理を有効にして、doma2によるAPT処理ができるようにbuild.gradleで設定します。

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.2.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'eclipse'

processResources.destinationDir = compileJava.destinationDir
compileJava.dependsOn processResources
compileJava.options.compilerArgs = ['-Adoma.dao.subpackage=impl', '-Adoma.dao.suffix=Impl']

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

eclipse {
    jdt {
        file {
            withProperties {properties ->
                properties.setProperty('org.eclipse.jdt.core.compiler.processAnnotations', 'enabled')
            }
        }
    }
}

eclipseJdt {
    doFirst {
        def factorypath = file('.factorypath')
        def writer = new FileWriter(factorypath)
        def xml = new groovy.xml.MarkupBuilder(writer)
        xml.setDoubleQuotes(true)
        xml.'factorypath'() {
            def domaJar = configurations.compile.find {
                it.name.startsWith('doma-2')
            }
            'factorypathentry'(kind: 'EXTJAR', id: domaJar, enabled: true, runInBatchMode: false)
        }
    }
}

repositories {
    mavenCentral()
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
    compile 'org.seasar.doma.boot:doma-spring-boot-starter:1.0.1'

    compile 'org.xerial:sqlite-jdbc:3.8.11.2'
    
    testCompile 'junit:junit'
    testCompile 'org.springframework.boot:spring-boot-starter-test'
}

https://github.com/takesection/spring-boot-doma2-eclipse