You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by "Robert J. Carr" <rj...@gmail.com> on 2008/05/19 22:40:44 UTC

using derby with ant's sql task

I'm using an embedded derby database in my application.  There is an
initialization that requires some table updates and I'd like to have
these done in ant using the <sql> task.

The problem I'm having is setting the 'derby.system.home' system
property.  Unlike the <java> task, the <sql> task doesn't take the
nested <sysproperty> property.

I'm sure it could be done with environment variables but I'd like to
avoid doing this if possible.

Are there any solutions others have used?  I'm not aware of a way to
have ant set a system property outside of the <java> task.

The kludge I've come up with is, since I was already using groovy for
something else, I embedded a line of groovy to set
'derby.system.home'.  Thankfully the <sql> task isn't forked so the
property persists.  But I do feel this is a kludge and would like to
know a better way, if possible.

Thanks!

Re: using derby with ant's sql task

Posted by "Robert J. Carr" <rj...@gmail.com>.
Thaks for the suggestion Rick.  I was mostly writing as a sanity check
as it seems there must be a better / different way.  I'm not sure how
much better a custom task is compared to a bit of embedded groovy, but
thanks for the suggestion (and sanity check!).

On Mon, May 19, 2008 at 2:08 PM, Rick Hillegas <Ri...@sun.com> wrote:
> Hi Robert,
>
> You might be able to get what you want by writing a custom ant Task, i.e., a
> class which extends org.apache.tools.ant.Task. If you need some examples of
> how to do this, you can grep the Derby source tree for "PropertySetter" or
> "MessageBuilder".
>
> Hope this is useful,
> -Rick
>
> Robert J. Carr wrote:
>>
>> I'm using an embedded derby database in my application.  There is an
>> initialization that requires some table updates and I'd like to have
>> these done in ant using the <sql> task.
>>
>> The problem I'm having is setting the 'derby.system.home' system
>> property.  Unlike the <java> task, the <sql> task doesn't take the
>> nested <sysproperty> property.
>>
>> I'm sure it could be done with environment variables but I'd like to
>> avoid doing this if possible.
>>
>> Are there any solutions others have used?  I'm not aware of a way to
>> have ant set a system property outside of the <java> task.
>>
>> The kludge I've come up with is, since I was already using groovy for
>> something else, I embedded a line of groovy to set
>> 'derby.system.home'.  Thankfully the <sql> task isn't forked so the
>> property persists.  But I do feel this is a kludge and would like to
>> know a better way, if possible.
>>
>> Thanks!
>>
>
>

Re: using derby with ant's sql task

Posted by Rick Hillegas <Ri...@Sun.COM>.
Hi Robert,

You might be able to get what you want by writing a custom ant Task, 
i.e., a class which extends org.apache.tools.ant.Task. If you need some 
examples of how to do this, you can grep the Derby source tree for 
"PropertySetter" or "MessageBuilder".

Hope this is useful,
-Rick

Robert J. Carr wrote:
> I'm using an embedded derby database in my application.  There is an
> initialization that requires some table updates and I'd like to have
> these done in ant using the <sql> task.
>
> The problem I'm having is setting the 'derby.system.home' system
> property.  Unlike the <java> task, the <sql> task doesn't take the
> nested <sysproperty> property.
>
> I'm sure it could be done with environment variables but I'd like to
> avoid doing this if possible.
>
> Are there any solutions others have used?  I'm not aware of a way to
> have ant set a system property outside of the <java> task.
>
> The kludge I've come up with is, since I was already using groovy for
> something else, I embedded a line of groovy to set
> 'derby.system.home'.  Thankfully the <sql> task isn't forked so the
> property persists.  But I do feel this is a kludge and would like to
> know a better way, if possible.
>
> Thanks!
>