Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

marcellodesales
This post was updated on .
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/teamforge/teamforge-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/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
Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

Merlyn Albery-Speyer
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


Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

marcellodesales
Hi Marlyn,

>> Taking your question literally you'll need to pass your compile classpath to ant.javac.

Wouldn't there be any magical Maven dependency way to do that? I could use the user's .m2 cache path, but I wanted gradle/maven to take care of it for me... :)
 
>> 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.

In a way, yes... The only thing the compiler will do is to compile+analyze domain classes and look for the ones annotated with @Entity (JPA)... That will result in the generation of other java source code, which will NOT be compiled them at that time... Only code generation...
 
>> What about the remaining source files? Do they require the output of CtfExtensionProcessor before
>> they can be compiled?

This step is a just one of my "initial passes" before the full source-code is compiled altogether... So, yes, the remaining (whole other components) depend on the source code generated by the processor in order to get a successful compilation... The only problem at the moment is that we have a highly customized "compile" task on the imported build.xml that I can't change at the moment (but I will push a complete migration to Gradle in a near future :D)...

I started off just doing "cmd".execute() and it worked without a problem, but since there are dozens of classes to be analyzed, I need to get the list of classes and the dependency taken care of using Gradle (in case new dependencies or changes occur)...

Thanks Merlyn... Please share any solution you can think of... It took me the entire night and this morning and I can't find anything :(
Marcello
Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

Merlyn Albery-Speyer
Hi Marcello,

I'm not at a computer where I can try this out. What jumps out at me is:
* define an additional sourceset that has the same src dir of src/main/
java, except with an include for the domain path, something like:
sourceSets { jpa { srcDir "src/main/java" ; includes ... } }
* configure the jpaCompile task to pass the jvm arguments you need,  
something like: jpaCompile { jvmarg '-processor' ; .... }
* add a configuration as a home for the CtfExtensionProcessor  
dependencies: configurations { ctf }
* add it's dependencies dependencies { ctf 'org.hibernate:hibernate-
annotations:3.3.1.GA' ; .... }
* supply the dependencies to the jpaCompile task, something like:  
jpaCompile { classpath += configurations.ctf.asPath ; ... }

Hopefully that will see you on the right track.

Cheers,
Merlyn

On Jul 23, 2011, at 4:22 PM, marcellodesales wrote:

> Hi Marlyn,
>
>>> Taking your question literally you'll need to pass your compile  
>>> classpath
>>> to ant.javac.
>
> Wouldn't there be any magical Maven dependency way to do that? I  
> could use
> the user's .m2 cache path, but I wanted gradle/maven to take care of  
> it for
> me... :)
>
>>> 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.
>
> In a way, yes... The only thing the compiler will do is to compile
> +analyze
> domain classes and look for the ones annotated with @Entity (JPA)...  
> That
> will result in the generation of other java source code, which will  
> NOT be
> compiled them at that time... Only code generation...
>
>>> What about the remaining source files? Do they require the output of
>>> CtfExtensionProcessor before
>>> they can be compiled?
>
> This step is a just one of my "initial passes" before the full  
> source-code
> is compiled altogether... So, yes, the remaining (whole other  
> components)
> depend on the source code generated by the processor in order to get a
> successful compilation... The only problem at the moment is that we  
> have a
> highly customized "compile" task on the imported build.xml that I  
> can't
> change at the moment (but I will push a complete migration to Gradle  
> in a
> near future :D)...
>
> I started off just doing "cmd".execute() and it worked without a  
> problem,
> but since there are dozens of classes to be analyzed, I need to get  
> the list
> of classes and the dependency taken care of using Gradle (in case new
> dependencies or changes occur)...
>
> Thanks Merlyn... Please share any solution you can think of... It  
> took me
> the entire night and this morning and I can't find anything :(
> Marcello
>
> --
> View this message in context: http://gradle.1045684.n5.nabble.com/Javac-Java-Annotation-Processor-Maven-classpath-dependencies-in-Gradle-tp4626751p4627001.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


Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

