I'm new to Gradle, so I expect many things I did wrong in my build script, which is pasted below.What is special about that build script is, that it runs the EclipseLink metadata processor and copies the generated Entity_.java file to a folder in the sources directory.Are there ways to make my Gradle script, which works, more elegant?version '0.1'apply plugin: 'idea'apply plugin: 'java'repositories {    mavenCentral()}dependencies {    // http://mvnrepository.com/artifact/org.xerial/sqlite-jdbc    compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.8.11.2'    // http://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.jpa    compile group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.jpa', version: '2.6.3'    // http://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.jpa.modelgen.processor    compile group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.jpa.modelgen.processor', version: '2.6.3'    // http://mvnrepository.com/artifact/javax.mail/mail    compile group: 'javax.mail', name: 'mail', version: '1.4.7'}sourceSets {    main {        java {            srcDir 'src/gen/java'        }    }}task copyMetaModel(type: Copy) {    includeEmptyDirs = false    FileTree tree = fileTree(dir: build/classes/main)    tree.include **/*_.java    from tree    into src/gen/java}task cleanMetaModel(type: Delete) {    delete fileTree(dir: 'src/gen/java', exclude: '.keep')}compileJava.doFirst {    Map otherArgs = [            destdir: destinationDir,            includeAntRuntime: false,            source: sourceCompatibility,            target: targetCompatibility,            classpath: configurations.compile.asPath,            failonerror: true    ]    options.compilerArgs = [            -Aeclipselink.persistencexml=${new File(project.projectDir, 'src/main/resources/META-INF/persistence.xml').absolutePath}    ]    tasks.cleanMetaModel.execute()    Map antOptions = otherArgs + options.optionMap()    ant.javac(antOptions) {        source.addToAntBuilder(ant, 'src', FileCollection.AntType.MatchingTask)        options.compilerArgs.each {value ->            compilerarg(value: value)        }    }}compileJava.doLast {    tasks.copyMetaModel.execute()}
EclipseLink metadata generation with Gradle
gradle