Hi,
How can I make downloading a file a prerequisite of a subsequent task--
for example, I want to download a zip file (from github) and subsequently
unzip it:
-- snip
file 'myProg.zip'
desc 'fetch'
task :fetch => 'myProg.zip' do
name = 'myProg'
url = 'https://github.com/user/myProg/archive/master.zip
<https://github.com/dominik-bln/CERMINE/archive/master.zip>'
CurbFetch::fetch name, url #
fetches and unzips
FileUtils.mv 'myProg-master', name # moves to
name
FileUtils.rm_rf 'myProg-master'
end
directory 'myProg' => :fetch
desc 'build'
task :build => 'myProg' do
Dir.chdir 'myProg'
# change into dir
system( 'mvn compile assembly:single' ) # run maven
end
-- snip
But this doesn't work as I intended, as
$ rake build
always causes the fetch task to be run. What am I doing wrong?
Thanks, Joe
Hi Joe,
Have you tried using a file task on file creation task? I believe one of
those should do what you want...
···
On 05/04/2015 10:48:43, Joe Gain wrote:
Hi,
How can I make downloading a file a prerequisite of a subsequent task--
for example, I want to download a zip file (from github) and subsequently
unzip it:
-- snip
file 'myProg.zip'
desc 'fetch'
task :fetch => 'myProg.zip' do
name = 'myProg'
url = 'https://github.com/user/myProg/archive/master.zip
<https://github.com/dominik-bln/CERMINE/archive/master.zip>'
CurbFetch::fetch name, url #
fetches and unzips
FileUtils.mv 'myProg-master', name # moves to
name
FileUtils.rm_rf 'myProg-master'
end
directory 'myProg' => :fetch
desc 'build'
task :build => 'myProg' do
Dir.chdir 'myProg'
# change into dir
system( 'mvn compile assembly:single' ) # run maven
end
-- snip
But this doesn't work as I intended, as
$ rake build
always causes the fetch task to be run. What am I doing wrong?
Thanks, Joe
--
Raj Sahae
408.230.8531
Sorry, "on" => "or"
file task OR file creation task
···
On 05/04/2015 02:05:49, Raj Sahae wrote:
Hi Joe,
Have you tried using a file task on file creation task? I believe one of
those should do what you want...
Class: Rake::FileTask (Ruby 2.2.2)
Class: Rake::FileCreationTask (Ruby 2.2.2)
On 05/04/2015 10:48:43, Joe Gain wrote:
> Hi,
>
> How can I make downloading a file a prerequisite of a subsequent task--
> for example, I want to download a zip file (from github) and subsequently
> unzip it:
>
> -- snip
>
> file 'myProg.zip'
>
> desc 'fetch'
> task :fetch => 'myProg.zip' do
> name = 'myProg'
> url = 'https://github.com/user/myProg/archive/master.zip
> <https://github.com/dominik-bln/CERMINE/archive/master.zip>'
> CurbFetch::fetch name, url #
> fetches and unzips
> FileUtils.mv 'myProg-master', name # moves to
> name
> FileUtils.rm_rf 'myProg-master'
> end
>
> directory 'myProg' => :fetch
>
> desc 'build'
> task :build => 'myProg' do
> Dir.chdir 'myProg'
> # change into dir
> system( 'mvn compile assembly:single' ) # run maven
> end
>
> -- snip
>
> But this doesn't work as I intended, as
>
> $ rake build
>
> always causes the fetch task to be run. What am I doing wrong?
>
> Thanks, Joe
--
Raj Sahae
408.230.8531
--
Raj Sahae
408.230.8531
Ugh, double sorry. Super tired and didn't read your code snippet
correctly.
Maybe try replacing your existing file task with a file creation task?
That way if the file exists at all, the task shouldn't be run.
···
On 05/04/2015 02:07:52, Raj Sahae wrote:
Sorry, "on" => "or"
file task OR file creation task
On 05/04/2015 02:05:49, Raj Sahae wrote:
> Hi Joe,
>
> Have you tried using a file task on file creation task? I believe one of
> those should do what you want...
>
> Class: Rake::FileTask (Ruby 2.2.2)
> Class: Rake::FileCreationTask (Ruby 2.2.2)
>
>
> On 05/04/2015 10:48:43, Joe Gain wrote:
> > Hi,
> >
> > How can I make downloading a file a prerequisite of a subsequent task--
> > for example, I want to download a zip file (from github) and subsequently
> > unzip it:
> >
> > -- snip
> >
> > file 'myProg.zip'
> >
> > desc 'fetch'
> > task :fetch => 'myProg.zip' do
> > name = 'myProg'
> > url = 'https://github.com/user/myProg/archive/master.zip
> > <https://github.com/dominik-bln/CERMINE/archive/master.zip>'
> > CurbFetch::fetch name, url #
> > fetches and unzips
> > FileUtils.mv 'myProg-master', name # moves to
> > name
> > FileUtils.rm_rf 'myProg-master'
> > end
> >
> > directory 'myProg' => :fetch
> >
> > desc 'build'
> > task :build => 'myProg' do
> > Dir.chdir 'myProg'
> > # change into dir
> > system( 'mvn compile assembly:single' ) # run maven
> > end
> >
> > -- snip
> >
> > But this doesn't work as I intended, as
> >
> > $ rake build
> >
> > always causes the fetch task to be run. What am I doing wrong?
> >
> > Thanks, Joe
>
> --
> Raj Sahae
> 408.230.8531
--
Raj Sahae
408.230.8531
--
Raj Sahae
408.230.8531
Ugh, double sorry. Super tired and didn't read your code snippet
correctly.
Maybe try replacing your existing file task with a file creation task?
That way if the file exists at all, the task shouldn't be run.
Thanks Raj,
I was looking at the task from the wrong perspective:
file 'myProg.zip' do
url = 'https://github.com/dominik-bln/CERMINE/archive/master.zip'
CurbFetch::fetch 'myProg', url
end
directory 'myProg' => 'myProg.zip' do
FileUtils.mv 'CERMINE-master', 'myProg'
FileUtils.rm_rf 'CERMINE-master'
end
desc 'build myProg'
task :build => 'myProg' do
Dir.chdir 'myProg'
system( 'mvn compile assembly:single' )
end
···
On Mon, May 4, 2015 at 11:12 AM, Raj Sahae <rajsahae@gmail.com> wrote:
On 05/04/2015 02:07:52, Raj Sahae wrote:
> Sorry, "on" => "or"
>
> file task OR file creation task
>
> On 05/04/2015 02:05:49, Raj Sahae wrote:
> > Hi Joe,
> >
> > Have you tried using a file task on file creation task? I believe one
of
> > those should do what you want...
> >
> > Class: Rake::FileTask (Ruby 2.2.2)
> >
Class: Rake::FileCreationTask (Ruby 2.2.2)
> >
> >
> > On 05/04/2015 10:48:43, Joe Gain wrote:
> > > Hi,
> > >
> > > How can I make downloading a file a prerequisite of a subsequent
task--
> > > for example, I want to download a zip file (from github) and
subsequently
> > > unzip it:
> > >
> > > -- snip
> > >
> > > file 'myProg.zip'
> > >
> > > desc 'fetch'
> > > task :fetch => 'myProg.zip' do
> > > name = 'myProg'
> > > url = 'https://github.com/user/myProg/archive/master.zip
> > > <https://github.com/dominik-bln/CERMINE/archive/master.zip>'
> > > CurbFetch::fetch name, url #
> > > fetches and unzips
> > > FileUtils.mv 'myProg-master', name #
moves to
> > > name
> > > FileUtils.rm_rf 'myProg-master'
> > > end
> > >
> > > directory 'myProg' => :fetch
> > >
> > > desc 'build'
> > > task :build => 'myProg' do
> > > Dir.chdir 'myProg'
> > > # change into dir
> > > system( 'mvn compile assembly:single' ) # run
maven
> > > end
> > >
> > > -- snip
> > >
> > > But this doesn't work as I intended, as
> > >
> > > $ rake build
> > >
> > > always causes the fetch task to be run. What am I doing wrong?
> > >
> > > Thanks, Joe
> >
> > --
> > Raj Sahae
> > 408.230.8531
>
> --
> Raj Sahae
> 408.230.8531
--
Raj Sahae
408.230.8531
--
joe gain
jacob-burckhardt-str. 16
78464 konstanz
germany
+49 (0)7531 60389
(...otherwise in ???)