Hi Rene,
Apologies for not getting back to you sooner on this, but I have tried
what you said and it still does work. My compiler adapter jar is not
being added to the classpath in the right way.
I am trying something slightly different now. Since it looks like the
JavaPlugin uses ant under the covers, I am now setting the
build.compiler property through the command line:
gradlew -Dbuild.compiler=org.foo.MyCompilerAdapter compileJava
And using the following script (the compiler adapter jar is now
installed in my local maven repo
====
buildscript {
repositories {
flatDir name: 'local repo', dirs:'/Users/andrew/.m2/repository'
}
dependencies {
classpath "org.foo:my-compiler-adapter:0....@jar"
}
}
apply plugin: 'java'
====
When I execute the script, I get the following class not found exception:
...
* What went wrong:
Execution failed for task ':compileJava'.
Cause: Class not found: org.foo.MyCompilerAdapter
==========
What this is saying to me is that:
1. The JavaPlugin is triggering a java compiler through ant.
2. The -Dbuild.compiler property on the command line is correctly
causing the underlying ant execution to look for the compiler adapter.
3. The compiler adapter jar is being found in the maven repo
(otherwise I would have gotten a dependency exception).
4. But, the compiler adapter is still not on the ant classpath.
I have tried all sorts of variations of the script above (including
editing the gradlew script), but I can't seem to get the last piece
working. Do you have any further ideas on how to get this working?
I am starting to think that this is a bug. At the very least, the
documentation could be clearer on how to get this working. Should I
raise a bug for this? I can attach the sample project and add the
compiler adapter to a publicly available maven repo.
Thanks. I appreciate your help.
--a
On Mon, Aug 16, 2010 at 11:33 AM, Rene Groeschke <[email protected]> wrote:
> Hi Andrew,
> Could you try to add this buildscript closure to your build file:
>
> buildscript {
> dependencies {
> classpath files('/Users/andrew/libs/my-compiler-adapter.jar')
> }
> }
>
> This should add the jar to the classpath of of the running gradle build
> itself.
>
> regards,
> René
>
>
>
> Am 16.08.10 17:54, schrieb Andrew Eisenberg:
>>
>> Thanks for your reply, Magnus. However, I am still not able to get the
>> working.
>>
>> * What went wrong:
>> Execution failed for task ':compile'.
>> Cause: Could not find method asPath() for arguments [] on
>> configuration ':antcompile'.
>>
>>
>> On Mon, Aug 16, 2010 at 12:47 AM, Magnus Rundberget
>> <[email protected]> wrote:
>>
>>>
>>> Hi,
>>> You need to add the dependencies manually to the ant tasks classpath.
>>> Short sample that should work:
>>> // custom dependency configuration
>>> configurations {
>>> antcompile
>>> }
>>> dependencies {
>>> antcompile files('/Users/andrew/libs/my-compiler-adapter.jar')
>>> }
>>> task compile<< {
>>> ant.javac(srcdir: '.', verbose: true,
>>> compiler:'org.foo.bar.MyCompilerAdapter',
>>> classpath:configurations.antcompile.asPath()) {
>>> include(name: '**/*.java')
>>> include(name: '**/*.groovy')
>>> }
>>> }
>>>
>>> cheers
>>> Magnus
>>>
>>>
>>>
>>>>
>>>> Date: Sun, 15 Aug 2010 20:53:14 -0700
>>>> From: [email protected]
>>>> To: [email protected]
>>>> Subject: [gradle-user] how to add a jar file to gradle's AntBuilder
>>>>
>>>> Hi all,
>>>>
>>>> I am trying to execute an ant javac call inside of a gradle task.
>>>> However, I am trying to execute with a custom CompilerAdapter, using
>>>> the compiler attribute (this allows me to run the javac task with my
>>>> own compiler implementation). In order to do this, I need to add an
>>>> extra jar to ant's classpath. Here is the current build.gradle that I
>>>> have, but it is not working:
>>>>
>>>>
>>>> dependencies {
>>>> files('/Users/andrew/libs/my-compiler-adapter.jar')
>>>> }
>>>>
>>>> task compile<< {
>>>> ant.javac(srcdir: '.', verbose: true, compiler:
>>>> 'org.foo.bar.MyCompilerAdapter') {
>>>> include(name: '**/*.java')
>>>> include(name: '**/*.groovy')
>>>> }
>>>> }
>>>>
>>>> The script is failing with the message:
>>>>
>>>> Execution failed for task ':compile'.
>>>> Cause: Class not found: org.foo.bar.MyCompilerAdapter
>>>>
>>>> It looks like the file in the dependencies section is not being added
>>>> to the ant classpath. (As a side note, this is working when I run the
>>>> related script directly in ant.) Any ideas on how to fix this script?
>>>>
>>>> Much appreciated.
>>>>
>>>> --andrew
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>
>>
>>
>
>
> --
> ------------------------------------
> Rene Groeschke
>
> [email protected]
> http://www.breskeby.com
> http://twitter.com/breskeby
> ------------------------------------
>
>
> ---------------------------------------------------------------------
> 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