On 15 Mar 2015 at 16:52:34, trueb...@gmail.com (trueb...@gmail.com) wrote:
Is there a way to generate a service proxy (@ProxyGen) using gradle as your build tool? As far as I can see vertx-parent hooks into the maven lifecycle and executes the maven-compile-plugin to perform code generation. I don't see how this can work with gradle.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
//add a source set for generated classes
sourceSets {
generated {
java {
srcDirs = ['src/main/generated']
}
}
}
...
add [group: 'io.vertx', name: 'vertx-codegen', version: vertxVersion] to your compile dependencies
...
task generateServiceProxy(type: JavaCompile, description: 'Generates EBServiceProxies') {
source = sourceSets.main.java
classpath = configurations.compile
destinationDir = sourceSets.generated.java.srcDirs.iterator().next()
options.compilerArgs = [
"-proc:only",
"-processor", "io.vertx.codegen.CodeGenProcessor",
"-AoutputDirectory=$destinationDir"
]
}
compileJava {
source sourceSets.main.java + sourceSets.generated.java
}
compileJava.dependsOn generateServiceProxy
clean {
delete += sourceSets.generated.java.srcDirs
}@GenModule(name = "vertx-mongo")
package xxx.xxx.xxx.customer;
import io.vertx.codegen.annotations.GenModule;def generateSrcPath="$buildDir/generated-src"
def generatedSrcDir = file("$buildDir/generated-src")
sourceSets {
main {
java.srcDirs += generatedSrcDir
output.dir(builtBy: 'generateServiceProxy', generateSrcPath)
}
}
dependencies {
compile libraries.vertx
...
...
}
task generateServiceProxy(type: JavaCompile, description: 'Generates EBServiceProxies') {
source = sourceSets.main.java
classpath = configurations.compile
destinationDir = generatedSrcDir
options.compilerArgs = [
"-proc:only",
"-processor", "io.vertx.codegen.CodeGenProcessor",
"-AoutputDirectory=$generateSrcPath"
]
}
compileJava.dependsOn generateServiceProxy
Thanks a lot for posting the final solution, asked the same question a couple of weeks ago on IRC and I'll definitely need this at some point.
apply plugin: idea
apply plugin: eclipse