Domaを見る

さて、DomaでDBの内容に基づいて

classを自動生成しましたので内容をみます。

f:id:itfune:20161108174520p:plain

dao下にクラス(インタフェース)が出来ています。

でも、.aptのところが空っぽです。

ここにインタフェースの実体が出来る予定だったのですが

なにかが足りないようです。

たぶんgradleファイルなので見直して更新します。

 

(2016-11-12)

なにごとも先達はあらまほしきものかな

こちら

http://masatoshitada.hatenadiary.jp/entry/2014/12/03/214712

のサイトなどを参考にさせていただいて、

build.gradleを以下の形式にするとインタフェースの実態も作成されます。

Groovyの勉強をしたら以下のbuild.gradleを見直したいと思います。

 

 

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'

sourceCompatibility = 1.8
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart',
                   'Implementation-Version': version
    }
}

configurations {
    domaGenRuntime
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

test {
    systemProperties 'property': 'value'
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

eclipse {
    wtp {
        component {
            contextPath = '/Sample'
        }
    }
}

dependencies {
    domaGenRuntime 'org.seasar.doma:doma-gen:2.0.1'
    domaGenRuntime 'org.postgresql:postgresql:9.4-1206-jdbc41'
    compile 'org.seasar.doma:doma:2.0.1'
    compile 'org.seasar.doma:doma-gen:2.0.1'
    compile 'org.postgresql:postgresql:9.4-1206-jdbc41'
}

task gen << {
    ant.taskdef(resource: 'domagentask.properties',
        classpath: configurations.domaGenRuntime.asPath)
    ant.gen(url: 'jdbc:postgresql://localhost/smpl', user: 'postgres', password: 'password') {
        entityConfig(packageName: 'jp.co.smpl.entity')
        daoConfig(packageName: 'jp.co.smpl.dao', configClassName: 'jp.co.smpl.AppConfig')
        sqlConfig()
    }
}

ext { aptDir='.apt_generated' }

eclipse {
    jdt.file.withProperties { it['org.eclipse.jdt.core.compiler.processAnnotations'] = 'enabled' }
    classpath {
        containers = ['org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8']
    }
}

eclipseJdt {
    def clos = []
    def fp = file('.factorypath')
    outputs.file fp
    clos += {
        fp.withWriter {
            def domaJar = configurations.compile.find {
                it.name.startsWith('doma-2')
            }
            new groovy.xml.MarkupBuilder(it).factorypath() {
                factorypathentry(kind:'EXTJAR', id:domaJar, enabled:true, runInBatchMode:false)
            }
        }
    }

    def prefs = { name, contents ->
        def f = file(".settings/$name")
        clos += {
            f.text = contents.stripMargin()
        }
        outputs.file f
    }

    prefs 'org.eclipse.jdt.apt.core.prefs', """\
    |eclipse.preferences.version=1
    |org.eclipse.jdt.apt.aptEnabled=true
    |org.eclipse.jdt.apt.genSrcDir=${aptDir}
    |org.eclipse.jdt.apt.reconcileEnabled=true
    |"""
    doLast { clos*.run() }
}