Quantcast

How to use the ClassPath from Ant

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to use the ClassPath from Ant

Andrey1981
Hello,

I'm thinking to use BeanShell for Java scripting...

Is it possible to use ClassPath generated by Ant?

I have some Java project in NetBeans that uses JPA and I would like to use BeanShell as scripting shell to process data from database. NetBeans generates Ant's build.xml, so if BeanShell could use it - it will be great! :)


Thanks in advance,

-Andrey





-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use the ClassPath from Ant

Wade Chandler-6
--- Andrey Siver <[hidden email]> wrote:

> Hello,
>
> I'm thinking to use BeanShell for Java scripting...
>
> Is it possible to use ClassPath generated by Ant?
>
> I have some Java project in NetBeans that uses JPA and I would like to use
> BeanShell as scripting shell to process data from database. NetBeans
> generates Ant's build.xml, so if BeanShell could use it - it will be great!
> :)
>
>

I have used BeanShell in Ant scripts to be able to use more features and do more things...even to
update properties after they have been set once. What exactly are you hoping to do? Ant has an
entire API, and you can use the API from your BeanShell scripts. Once you have Ant configured
with Apache BSF and have BeanShell installed in Ant it is as simple as using script tasks and
setting the appropriate language. Then it is just a matter of using the API. This more for using
BeanShell directly in the Ant script and to help with the build process etc.

Also, you can have Ant build your NB project. Then you can have another target which uses the
build artifacts. This would be fairly simple to do. The regular NB project build.xml will build
your project, and you have another target or override one in your NB project (see the comments in
the NB build.xml file for targets to define and when they run...there is one you can define in
build.xml which the NB build scripts will run after the jars are built). You can then setup a
classpath which includes other classpaths and use the java task to call BeanShell directly or use
the script task directly in Ant 1.7 (Ant 1.7 allows one to set the classpath to use when calling
the script tag...thus passing a different classpath to the script engine).

I would start off playing around with Ant and figuring out how to run a script and how you
actually want your process to work. i.e. build the NB project, run another target, then you will
run a separate bsh script in the BeanShell by having Ant run it or you will use Ant and the
script tag and embed your bsh script directly in your Ant script file. So, first just figure out
what path you want to travel or how you want this to exactly work, then figure out how to build a
classpath in Ant to call a script (need to install the optional JARs for the script task in
Ant...bsf,beanshell,ant specific bsf extensions), java class, or use the execute task.

If you can build a classpath and then pass the reference in and make Ant call a java class using
the java task you can do this with ease. Then from there have it run BeanShell however you figure
is the best way for you. Once you can build and pass a classpath you can make what ever Java
class you run use what ever classes you choose.

Wade


==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use the ClassPath from Ant

Andrey1981
Hello Wade,

Thank you for the answer.

I need to process a data from database and I see two ways: 1) Use Java only; 2) Use BeanShell with my JPA-classes (the way is like described here http://ideoplex.com/id/487/hibernate-prototyping-with-the-beanshell ).

I use NB. It creates necessary build.xml for building the project. The idea is to use this build.xml, especially the full classpath, in my *.bsh and question is: how to make access to my JPA-classes easily.

I use NB-modules http://ikayzo.org/confluence/display/BSH/Netbeans+and+Beanshell for BeanShell and as I could understand they do not provide access to the project classpath.

2008/4/29 Wade Chandler <[hidden email]>:

... 



==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use the ClassPath from Ant

Andrey1981
Dear Wade,

Of course, all those variants are interesting :).
But as I see, the most important one - is the possibility to use project class path from Ant build.xml (so it will be the possibility to use corresponding *.bsh outside the NB)...


Regards,

-Andrey

2008/4/30 Wade Chandler <[hidden email]>:
--- Andrey Siver <[hidden email]> wrote:
> Hello Wade,
>
> Thank you for the answer.
>
> I need to process a data from database and I see two ways: 1) Use Java only;
> 2) Use BeanShell with my JPA-classes (the way is like described here
> http://ideoplex.com/id/487/hibernate-prototyping-with-the-beanshell ).
>
> I use NB. It creates necessary build.xml for building the project. The idea
> is to use this build.xml, especially the full classpath, in my *.bsh and
> question is: how to make access to my JPA-classes easily.
>
> I use NB-modules
> http://ikayzo.org/confluence/display/BSH/Netbeans+and+Beanshell for
> BeanShell and as I could understand they do not provide access to the
> project classpath.
>

It depends really. Are you wanting to do this from NetBeans while running a BeanShell script
where the BeanShell is actually part of NB running inside the JVM or are you wanting to do this
from Ant when your Ant script is run, and does this only need to happen when it is run from NB or
also from the command line (both when the build is run from NB and the command line)?

Wade



==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Loading...