marcellodesales
Hi Merlyn,

I guess I might be close to get this done :D I hope... I'm getting the error "Cause: Could not find method jpa() for arguments [build_1p49ceo95d1og4v8njdbovf6g0$_run_closure4_closure7@9e4585] on root project 'saturn'." I have defined the sourceSets as you described... I tried removing the ";", using "include", "includes", and I even tried adding "java" as an the parent of "srcDir"... Do I have to define "jpa" somewhere? As I found in the documentation: "To define a new source set, you simply reference it in the sourceSets { } block. When you define a source set, the Java plugin adds a number of tasks which assemble the classes for the source set, as shown in Table 20.2, “Java plugin - source set tasks”. For example, if you add a source set called intTest, the Java plugin adds compileIntTestJava, processIntTestResources and intTestClasses tasks."

Is there something missing in the documentation? Anything wrong?

Attempts

sourceSets {
    jpa {
        java {
            srcDir '/u1/SRC/ctf/apps/collabnet-core/tsunami/core/src/main/java';
            includes '**/domain/*'
        }
    }
}

sourceSets {
    jpa {
        srcDir '/u1/SRC/ctf/apps/collabnet-core/tsunami/core/src/main/java';
        includes '**/domain/*'
    }
}

Here's the entire code... I removed the import of my ANT script that I was importing to get this done first independently...

build.gradle


apply plugin: 'java'

repositories {
    mavenCentral()
    mavenRepo urls: "http://cu134.cloud.sp.collab.net:8081/nexus/content/repositories/collabnet-snapshot", userName: "admin", password: "welcome"
}

configurations {
    annotations
}

dependencies {
    annotations 'com.collabnet.teamforge:teamforge-annotations:6.1.1.jpa-SNAPSHOT'
    annotations 'javax.persistence:persistence-api:1.0'
    annotations 'org.hibernate:hibernate-annotations:3.3.1.GA'
}

sourceSets {
    jpa {
        srcDir '/u1/SRC/ctf/apps/collabnet-core/tsunami/core/src/main/java';
        includes '**/domain/*'
    }
}

jpaCompile {
    jvmarg '-processor'
    jvmarg 'com.collabnet.tf.annotation.extension.CtfExtensionProcessor'
    jvmarg '-s'
    jvmarg '/tmp'
    classpath += configurations.annotations.asPath
}

Runtime error


[mdesales@cu096 ctf]$ gradle jC

FAILURE: Build failed with an exception.

* Where:
Build file '/u1/SRC/ctf/build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'saturn'.
Cause: Could not find method jpa() for arguments [build_1p49ceo95d1og4v8njdbovf6g0$_run_closure4_closure6@7aa187] on root project 'saturn'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.34 secs
Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

marcellodesales
After a few more attempts, I passed from the sourceSets block... The only way I could get it working was by adding the "main" block before the "jpa" one... So, I went to the annotations project where I first used the sourceSets and added the jpa block... Guess what? It worked over there... But, the interesting part of the name of the jpa task for compiling... "compileJpaJava"... So, I guess it follows the convention of the block "compileBLOCKNAMEJava"...

[mdesales@cu096 saturn]$ vim tools/annotations/build.gradle
[mdesales@cu096 saturn]$ cd tools/annotations/
[mdesales@cu096 annotations]$ gradle jpa
:compileJpaJava UP-TO-DATE
:processJpaResources UP-TO-DATE
:jpaClasses UP-TO-DATE

I have added the following to the source code I posted before...

sourceSets {
    main {
        java {
            //srcDir 'src'
            //exclude "**/osgi/*"
        }
    }
    jpa {
        java {
            srcDir '/u1/SRC/ctf/apps/collabnet-core/tsunami/core/src/main/java'
            include '**/domain/*'
        }
    }
}

New problem: jvmArgs not working


Still can't compile script... I have tried multiple "jvmArg", "jvmArgs"...  

