You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Jean-Philippe Caruana <jp...@target2sell.com> on 2014/10/30 15:16:42 UTC

scala build

Hi,

I want to package a scala project as a tgz. In the generated tgz, the
scala-compiler-2.10.4.jar is included : it is heavy (14M) and unnecessary.

I try to remove it, but it doesn't work :

  generated_lib = package(:jar).exclude '*.properties*'
  livrable = package :tgz
  livrable.path('lib').include generated_lib, compile.dependencies
  livrable.path('lib').exclude 'scala-compiler-2.10.4.jar'


I added a (always failing) check:

  check livrable, "doesn't need the very heavy (14M) scala-compiler.jar " do
    it.should_not contain('lib/scala-compiler-2.10.4.jar')
  end


I also tried
  generated_lib = package(:jar).exclude '*.properties*'
  livrable = package :tgz
  livrable.path('lib').include generated_lib, (compile.dependencies -
'org.scala-lang:scala-compiler:jar:2.10.4')

How can I do ?

-- 
Jean-Philippe Caruana 
http://www.barreverte.fr


Re: scala build

Posted by Jean-Philippe Caruana <jp...@target2sell.com>.
Thanks ! It works like a charm.

Le 04/11/2014 10:05, Peter Donald a écrit :
> Hi,
>
> On Mon, Nov 3, 2014 at 8:51 PM, Jean-Philippe Caruana <jp...@target2sell.com>
> wrote:
>
>> But it still doesn't work:
>> Expected ./target/querySimulator-1.0.0-SNAPSHOT.tgz to not contain
>> 'lib/scala-compiler-2.10.4.jar'
>> Buildr aborted!
>> RuntimeError : Checks failed for project querySimulator (see errors above).
>>
> Ok - so now I see what the problem is. The dependencies list includes a
> string dependency that identifies a file and it is this one you want to
> exclude. If so you could probably replace "compile.dependencies" with
> "compile.dependencies.select
> {|a| !(a.to_s =~/scala-compiler-2.10.4.jar$/)}".  That would remove the one
> dependency that when converted to a string matched the filename.
>
> Hope that helps.
>

-- 
Jean-Philippe Caruana 
http://www.barreverte.fr


Re: scala build

Posted by Peter Donald <pe...@realityforge.org>.
Hi,

On Mon, Nov 3, 2014 at 8:51 PM, Jean-Philippe Caruana <jp...@target2sell.com>
wrote:

> But it still doesn't work:
> Expected ./target/querySimulator-1.0.0-SNAPSHOT.tgz to not contain
> 'lib/scala-compiler-2.10.4.jar'
> Buildr aborted!
> RuntimeError : Checks failed for project querySimulator (see errors above).
>

Ok - so now I see what the problem is. The dependencies list includes a
string dependency that identifies a file and it is this one you want to
exclude. If so you could probably replace "compile.dependencies" with
"compile.dependencies.select
{|a| !(a.to_s =~/scala-compiler-2.10.4.jar$/)}".  That would remove the one
dependency that when converted to a string matched the filename.

Hope that helps.

-- 
Cheers,

Peter Donald

Re: scala build

Posted by Jean-Philippe Caruana <jp...@target2sell.com>.
Hi,

yes, you're correct, I am using a local file dependency:
$ cat build.yml
scala.version: 2.10.4

SOrry for wasting your time with too few information.

But it still doesn't work:
Expected ./target/querySimulator-1.0.0-SNAPSHOT.tgz to not contain
'lib/scala-compiler-2.10.4.jar'
Buildr aborted!
RuntimeError : Checks failed for project querySimulator (see errors above).

What stikes me is I used to remove scala-compiler years ago in a project
now dead in a company I left since. I kept the buildfile and this
worked, back in 2011:

    lib_generee = package(:jar).exclude('.scala-deps')
    livrable = package :tgz
    livrable.include _('src/main/batch')
    livrable.path('batch/lib').include
compile.dependencies.exclude('scala-compiler.jar'), lib_generee

