shivan42 / CodeGenUnderStorIO

Codegen for StorIO entity classes to wotk with SQLite
11 stars 3 forks source link

Gradle plugin #4

Open ZakTaccardi opened 8 years ago

ZakTaccardi commented 8 years ago

This should be a gradle plugin!

shivan42 commented 8 years ago

May be... If you see this project as gradle plugin and have a time to create this plugin, my project is open for improvements !

nayeemzen commented 7 years ago

Simple gradle task to generate sql entities in the build folder and add them to the classpath.

All your sql files go in src/main/sql CodeGenUnderStorIO.jar is in app/codegen

def sqlPath = 'src/main/sql'
def sqlGeneratedPath = 'build/generated/source/sql/'
android {
    sourceSets {
        main.java.srcDirs += sqlGeneratedPath
    }
}
task generateStorIOEntities {
    description = 'Generate sqlite tables and storio entities'
    fileTree(dir: sqlPath, include: '**/*.sql').each { File file ->
        doLast {
            javaexec {
                main = "-jar";
                classpath = buildscript.configurations.classpath
                args = ["codegen/CodeGenUnderStorIO.jar", "${file}", "com.sendkoin.sql", "${sqlGeneratedPath}"]
            }
        }
    }
}

preBuild.dependsOn generateStorIOEntities