compileJpaJava {
    jvmArgs ['-processor', 'com.collabnet.tf.annotation.extension.CtfExtensionProcessor', '-s', '/tmp']
    classpath += configurations.annotations.asPath
}

Runtime error


[mdesales@cu096 saturn]$ gradle tasks

FAILURE: Build failed with an exception.

* Where:
Build file '/u1/SRC/ctf/build.gradle' line: 37

* What went wrong:
A problem occurred evaluating root project 'saturn'.
Cause: Could not find property 'jvmArgs' on task ':compileJpaJava'.

Thanks and I appreciate any help...

Marcello
Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

Merlyn Albery-Speyer
Marcello,

I was wrong about compile.jvmarg, you add them via  
compile.options.compilerArg. See the Gradle DSL documentation for  
compile:

http://www.gradle.org/releases/1.0-milestone-3/docs/dsl/org.gradle.api.tasks.compile.Compile.html

Hope that helps,
Merlyn

On Jul 24, 2011, at 2:17 PM, marcellodesales wrote:

> After a few more attempts, I passed from the sourceSets block... The  
> only way
> I could get it working was by adding the "main" block before the "jpa"
> one... So, I went to the annotations project where I first used the
> sourceSets and added the jpa block... Guess what? It worked over  
> there...
> But, the interesting part of the name of the jpa task for compiling...
> "compileJpaJava"... So, I guess it follows the convention of the block
> "compileBLOCKNAMEJava"...
>
> [mdesales@cu096 saturn]$ vim tools/annotations/build.gradle
> [mdesales@cu096 saturn]$ cd tools/annotations/
> [mdesales@cu096 annotations]$ gradle jpa
> :compileJpaJava UP-TO-DATE
> :processJpaResources UP-TO-DATE
> :jpaClasses UP-TO-DATE
>
> I have added the following to the source code I posted before...
>
> sourceSets {
>    main {
>        java {
>            //srcDir 'src'
>            //exclude "**/osgi/*"
>        }
>    }
>    jpa {
>        java {
>            srcDir
> '/u1/SRC/ctf/apps/collabnet-core/tsunami/core/src/main/java'
>            include '**/domain/*'
>        }
>    }
> }
>
> New problem: jvmArgs not working
>
>
> Still can't compile script... I have tried multiple "jvmArg",  
> "jvmArgs"...
>
> compileJpaJava {
>    jvmArgs ['-processor',
> 'com.collabnet.tf.annotation.extension.CtfExtensionProcessor', '-s',  
> '/tmp']
>    classpath += configurations.annotations.asPath
> }
>
> Runtime error
>
>
> [mdesales@cu096 saturn]$ gradle tasks
>
> FAILURE: Build failed with an exception.
>
> * Where:
> Build file '/u1/SRC/ctf/build.gradle' line: 37
>
> * What went wrong:
> A problem occurred evaluating root project 'saturn'.
> Cause: Could not find property 'jvmArgs' on task ':compileJpaJava'.
>
> Thanks and I appreciate any help...
>
> Marcello
>
> --
> View this message in context: http://gradle.1045684.n5.nabble.com/Javac-Java-Annotation-Processor-Maven-classpath-dependencies-in-Gradle-tp4626751p4628814.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


Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

marcellodesales
Hey Merlyn,

Just to keep it documented, I got it working!!! Man, Gradle is awesome! thanks a lot for your help... Here's the complete code for processing Java 6 Annotations with Javac compiler flags + dependencies expressed in Maven... Is this a bug?

// The definition of "jpa" sourceSet WILL ONLY WORK IF the "main" is defined... is this Gradle bug?

apply plugin: 'java'

repositories {
    mavenCentral()
    mavenRepo urls: "http://localhost:8081/nexus/content/repositories/snapshot", userName: "admin", password: "welcome"
}

configurations {
    annotations
}

dependencies {
    annotations 'com.myapi:myapi:1.0-SNAPSHOT'
    annotations 'javax.persistence:persistence-api:1.0'
    annotations 'javax:javaee-api:6.0'
    annotations 'org.hibernate:hibernate-annotations:3.3.1.GA'
}

// the following definition of "jpa" source code directory will only work if the "main" is defined... is this a Gradle bug?
sourceSets {
    main {
        java {
            //srcDir 'src'
            //exclude "**/osgi/*"
        }
    }
    jpa {
        java {
            srcDir '/development/src/main/java'
            include '**/domain/*'
        }
    }
}

compileJpaJava {
    options.compilerArgs = ["-processor", "com.myapi.CtfExtensionProcessor",
        "-ActfBuildDir=/development/build/src/java",
        "-ActfFieldsPackage=com.myapi.fields"]
    classpath += configurations.annotations
}

Hope this helps others in the future!
Marcello
Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

Szczepan Faber
>// The definition of "jpa" sourceSet WILL ONLY WORK IF the "main" is
defined... is this Gradle bug?

What do you mean by "main defined" and what doesn't work if "main is
not defined"? :)

Cheers!

On Tue, Jul 26, 2011 at 2:37 AM, marcellodesales
<[hidden email]> wrote:

> Hey Merlyn,
>
> Just to keep it documented, I got it working!!! Man, Gradle is awesome!
> thanks a lot for your help... Here's the complete code for processing Java 6
> Annotations with Javac compiler flags + dependencies expressed in Maven...
> Is this a bug?
>
> // The definition of "jpa" sourceSet WILL ONLY WORK IF the "main" is
> defined... is this Gradle bug?
>
> apply plugin: 'java'
>
> repositories {
>    mavenCentral()
>    mavenRepo urls:
> "http://localhost:8081/nexus/content/repositories/snapshot", userName:
> "admin", password: "welcome"
> }
>
> configurations {
>    annotations
> }
>
> dependencies {
>    annotations 'com.myapi:myapi:1.0-SNAPSHOT'
>    annotations 'javax.persistence:persistence-api:1.0'
>    annotations 'javax:javaee-api:6.0'
>    annotations 'org.hibernate:hibernate-annotations:3.3.1.GA'
> }
>
> // the following definition of "jpa" source code directory will only work if
> the "main" is defined... is this a Gradle bug?
> sourceSets {
>    main {
>        java {
>            //srcDir 'src'
>            //exclude "**/osgi/*"
>        }
>    }
>    jpa {
>        java {
>            srcDir '/development/src/main/java'
>            include '**/domain/*'
>        }
>    }
> }
>
> compileJpaJava {
>    options.compilerArgs = ["-processor", "com.myapi.CtfExtensionProcessor",
>        "-ActfBuildDir=/development/build/src/java",
>        "-ActfFieldsPackage=com.myapi.fields"]
>    classpath += configurations.annotations
> }
>
> Hope this helps others in the future!
> Marcello
>
> --
> View this message in context: http://gradle.1045684.n5.nabble.com/Javac-Java-Annotation-Processor-Maven-classpath-dependencies-in-Gradle-tp4626751p4633029.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
>
>
>



--
Szczepan Faber
Principal engineer@gradleware
Lead@mockito

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

marcellodesales
Hi Szczepan,

I have to take it back... I think there was something wrong in the previous code that led me to this conclusion while I was trying to create my first compile code in Gradle while Merlyn was just giving directions :D... I just deleted the "main" block, and the code compiled without a problem!!! :) See below...

sourceSets {
    jpa {
        java {
            srcDir '/development/src/main/java'
            include '**/domain/*'
        }
    }
}

So, the code is beautiful... After understanding and getting the idea of Gradle and comparing with an ANT build.xml or a MAVEN pom.xml, Gradle is magical... I was in love with Grails GANT, but this is awesome!

I have a feedback for the dev/docs team... please provide as many examples as possible in the documentation for the tasks... Or open the documentation for user's contributed examples known to be working in the current or previous revisions... I understand the product is still M3, but it would help us (community) a lot to learn and adopt...  :D  Maybe to the level, or better one, when compared to the Apache ANT documentation... Each task has lots of examples related to the task...

