lib/java/pom.rb in buildr-1.2.3 vs lib/java/pom.rb in buildr-1.2.4

- old
+ new

@@ -24,14 +24,18 @@ def load(source) case source when Hash load(Buildr.artifact(source).pom) when Artifact - load(source.pom.to_s) - when String, Rake::FileTask + pom = source.pom + pom.invoke + load(pom.to_s) + when Rake::FileTask + source.invoke + load(source.to_s) + when String filename = File.expand_path(source) - file(filename).invoke unless pom = cache[filename] puts "Loading m2 pom file from #{filename}" if Rake.application.options.trace pom = POM.new(IO.read(filename)) cache[filename] = pom end @@ -116,14 +120,17 @@ # # The first form returns all the managed dependencies specified by this POM in dependencyManagement. # The second form uses a single spec hash and expands it from the current/parent POM. Used to determine # the version number if specified in dependencyManagement instead of dependencies. def managed(spec = nil) - return managed.detect { |dep| [:group, :id, :type, :classifier].all? { |key| spec[key] == dep[key] } } || - (parent ? parent.managed(spec) : nil) if spec - @managed ||= begin - managed = project["dependencyManagement"].first["dependencies"].first["dependency"] rescue [] - managed.map { |dep| pom_to_hash(dep, properties) } + if spec + managed.detect { |dep| [:group, :id, :type, :classifier].all? { |key| spec[key] == dep[key] } } || + (parent ? parent.managed(spec) : nil) + else + @managed ||= begin + managed = project["dependencyManagement"].first["dependencies"].first["dependency"] rescue nil + managed ? managed.map { |dep| pom_to_hash(dep, properties) } : [] + end end end private