Method: JavaClass::Classpath::Factory#workspace

Defined in:
lib/javaclass/classpath/factory.rb

#workspace(basepath, cp = CompositeClasspath.new) ⇒ Object

Create a classpath from a workspace basepath which contains Eclipse or Maven projects.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/javaclass/classpath/factory.rb', line 38

def workspace(basepath, cp=CompositeClasspath.new)
  # check for a valid project in this folder
  Classpath_types.each do |classpath_type|
    if classpath_type.valid_location?(basepath)
      cp.add_element(classpath_type.new(basepath))
      return cp
    end
  end

  # check the children as regular workspace
  Dir.entries(basepath).each do |entry|
    next if entry == '.' || entry == '..'
    file = File.join(basepath, entry)

    Classpath_types.each do |classpath_type|
      if classpath_type.valid_location?(file)
        cp.add_element(classpath_type.new(file))
        break
      end
    end
  end if FileTest.directory? basepath
  cp
end