Hi Marcelo,
Taking your question literally you'll need to pass your compile
classpath to ant.javac. I'd like to lead you in a different direction,
though, as it would be far cleaner to have Gradle itself compile your
source. I'm assuming that anything in your domain package needs to be
compiled using this CtfExtensionProcessor. What about the remaining
source files? Do they require the output of CtfExtensionProcessor
before they can be compiled?
Cheers,
Merlyn
On Jul 23, 2011, at 1:59 PM, marcellodesales wrote:
Hello all,
I must say I'm hooked with Gradle and I was finally saved from the
XML hell
from ANT + Maven... :) 15 lines of code to generate a Jar, push the
library
to my internal nexus Maven repository... Impressed!!!! Thanks guys!!!!
Now I'm trying to migrate the following command-line shell command,
which
processes a given source code using the Java 6 annotation processor
facility
with the given processor, classpath, destination and input file...
Also, I'm
having trouble defining "doFirst" for a task that was imported from
an ANT
build.xml... It's just not working...
1. The processor problem...
javac -processor
com.collabnet.tf.annotation.extension.CtfExtensionProcessor
-classpath
/home/mdesales/.m2/repository/com/collabnet/tf/ctf-annotations/6.1-
SNAPSHOT/ctf-annotations-6.1-SNAPSHOT.jar:/home/mdesales/.m2/
repository/javax/persistence/persistence-api/1.0/persistence-
api-1.0.jar:/home/mdesales/.m2/repository/org/hibernate/hibernate-
annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar
-s /tmp /u1/SRC/ctf/src/main/java/com/collabnet/tf/UserPage.java
I'm struggling to to write a gradle script that does the same... I
have
visited the maven and java plugin documentation pages, as well as
different
blog posts, but I haven't found anything related... The route I
decided to
take was to use the ant "javac" tag and try to run it from there...
-----------------------------------------------------
ant.importBuild 'build.xml'
apply plugin: 'maven'
repositories {
mavenCentral()
mavenRepo urls:
"http://localhost:8081/nexus/content/repositories/snapshot", userName:
"admin", password: "welcome"
}
task processAnnotations(description: "Generates new classes") << {
dependencies {
compileClasspath
'com.collabnet.teamforge:teamforge-annotations:6.1.1.jpa-SNAPSHOT'
compileClasspath 'javax.persistence:persistence-api:1.0'
compileClasspath 'org.hibernate:hibernate-annotations:
3.3.1.GA'
}
ant.javac(destdir: "/tmp") {
src(path: "${ant.properties.BUILD_SRC}/src/main/java")
include(name: "**/domain/*")
compilerarg(value: "-processor")
compilerarg(value:
"com.collabnet.tf.annotation.extension.CtfExtensionProcessor")
}
}
generate.doFirst {
println "Will generate everything"
}
------------------------------------
Here's the error I keep getting... Is this script correct? Is there
a way to
define such dependencies? Considering I'm importing an ANT
build.xml, I just
don't want to change the "compile" task from that build.xml and use
a local
dependency here to just solve my problem of processing Java
annotations...
mdesales@xyz src]$ gradle gFC
:generateFildsClasses
FAILURE: Build failed with an exception.
* Where:
Build file '/u1/SRC/ctf/apps/collabnet-core/saturn/build.gradle'
line: 13
* What went wrong:
Execution failed for task ':generateFildsClasses'.
Cause: No signature of method:
org
.gradle
.api
.internal
.artifacts
.dsl.dependencies.DefaultDependencyHandler.compileClasspath()
is applicable for argument types: (java.lang.String) values:
[com.collabnet.teamforge:teamforge-annotations:6.1.1.jpa-SNAPSHOT]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info
or
--debug option to get more log output.
2. The doFirst defined above does not run... the task "generate" is
imported
from the build.xml imported... It just does not run... Any ideas????
Thanks all
Marcello
--
View this message in context:
http://gradle.1045684.n5.nabble.com/Javac-Java-Annotation-Processor-Maven-classpath-dependencies-in-Gradle-tp4626751p4626751.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email