lib/buildr/java/tests.rb
def filter_classes(dependencies, criteria = {})
      return [] unless task.compile.target
      target = task.compile.target.to_s
      candidates = Dir["#{target}/**/*.class"].
        map { |file| Util.relative_path(file, target).ext('').gsub(File::SEPARATOR, '.') }.
        reject { |name| name =~ /\$./ }
      result = []
      if criteria[:class_names]
        result.concat candidates.select { |name| criteria[:class_names].flatten.any? { |pat| pat === name } }
      end
      begin
        Java.load
        filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
        if criteria[:interfaces]
          filter.add_interfaces(criteria[:interfaces].to_java(Java.java.lang.String)) 
        end
        if criteria[:class_annotations]
          filter.add_class_annotations(criteria[:class_annotations].to_java(Java.java.lang.String))
        end
        if criteria[:method_annotations]
          filter.add_method_annotations(criteria[:method_annotations].to_java(Java.java.lang.String))
        end
        result.concat filter.filter(candidates.to_java(Java.java.lang.String)).map(&:to_s)
      rescue =>ex
        info "#{ex.class}: #{ex.message}"
        raise
      end
      # We strip Scala singleton objects whose .class ends with $
      result.map { |c| (c =~ /\$$/) ? c[0..(c.size - 2)] : c  }.uniq
    end
# :call-seq:
#     filter_classes(dependencies, criteria)
# 
# Return a list of classnames that match the given criteria. 
# The criteria parameter is a hash that must contain at least one of:
#
# * :class_names -- List of patterns to match against class name
# * :interfaces -- List of java interfaces or java classes
# * :class_annotations -- List of annotations on class level
# * :method_annotations -- List of annotations on method level
#


Return a list of classnames that match the given criteria.
The criteria parameter is a hash that must contain at least one of.


Return a list of classnames that match the given criteria . The criteria parameter is a hash that must contain at least one of .
def filter_classes(dependencies, criteria = {})
      return [] unless task.compile.target
      target = task.compile.target.to_s
      candidates = Dir["#{target}/**/*.class"].
        map { |file| Util.relative_path(file, target).ext('').gsub(File::SEPARATOR, '.') }.
        reject { |name| name =~ /\$./ }
      result = []
      if criteria[:class_names]
        result.concat candidates.select { |name| criteria[:class_names].flatten.any? { |pat| pat === name } }
      end
      begin
        Java.load
        filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
        if criteria[:interfaces]
          filter.add_interfaces(criteria[:interfaces].to_java(Java.java.lang.String)) 
        end
        if criteria[:class_annotations]
          filter.add_class_annotations(criteria[:class_annotations].to_java(Java.java.lang.String))
        end
        if criteria[:method_annotations]
          filter.add_method_annotations(criteria[:method_annotations].to_java(Java.java.lang.String))
        end
        result.concat filter.filter(candidates.to_java(Java.java.lang.String)).map(&:to_s)
      rescue =>ex
        info "#{ex.class}: #{ex.message}"
        raise
      end
      result.map { |c| (c =~ /\$$/) ? c[0..(c.size - 2)] : c  }.uniq
    end
def filter_classes ( dependencies , criteria = { } ) return [ ] unless task . compile . target target = task . compile . target . to_s candidates = Dir [ "#{target}/**/*.class" ] . map { | file | Util . relative_path ( file , target ) . ext ( '' ) . gsub ( File :: SEPARATOR , '.' ) } . reject { | name | name =~ / \$ . / } result = [ ] if criteria [ :class_names ] result . concat candidates . select { | name | criteria [ :class_names ] . flatten . any? { | pat | pat === name } } end begin Java . load filter = Java . org . apache . buildr . JavaTestFilter . new ( dependencies . to_java ( Java . java . lang . String ) ) if criteria [ :interfaces ] filter . add_interfaces ( criteria [ :interfaces ] . to_java ( Java . java . lang . String ) ) end if criteria [ :class_annotations ] filter . add_class_annotations ( criteria [ :class_annotations ] . to_java ( Java . java . lang . String ) ) end if criteria [ :method_annotations ] filter . add_method_annotations ( criteria [ :method_annotations ] . to_java ( Java . java . lang . String ) ) end result . concat filter . filter ( candidates . to_java ( Java . java . lang . String ) ) . map ( & :to_s ) rescue => ex info "#{ex.class}: #{ex.message}" raise end result . map { | c | ( c =~ / \$ $ / ) ? c [ 0 .. ( c . size - 2 ) ] : c } . uniq end
:call-seq:
filter_classes(dependencies, criteria)
: call - seq : filter_classes ( dependencies criteria )
# We strip Scala singleton objects whose .class ends with $
dependencies
criteria