Created
January 9, 2012 15:51
-
-
Save lenny/1583527 to your computer and use it in GitHub Desktop.
Java Classpath Helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JavaClasspath | |
class << self | |
def bootstrap(jar_dirs, classpath_dirs) | |
jar_dirs.each do |jardir| | |
Dir.entries(jardir).grep(/\.jar$/) {|jar| add_expanded_path(File.join(jardir, jar))} | |
end | |
classpath_dirs.each do |cp_dir| | |
add_expanded_path(cp_dir) | |
end | |
end | |
def add_expanded_path(file) | |
if File.directory?(file) | |
$CLASSPATH << "#{File.expand_path(file)}/" | |
else | |
$CLASSPATH << File.expand_path(file) | |
end | |
end | |
def add_jars_from_dir(jardir) | |
unless File.exists?(jardir) | |
raise "#{jardir} doesn't exist" | |
end | |
Dir.entries(jardir).grep(/\.jar$/) {|jar| add_expanded_path(File.join(jardir, jar))} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment