Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add Saxon Jars to the CLASSPATH if they're already there... #20

Merged
merged 1 commit into from
Jan 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions lib/saxon/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,30 @@ def self.extra_jars(path)
([icu] + optional).compact
end

def self.jars_not_on_classpath?
begin
Java::net.sf.saxon.s9api.Processor
false
rescue
true
end
end

def self.load!(saxon_home = File.expand_path('../../../vendor/saxonica', __FILE__))
return false if @saxon_loaded
LOAD_SEMAPHORE.synchronize do
if Saxon::S9API.const_defined?(:Processor)
false
else
saxon_home = Pathname.new(saxon_home)
raise NoJarsError, saxon_home unless saxon_home.directory?
jars = [main_jar(saxon_home)].compact
raise MissingJarError if jars.empty?
jars += extra_jars(saxon_home)
if jars_not_on_classpath?
saxon_home = Pathname.new(saxon_home)
raise NoJarsError, saxon_home unless saxon_home.directory?
jars = [main_jar(saxon_home)].compact
raise MissingJarError if jars.empty?
jars += extra_jars(saxon_home)

add_jars_to_classpath!(saxon_home, jars)
add_jars_to_classpath!(saxon_home, jars)
end
import_classes_to_namespace!

@saxon_loaded = true
Expand Down