Class: JavaClass::Classpath::EclipseClasspath

Inherits:
CompositeClasspath show all
Defined in:
lib/javaclass/classpath/eclipse_classpath.rb

Overview

An Eclipse workspace aware classpath.

Author

Peter Kofler

Constant Summary collapse

DOT_CLASSPATH =
'.classpath'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CompositeClasspath

#__old__add_element__, #accessed, #add_element, #add_file_name, #all_accessed, #count, #elements, #includes?, #load_binary, #mark_accessed, #names, #reset_access, #to_s

Methods inherited from FileClasspath

#==, #additional_classpath, #elements, #jar?, #to_key, #to_s

Constructor Details

#initialize(folder) ⇒ EclipseClasspath

Create a classpath for an Eclipse base project in folder where the .classpath is.



30
31
32
33
34
35
36
37
38
39
# File 'lib/javaclass/classpath/eclipse_classpath.rb', line 30

def initialize(folder)
  unless EclipseClasspath::valid_location?(folder)
    raise IOError, "folder #{folder} not an Eclipse project"
  end
  @folder = folder
  dot_classpath = File.join(@folder, DOT_CLASSPATH)
  super(dot_classpath)
  
  add_entries_from(dot_classpath)
end

Class Method Details

.add_variable(name, value) ⇒ Object

Add an Eclipse variable name with _value to look up libraries.



18
19
20
21
22
# File 'lib/javaclass/classpath/eclipse_classpath.rb', line 18

def self.add_variable(name, value)
  @@variables ||= Hash.new
  @@variables.delete(name)
  @@variables[name] = value if value
end

.skip_lib(flag = :skip) ⇒ Object

Skip the lib containers if .classpath.



25
26
27
# File 'lib/javaclass/classpath/eclipse_classpath.rb', line 25

def self.skip_lib(flag=:skip)
  @@skip_lib = flag
end

.valid_location?(file) ⇒ Boolean

Check if the file is a valid location for an Eclipse classpath.

Returns:

  • (Boolean)


13
14
15
# File 'lib/javaclass/classpath/eclipse_classpath.rb', line 13

def self.valid_location?(file)
  FileTest.exist?(file) && FileTest.directory?(file) && FileTest.exist?(File.join(file, DOT_CLASSPATH))
end