buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Weil <marc.w...@oracle.com>
Subject Re: Calling ant task with classpath directly through Java
Date Wed, 20 Apr 2011 18:45:39 GMT
Ah yes, I ended up having to use antwrap to get this all working. I didn't realize that ant()
called inside a project block would return an AntTask for you. Perhaps some more documentation
in this area would be good... =)  There's only one example about this so far, and it's far
from exhaustive and is in the "Extending Buildr" section which seems odd.

Thanks for the hint!

Marc

On Apr 18, 2011, at 7:18 PM, Alex Boisvert wrote:

> Oh and I notice you're using Java.package.of.Task instead of using
> Antwrap... and I think it's easier to use Antwrap.
> 
> Take a look at the following wrapper tasks as examples,
> https://github.com/apache/buildr/blob/trunk/addon/buildr/hibernate.rb
> <https://github.com/apache/buildr/blob/trunk/addon/buildr/hibernate.rb>
> https://github.com/apache/buildr/blob/trunk/addon/buildr/openjpa.rb
> 
> <https://github.com/apache/buildr/blob/trunk/addon/buildr/openjpa.rb>alex
> 
> On Mon, Apr 18, 2011 at 4:10 PM, Alex Boisvert <alex.boisvert@gmail.com>wrote:
> 
>> Hi Marc,
>> 
>> I recommend you use the classpath element support of the StaticWeaveAntTask
>> (see example at the bottom of
>> http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/tools/weaving/jpa/StaticWeaveAntTask.html
>> ).
>> 
>> e.g.,
>> <target name="weaving" description="perform weaving."
>> depends="define.task">
>>  <weave source= "c:\foo.jar" target = "c:\wovenfoo.jar"
>> persistenceinfo="c:\foo-containing-persistenceinfo.jar">
>>    <classpath>
>>      <pathelement path="c:\foo-dependent.jar"/>
>>    </classpath>
>>  </weave>
>> </target>
>> 
>> alex
>> 
>> 
>> On Mon, Apr 18, 2011 at 2:48 PM, Marc Weil <marc.weil@oracle.com> wrote:
>> 
>>> Hi all,
>>> 
>>> I am trying to run JPA weaving (with Eclipselink) via Buildr but I'm
>>> having some problems getting it to recognize the classpath. I have defined a
>>> task as so:
>>> 
>>> task 'weave_code' do
>>>     ant_task =
>>> Java.org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask.new
>>>     ant_task.source = _(:target, :main, :classes)
>>>     ant_task.target = _(:target, :main, :classes)
>>>     ant_task.persistenceinfo = project('war').path_to('war')
>>>     ant_task.logLevel = "FINEST"
>>>     ant_task.execute
>>> end
>>> 
>>> The problem is that the Java classpath doesn't contain all the
>>> dependencies of the particular subproject where this task is both defined
>>> and invoked, and so I get a ton of ClassDefNotFound errors. I tried setting
>>> the classpath with the standard Java.classpath << STUFF; Java.load;
>>> mechanism, but Buildr vomits when I try to add all my projects and their
>>> dependencies to this list because it thinks I'm causing circular
>>> dependencies.
>>> 
>>> Initially I was hoping that since I was invoking it in my subproject as
>>> such:
>>> 
>>> compile.with ECLIPSELINK, COMMONS_LANG, JAVAX_PERSISTENCE, SLF4J_API,
>>> projects('common')
>>> compile { task('weave_code').invoke }
>>> 
>>> that the classpath generated by compile.with would carry over into the
>>> Java call. But apparently it doesn't work that way. Does anyone know a way
>>> around this or have any suggestions for how I might do this?
>>> 
>>> Thanks!
>>> Marc
>> 
>> 
>> 


Mime
View raw message