1

Does anyone know why the following code returns an empty array? Thanks.

groovyc_deps = Buildr::Groovy::Groovyc.dependencies
groovy_jar = groovyc_deps.grep /.*groovy.*\.jar/
p groovy_jar # => []
Tomasz Stanczak
  • 12,796
  • 1
  • 30
  • 32
dakin
  • 79
  • 1
  • 4

1 Answers1

5

Because Groovyc.dependencies returns an array of Artifact, not Strings.

Try the following,

groovyc_deps = Buildr::Groovy::Groovyc.dependencies
groovy_jar = groovyc_deps.select { |a| a.to_s =~ /.*groovy.*\.jar/ }

which converts artifacts to string before matching against the regular expression.

Alex Boisvert
  • 2,850
  • 2
  • 19
  • 18