I typically write something like,
task "run" do
Java::Commands.java "org.example.Main",
:classpath => [ compile.dependencies, compile.target ]
end
This has come up often enough in my buildfiles that I'm likely to
standardize it as a local task eventually.
alex
On Tue, Sep 21, 2010 at 8:33 AM, Antoine Toulme <antoine@lunar-ocean.com>wrote:
> Yes, we still don't have better support for transitive dependencies.
>
> Instead of doing a system call, you could potentially use the
> Java::Commands::java method, with a :classpath option to set the classpath.
>
> Antoine
>
> On Tue, Sep 21, 2010 at 08:16, David Yang <david.g.yang@gmail.com> wrote:
>
> >
> > I know this has been discussed here (
> >
> http://groups.google.com/group/buildr-talk/browse_thread/thread/9f3694f43f23a701
> > )
> >
> > But wanted to open up the issue again:
> >
> > I've spent the last few years doing Ruby so I'm not super-familiar with
> how
> > Java handles bundling dependencies (most of what I have seen is Maven's
> > system/local repos, haven't seen how ivy handles anything).
> >
> > I have a project that has several deps both in Maven repos and from sub
> > projects - the way I run the Main class right now is:
> >
> > define 'router' do
> > compile.with transitive(CAMEL, CAMEL_FTP, project('other-project'))
> > package(:jar).with
> > :manifest=>manifest.merge('Main-Class'=>'com.company.route.Route')
> >
> > task :run => :compile do
> > puts resources.target
> > deps = compile.dependencies + [compile.target] + [resources.target]
> > cp = deps.join(":")
> > puts cp
> > system "java -cp #{cp} com.company.route.Route"
> > end
> >
> >
> > Is this the right way to think about it?
> >
> > Also, if I bundle resources with other projects in jar files, or in this
> > project, how do I add those to the classpath as well?
> >
> > Sorry for the newbie questions - the above feels gross to me and I'm just
> > wondering if there's something obvious I'm missing.
> >
> > Thanks,
> > David
>
|