开发者

Why is grep Failing to Find Matches on my Groovy Dependencies? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geogr开发者_如何学运维aphic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

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 # => []


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