$ cat build.yaml
junit: 4.8.2
scala.version: 2.8.1
scala.check: 1.7
scala.test: 1.2


How come this doesn't work anymore ?
What am i doing wrong ?


Thanks.

Le 31/10/2014 23:01, Peter Donald a écrit :
> Hi,
>
> It looks like you are using a local/file dependency which I did not account
> for. So what you need to do is add the prefix like
> "!a.respond_to?(:to_spec) || " in your select block. I have updated the
> example [1] to demonstrate this.
>
> HTH
>
> [1]
> https://github.com/realityforge/buildr-examples/commit/2649848058d9213e8be928148686685d57ffb566

-- 
Jean-Philippe Caruana
http://www.barreverte.fr


Re: scala build

Posted by Peter Donald <pe...@realityforge.org>.
Hi,

It looks like you are using a local/file dependency which I did not account
for. So what you need to do is add the prefix like
"!a.respond_to?(:to_spec) || " in your select block. I have updated the
example [1] to demonstrate this.

HTH

[1]
https://github.com/realityforge/buildr-examples/commit/2649848058d9213e8be928148686685d57ffb566

On Fri, Oct 31, 2014 at 7:43 PM, Jean-Philippe Caruana <jp...@target2sell.com>
wrote:

> Hi Peter,
>
> thank you for your answer.
> I tried the solution you gave, but it doesn't compile :
>
> $ buildr --version
> Buildr 1.4.20
>
> $ buildr package
> (in /home/jp/src/t2s/performance-tests/querySimulator, development)
> sh: 2: Syntax error: EOF in backquote substitution
> Buildr aborted!
> NoMethodError : undefined method `to_spec' for #<String:0x0000000397c6a8>
> /home/jp/src/t2s/performance-tests/querySimulator/buildfile:46:in `block
> (3 levels) in <top (required)>'
> /home/jp/src/t2s/performance-tests/querySimulator/buildfile:46:in `block
> (2 levels) in <top (required)>'
> /home/jp/src/t2s/performance-tests/querySimulator/buildfile:45:in `tap'
> /home/jp/src/t2s/performance-tests/querySimulator/buildfile:45:in `block
> in <top (required)>'
>
> /var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:426:in
> `raw_load_buildfile'
>
> /var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:225:in
> `block in load_buildfile'
>
> /var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:220:in
> `load_buildfile'
> (See full trace by running task with --trace)
>
>
> my buildfile looks like this :
>
>   package(:jar)
>   package(:tgz).tap do |pkg|
>     pkg.path('lib').include package(:jar), compile.dependencies.select
> {|a| a.to_spec != 'org.scala-lang:scala-compiler:jar:2.10.4'}
>     pkg.path('etc').include _('src/main/resources')
>     pkg.path('bin').include _('src/main/bin')
>   end
>
>
> I also tried it like this :
>
>   generated_lib = package(:jar).exclude '*.properties*'
>   livrable = package :tgz
>   livrable.path('lib').include generated_lib,
> compile.dependencies.select { |a| a.to_spec !=
> 'org.scala-lang:scala-compiler:jar:2.10.4' }
>   livrable.path('lib').exclude 'scala-compiler-2.10.4.jar'
>
>   livrable.include _('src/main/resources'), :as => 'etc'
>   livrable.include _('src/main/bin'), :as => 'bin'
>
> But got a similar error:
> Buildr aborted!
> NoMethodError : undefined method `to_spec' for #<String:0x0000000308d600>
> /home/jp/src/t2s/performance-tests/querySimulator/buildfile:45:in `block
> (2 levels) in <top (required)>'
> /home/jp/src/t2s/performance-tests/querySimulator/buildfile:45:in `block
> in <top (required)>'
>
> /var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:426:in
> `raw_load_buildfile'
>
> /var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:225:in
> `block in load_buildfile'
>
> /var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:220:in
> `load_buildfile'
>
>
> Thanks
>
> Le 30/10/2014 23:24, Peter Donald a écrit :
> > Hi,
> >
> > The easiest way to do this is probably replace
> >
> > compile.dependencies
> >
> > with
> >
> > compile.dependencies.select {|a| a.to_spec != 'org.scala-lang:scala-
> > compiler:jar:2.10.4'}
> >
> > I put together an example of this at
> >
> >
> https://github.com/realityforge/buildr-examples/tree/master/include_select_deps
> >
> > HTH
> >
> >
> > On Fri, Oct 31, 2014 at 1:16 AM, Jean-Philippe Caruana <
> jp@target2sell.com>
> > wrote:
> >
> >> Hi,
> >>
> >> I want to package a scala project as a tgz. In the generated tgz, the
> >> scala-compiler-2.10.4.jar is included : it is heavy (14M) and
> unnecessary.
> >>
> >> I try to remove it, but it doesn't work :
> >>
> >>   generated_lib = package(:jar).exclude '*.properties*'
> >>   livrable = package :tgz
> >>   livrable.path('lib').include generated_lib, compile.dependencies
> >>   livrable.path('lib').exclude 'scala-compiler-2.10.4.jar'
> >>
> >>
> >> I added a (always failing) check:
> >>
> >>   check livrable, "doesn't need the very heavy (14M) scala-compiler.jar
> "
> >> do
> >>     it.should_not contain('lib/scala-compiler-2.10.4.jar')
> >>   end
> >>
> >>
> >> I also tried
> >>   generated_lib = package(:jar).exclude '*.properties*'
> >>   livrable = package :tgz
> >>   livrable.path('lib').include generated_lib, (compile.dependencies -
> >> 'org.scala-lang:scala-compiler:jar:2.10.4')
> >>
> >> How can I do ?
> >>
> >> --
> >> Jean-Philippe Caruana
> >> http://www.barreverte.fr
>
> --
> Jean-Philippe Caruana
> http://www.barreverte.fr
>
>


-- 
Cheers,

Peter Donald

Re: scala build

Posted by Jean-Philippe Caruana <jp...@target2sell.com>.
Hi Peter,

thank you for your answer.
I tried the solution you gave, but it doesn't compile :

$ buildr --version
Buildr 1.4.20

$ buildr package
(in /home/jp/src/t2s/performance-tests/querySimulator, development)
sh: 2: Syntax error: EOF in backquote substitution
Buildr aborted!
NoMethodError : undefined method `to_spec' for #<String:0x0000000397c6a8>
/home/jp/src/t2s/performance-tests/querySimulator/buildfile:46:in `block
(3 levels) in <top (required)>'
/home/jp/src/t2s/performance-tests/querySimulator/buildfile:46:in `block
(2 levels) in <top (required)>'
/home/jp/src/t2s/performance-tests/querySimulator/buildfile:45:in `tap'
/home/jp/src/t2s/performance-tests/querySimulator/buildfile:45:in `block
in <top (required)>'
/var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:426:in
`raw_load_buildfile'
/var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:225:in
`block in load_buildfile'
/var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:220:in
`load_buildfile'
(See full trace by running task with --trace)


my buildfile looks like this :

  package(:jar)
  package(:tgz).tap do |pkg|
    pkg.path('lib').include package(:jar), compile.dependencies.select
{|a| a.to_spec != 'org.scala-lang:scala-compiler:jar:2.10.4'}
    pkg.path('etc').include _('src/main/resources')
    pkg.path('bin').include _('src/main/bin')
  end


I also tried it like this :

  generated_lib = package(:jar).exclude '*.properties*'
  livrable = package :tgz
  livrable.path('lib').include generated_lib,
compile.dependencies.select { |a| a.to_spec !=
'org.scala-lang:scala-compiler:jar:2.10.4' }
  livrable.path('lib').exclude 'scala-compiler-2.10.4.jar'

  livrable.include _('src/main/resources'), :as => 'etc'
  livrable.include _('src/main/bin'), :as => 'bin'

But got a similar error:
Buildr aborted!
NoMethodError : undefined method `to_spec' for #<String:0x0000000308d600>
/home/jp/src/t2s/performance-tests/querySimulator/buildfile:45:in `block
(2 levels) in <top (required)>'
/home/jp/src/t2s/performance-tests/querySimulator/buildfile:45:in `block
in <top (required)>'
/var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:426:in
`raw_load_buildfile'
/var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:225:in
`block in load_buildfile'
/var/lib/gems/1.9.1/gems/buildr-1.4.20/lib/buildr/core/application.rb:220:in
`load_buildfile'


Thanks

Le 30/10/2014 23:24, Peter Donald a écrit :
> Hi,
>
> The easiest way to do this is probably replace
>
> compile.dependencies
>
> with
>
> compile.dependencies.select {|a| a.to_spec != 'org.scala-lang:scala-
> compiler:jar:2.10.4'}
>
> I put together an example of this at
>
> https://github.com/realityforge/buildr-examples/tree/master/include_select_deps
>
> HTH
>
>
> On Fri, Oct 31, 2014 at 1:16 AM, Jean-Philippe Caruana <jp...@target2sell.com>
> wrote:
>
>> Hi,
>>
>> I want to package a scala project as a tgz. In the generated tgz, the
>> scala-compiler-2.10.4.jar is included : it is heavy (14M) and unnecessary.
>>
>> I try to remove it, but it doesn't work :
>>
>>   generated_lib = package(:jar).exclude '*.properties*'
>>   livrable = package :tgz
>>   livrable.path('lib').include generated_lib, compile.dependencies
>>   livrable.path('lib').exclude 'scala-compiler-2.10.4.jar'
>>
>>
>> I added a (always failing) check:
>>
>>   check livrable, "doesn't need the very heavy (14M) scala-compiler.jar "
>> do
>>     it.should_not contain('lib/scala-compiler-2.10.4.jar')
>>   end
>>
>>
>> I also tried
>>   generated_lib = package(:jar).exclude '*.properties*'
>>   livrable = package :tgz
>>   livrable.path('lib').include generated_lib, (compile.dependencies -
>> 'org.scala-lang:scala-compiler:jar:2.10.4')
>>
>> How can I do ?
>>
>> --
>> Jean-Philippe Caruana
>> http://www.barreverte.fr

-- 
Jean-Philippe Caruana 
http://www.barreverte.fr


Re: scala build

Posted by Peter Donald <pe...@realityforge.org>.
Hi,

The easiest way to do this is probably replace

compile.dependencies

with

compile.dependencies.select {|a| a.to_spec != 'org.scala-lang:scala-
compiler:jar:2.10.4'}

I put together an example of this at

https://github.com/realityforge/buildr-examples/tree/master/include_select_deps

HTH


On Fri, Oct 31, 2014 at 1:16 AM, Jean-Philippe Caruana <jp...@target2sell.com>
wrote:

> Hi,
>
> I want to package a scala project as a tgz. In the generated tgz, the
> scala-compiler-2.10.4.jar is included : it is heavy (14M) and unnecessary.
>
> I try to remove it, but it doesn't work :
>
>   generated_lib = package(:jar).exclude '*.properties*'
>   livrable = package :tgz
>   livrable.path('lib').include generated_lib, compile.dependencies
>   livrable.path('lib').exclude 'scala-compiler-2.10.4.jar'
>
>
> I added a (always failing) check:
>
>   check livrable, "doesn't need the very heavy (14M) scala-compiler.jar "
> do
>     it.should_not contain('lib/scala-compiler-2.10.4.jar')
>   end
>
>
> I also tried
>   generated_lib = package(:jar).exclude '*.properties*'
>   livrable = package :tgz
>   livrable.path('lib').include generated_lib, (compile.dependencies -
> 'org.scala-lang:scala-compiler:jar:2.10.4')
>
> How can I do ?
>
> --
> Jean-Philippe Caruana
> http://www.barreverte.fr
>
>


-- 
Cheers,

Peter Donald