You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by David Yang <da...@gmail.com> on 2010/09/21 17:16:54 UTC

Running projects after compile/build

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

Re: Running projects after compile/build

Posted by Antoine Toulme <an...@lunar-ocean.com>.
Can you file an enhancement request for this and assign it to Alex for 1.4.3
? It's a good addition imo.

On Tue, Sep 21, 2010 at 09:47, David Yang <da...@gmail.com> wrote:

>
> Awesome, thanks for this.  If a dev would expain why this isn't a buildr
> default task like buildr run similar to Maven's exec:java (sic) I'd be
> interested in understanding this area of buildr better.
>
> On Sep 21, 2010, at 12:43 PM, Alex Boisvert wrote:
>
> > 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 <da...@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
> >>
>
>

Re: Running projects after compile/build

Posted by David Yang <da...@gmail.com>.
Thanks for the explanation - really enjoy using Buildr so far and it's
a nice way for us Ruby people to get back into Java without facing all
the usual traumas of dependency management.

I've created the feature request here:
https://issues.apache.org/jira/browse/BUILDR-514

David

On Tue, Sep 21, 2010 at 1:03 PM, Alex Boisvert <al...@gmail.com> wrote:
> On Tue, Sep 21, 2010 at 9:47 AM, David Yang <da...@gmail.com> wrote:
>
>>
>> Awesome, thanks for this.  If a dev would expain why this isn't a buildr
>> default task like buildr run similar to Maven's exec:java (sic) I'd be
>> interested in understanding this area of buildr better.
>>
>
> There's no good reason other than we haven't gotten to it yet.   For me it
> was just easy to write task "run" do ... end so I've never bothered to
> standardize it.
>
> BTW, I usually accompany it with:
>
> Project.local_task 'run'
>
> such that if I'm in the directory, then it picks the project's local run
> task.
>
> alex
>

Re: Running projects after compile/build

Posted by Alex Boisvert <al...@gmail.com>.
On Tue, Sep 21, 2010 at 9:47 AM, David Yang <da...@gmail.com> wrote:

>
> Awesome, thanks for this.  If a dev would expain why this isn't a buildr
> default task like buildr run similar to Maven's exec:java (sic) I'd be
> interested in understanding this area of buildr better.
>

There's no good reason other than we haven't gotten to it yet.   For me it
was just easy to write task "run" do ... end so I've never bothered to
standardize it.

BTW, I usually accompany it with:

Project.local_task 'run'

such that if I'm in the directory, then it picks the project's local run
task.

alex

Re: Running projects after compile/build

Posted by David Yang <da...@gmail.com>.
Awesome, thanks for this.  If a dev would expain why this isn't a buildr default task like buildr run similar to Maven's exec:java (sic) I'd be interested in understanding this area of buildr better.

On Sep 21, 2010, at 12:43 PM, Alex Boisvert wrote:

> 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 <an...@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 <da...@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
>> 


Re: Running projects after compile/build

Posted by Alex Boisvert <al...@gmail.com>.
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 <an...@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 <da...@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
>

Re: Running projects after compile/build

Posted by Antoine Toulme <an...@lunar-ocean.com>.
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 <da...@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

Running projects after compile/build

Posted by David Yang <da...@gmail.com>.
> 
> 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