class JavaClass::Classpath::EclipseClasspath
An Eclipse workspace aware classpath.
- Author
-
Peter Kofler
Constants
- DOT_CLASSPATH
Public Class Methods
add_variable(name, value)
click to toggle source
Add an Eclipse variable name with _value to look up libraries.
# 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
new(folder)
click to toggle source
Create a classpath for an Eclipse base project in folder where the .classpath is.
Calls superclass method
JavaClass::Classpath::CompositeClasspath::new
# 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
skip_lib(flag=:skip)
click to toggle source
Skip the lib containers if .classpath.
# File lib/javaclass/classpath/eclipse_classpath.rb, line 25 def self.skip_lib(flag=:skip) @@skip_lib = flag end
valid_location?(file)
click to toggle source
Check if the file is a valid location for an Eclipse classpath.
# 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
Private Instance Methods
add_entries_from(dot_classpath)
click to toggle source
# File lib/javaclass/classpath/eclipse_classpath.rb, line 43 def add_entries_from(dot_classpath) dot_classpath_lines = IO.readlines(dot_classpath) add_output_folder(dot_classpath_lines) add_source_output_folder(dot_classpath_lines) @@skip_lib ||= false unless @@skip_lib add_local_libraries(dot_classpath_lines) @@variables ||= Hash.new add_variables(dot_classpath_lines) end end
add_local_libraries(dot_classpath_lines)
click to toggle source
# File lib/javaclass/classpath/eclipse_classpath.rb, line 74 def add_local_libraries(dot_classpath_lines) dot_classpath_lines.find_all { |line| line =~ /kind\s*=\s*"lib"/ }.each do |line| if line =~ /path\s*=\s*"([^"]+)"/ add_file_name(File.join(@folder, $1)) end end end
add_output_folder(dot_classpath_lines)
click to toggle source
# File lib/javaclass/classpath/eclipse_classpath.rb, line 58 def add_output_folder(dot_classpath_lines) dot_classpath_lines.find_all { |line| line =~ /kind\s*=\s*"output"/ }.each do |line| if line =~ /path\s*=\s*"([^"]+)"/ add_file_name(File.join(@folder, $1)) end end end
add_source_output_folder(dot_classpath_lines)
click to toggle source
# File lib/javaclass/classpath/eclipse_classpath.rb, line 66 def add_source_output_folder(dot_classpath_lines) dot_classpath_lines.find_all { |line| line =~ /output\s*=\s*"/ }.each do |line| if line =~ /output\s*=\s*"([^"]+)"/ add_file_name(File.join(@folder, $1)) end end end
add_variables(dot_classpath_lines)
click to toggle source
# File lib/javaclass/classpath/eclipse_classpath.rb, line 82 def add_variables(dot_classpath_lines) dot_classpath_lines.find_all { |line| line =~ /kind\s*=\s*"var"/ }.each do |line| if line =~ /path\s*=\s*"([^\/]+)\/([^"]+)"/ path = @@variables[$1] add_file_name(File.join(path, $2)) if path end end end