Module | JavaClass::Analyse::TransitiveDependencies |
In: |
lib/javaclass/analyse/transitive_dependencies.rb
|
Transitive dependency analysis to be mixed into Dsl::LoadingClasspath. For an example see how to get cumulative dependencies of a class. For plain dependencies of a Classpath see Dependencies.
Author: | Peter Kofler |
Creates the tree of all transitive dependencies of the Java package where every dependency is only listed once at its first occurence. It returns an AdderTree containing all found dependencies. An additional block is used as filter on class names to work with, e.g. the main classes. Requires a method names in the base class.
# File lib/javaclass/analyse/transitive_dependencies.rb, line 39 def transitive_dependencies_package(package, &filter) tree = AdderTree.new(package) names { |classname| classname.same_or_subpackage_of?(package) }.each do |classname| transitive_dependency_tree(classname, tree, &filter) end tree end
Creates the tree of all transitive dependencies of classname where every dependency is only listed once at its first occurence. It returns an AdderTree containing all found dependencies. An additional block is used as filter on class names to work with, e.g. the main classes. Requires methods includes? and load in the base class.
# File lib/javaclass/analyse/transitive_dependencies.rb, line 16 def transitive_dependency_tree(classname, tree=nil, &filter) return if block_given? && !filter.call(classname) return if tree && tree.root.contain?(classname) if tree tree = tree.add(classname.to_classname) else tree = AdderTree.new(classname.to_classname) end if includes?(classname) load(classname).imported_3rd_party_types.each do |type| transitive_dependency_tree(type, tree, &filter) end end tree end