Class: Jars::MavenSettings
- Inherits:
-
Object
- Object
- Jars::MavenSettings
- Defined in:
- lib/jars/maven_settings.rb
Constant Summary collapse
- LINE_SEPARATOR =
ENV_JAVA['line.separator']
Class Method Summary collapse
- .cleanup ⇒ Object
- .effective_settings ⇒ Object
- .global_settings ⇒ Object
- .local_settings ⇒ Object
- .reset ⇒ Object
- .settings ⇒ Object
- .user_settings ⇒ Object
Class Method Details
.cleanup ⇒ Object
61 62 63 64 65 |
# File 'lib/jars/maven_settings.rb', line 61 def cleanup File.unlink(effective_settings) if effective_settings != settings ensure reset end |
.effective_settings ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/jars/maven_settings.rb', line 38 def effective_settings unless instance_variable_defined?(:@_jars_effective_maven_settings_) @_jars_effective_maven_settings_ = nil end if @_jars_effective_maven_settings_.nil? begin require 'rubygems/request' http = Gem::Request.proxy_uri(Gem.configuration[:http_proxy] || Gem::Request.get_proxy_from_env('http')) https = Gem::Request.proxy_uri(Gem.configuration[:https_proxy] || Gem::Request.get_proxy_from_env('https')) rescue Jars.debug('ignore rubygems proxy configuration as rubygems is too old') end if http.nil? && https.nil? @_jars_effective_maven_settings_ = settings else @_jars_effective_maven_settings_ = setup_interpolated_settings(http, https) || settings end end @_jars_effective_maven_settings_ end |
.global_settings ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/jars/maven_settings.rb', line 78 def global_settings unless instance_variable_defined?(:@_jars_maven_global_settings_) @_jars_maven_global_settings_ = nil end if @_jars_maven_global_settings_.nil? if mvn_home = ENV['M2_HOME'] || ENV['MAVEN_HOME'] settings = File.join(mvn_home, 'conf/settings.xml') settings = false unless File.exist?(settings) else settings = false end @_jars_maven_global_settings_ = settings end @_jars_maven_global_settings_ || nil end |
.local_settings ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/jars/maven_settings.rb', line 7 def local_settings unless instance_variable_defined?(:@_jars_maven_local_settings_) @_jars_maven_local_settings_ = nil end if @_jars_maven_local_settings_.nil? if settings = Jars.absolute('settings.xml') @_jars_maven_local_settings_ = settings if File.exist?(settings) end end @_jars_maven_local_settings_ || nil end |
.reset ⇒ Object
67 68 69 |
# File 'lib/jars/maven_settings.rb', line 67 def reset instance_variables.each { |var| instance_variable_set(var, nil) } end |
.settings ⇒ Object
71 72 73 74 75 76 |
# File 'lib/jars/maven_settings.rb', line 71 def settings unless instance_variable_defined?(:@_jars_maven_settings_) @_jars_maven_settings_ = nil end local_settings || user_settings if @_jars_maven_settings_.nil? end |
.user_settings ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jars/maven_settings.rb', line 19 def user_settings unless instance_variable_defined?(:@_jars_maven_user_settings_) @_jars_maven_user_settings_ = nil end if @_jars_maven_user_settings_.nil? if settings = Jars.absolute(Jars.to_prop(MAVEN_SETTINGS)) unless File.exist?(settings) Jars.warn { "configured ENV['#{MAVEN_SETTINGS}'] = '#{settings}' not found" } settings = false end else # use maven default (user) settings settings = File.join(Jars.user_home, '.m2', 'settings.xml') settings = false unless File.exist?(settings) end @_jars_maven_user_settings_ = settings end @_jars_maven_user_settings_ || nil end |