I'm pushing Gradle to be the replacement for an OLD, VERY OLD build system built on top of (ANT + Python - Maven)... A nightmare to extend and add dependencies... I love the tight integration with Maven + Ivy, and how easy it is once you get the idea... Getting a complete sub-project in a Jar and Maven: 2 minutes of copy and paste? Change the dependencies list? I have already created 3 build.gradle for 3 different projects, adjusted the sourceSets with where the source directory is located (yes, code written even without the Maven src structure)... I don't even feel like sleeping anymore :P

thanks a lot!!!
Marcello
Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

Szczepan Faber
>please provide as many examples
as possible in the documentation for the tasks

We'll try :) What tasks did you miss examples most? Where do learn
about tasks, from the user guide or the DSL reference?

Cheers!

On Tue, Jul 26, 2011 at 11:18 AM, marcellodesales
<[hidden email]> wrote:

> Hi Szczepan,
>
> I have to take it back... I think there was something wrong in the previous
> code that led me to this conclusion while I was trying to create my first
> compile code in Gradle while Merlyn was just giving directions :D... I just
> deleted the "main" block, and the code compiled without a problem!!! :) See
> below...
>
> sourceSets {
>    jpa {
>        java {
>            srcDir '/development/src/main/java'
>            include '**/domain/*'
>        }
>    }
> }
>
> So, the code is beautiful... After understanding and getting the idea of
> Gradle and comparing with an ANT build.xml or a MAVEN pom.xml, Gradle is
> magical... I was in love with Grails GANT, but this is awesome!
>
> I have a feedback for the dev/docs team... please provide as many examples
> as possible in the documentation for the tasks... Or open the documentation
> for user's contributed examples known to be working in the current or
> previous revisions... I understand the product is still M3, but it would
> help us (community) a lot to learn and adopt...  :D  Maybe to the level, or
> better one, when compared to the Apache ANT documentation... Each task has
> lots of examples related to the task...
>
> I'm pushing Gradle to be the replacement for an OLD, VERY OLD build system
> built on top of (ANT + Python - Maven)... A nightmare to extend and add
> dependencies... I love the tight integration with Maven + Ivy, and how easy
> it is once you get the idea... Getting a complete sub-project in a Jar and
> Maven: 2 minutes of copy and paste? Change the dependencies list? I have
> already created 3 build.gradle for 3 different projects, adjusted the
> sourceSets with where the source directory is located (yes, code written
> even without the Maven src structure)... I don't even feel like sleeping
> anymore :P
>
> thanks a lot!!!
> Marcello
>
> --
> View this message in context: http://gradle.1045684.n5.nabble.com/Javac-Java-Annotation-Processor-Maven-classpath-dependencies-in-Gradle-tp4626751p4634174.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
>
>
>



--
Szczepan Faber
Principal engineer@gradleware
Lead@mockito

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Javac + Java Annotation Processor + Maven classpath dependencies in Gradle...

marcellodesales
Szczepan Faber wrote
We'll try :) What tasks did you miss examples most? Where do learn
about tasks, from the user guide or the DSL reference?
From the tutorial and each individual documentation, we can get the idea of the DSLs... But the concept of extensions of those concepts are still vague... I couldn't imagine we can get a bound configuration and reuse it in other tasks like in this option...

Maybe an "Advanced" topic about Gradle extensibility... So, the place to learn about the complete details should be, in my opinion, in the DSL references... Usually we read the user guide with "default" directions and descriptions... Conversely, ALL the details and options about a given task should be explored in the DSL reference, with examples where users could copy and paste... For instance, the ANT documentation gave me that power in the past to copy code snippets and build on top of other code based on given examples: http://ant.apache.org/manual/Tasks/jar.html has different examples about the Jar task well detailed for different scenarios... Maybe we could have the same level of details in the DLS reference... Not only the description, but the different uses of the options and how to get them together with others (As in Gradle we extend default tasks, etc)...

thanks
Marcello