Module: Jars
- Defined in:
- lib/jar_dependencies.rb,
lib/jar_installer.rb more...
Overview
Copyright © 2014 Christian Meier
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defined Under Namespace
Classes: JarInstaller
Constant Summary collapse
- HOME =
'JARS_HOME'
- MAVEN_SETTINGS =
'JARS_MAVEN_SETTINGS'
- SKIP =
'JARS_SKIP'
- VERBOSE =
'JARS_VERBOSE'
- DEBUG =
'JARS_DEBUG'
- VENDOR =
'JARS_VENDOR'
Class Method Summary collapse
- .absolute(file) ⇒ Object
- .debug? ⇒ Boolean
- .home ⇒ Object
- .maven_settings ⇒ Object
- .require_jar(group_id, artifact_id, *classifier_version) ⇒ Object
- .reset ⇒ Object
- .skip? ⇒ Boolean
- .to_boolean(key) ⇒ Object
- .to_prop(key) ⇒ Object
- .vendor? ⇒ Boolean
- .verbose? ⇒ Boolean
Class Method Details
permalink .absolute(file) ⇒ Object
[View source]
65 66 67 |
# File 'lib/jar_dependencies.rb', line 65 def self.absolute( file ) File.( file ) if file end |
permalink .debug? ⇒ Boolean
57 58 59 |
# File 'lib/jar_dependencies.rb', line 57 def self.debug? to_boolean( DEBUG ) end |
permalink .home ⇒ Object
[View source]
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/jar_dependencies.rb', line 87 def self.home if @_jars_home_.nil? unless @_jars_home_ = absolute( to_prop( HOME ) ) begin require 'rexml/document' doc = REXML::Document.new( File.read( maven_settings ) ) REXML::XPath.first( doc, "//settings/localRepository").tap do |e| @_jars_home_ = e.text.sub( /\\/, '/') if e end rescue # ignore end end # use maven default repository @_jars_home_ ||= File.join( ENV[ 'HOME' ], '.m2', 'repository' ) end @_jars_home_ end |
permalink .maven_settings ⇒ Object
[View source]
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/jar_dependencies.rb', line 76 def self.maven_settings if @_jars_maven_settings_.nil? unless @_jars_maven_settings_ = absolute( to_prop( MAVEN_SETTINGS ) ) # use maven default settings @_jars_maven_settings_ = File.join( ENV[ 'HOME' ], '.m2', 'settings.xml' ) end end @_jars_maven_settings_ end |
permalink .require_jar(group_id, artifact_id, *classifier_version) ⇒ Object
[View source]
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/jar_dependencies.rb', line 106 def self.require_jar( group_id, artifact_id, *classifier_version ) version = classifier_version[ -1 ] classifier = classifier_version[ -2 ] @@jars ||= {} coordinate = "#{group_id}:#{artifact_id}" coordinate += ":#{classifier}" if classifier if @@jars.key? coordinate if @@jars[ coordinate ] == version false else # version of already registered jar @@jars[ coordinate ] end else do_require( group_id, artifact_id, version, classifier ) @@jars[ coordinate ] = version return true end end |
permalink .reset ⇒ Object
[View source]
69 70 71 72 73 74 |
# File 'lib/jar_dependencies.rb', line 69 def self.reset @_jars_maven_settings_ = nil @_jars_home_ = nil @@jars ||= {} @@jars.clear end |
permalink .skip? ⇒ Boolean
49 50 51 |
# File 'lib/jar_dependencies.rb', line 49 def self.skip? to_boolean( SKIP ) end |
permalink .to_boolean(key) ⇒ Object
[View source]
41 42 43 44 45 46 47 |
# File 'lib/jar_dependencies.rb', line 41 def self.to_boolean( key ) prop = to_prop( key ) # prop == nil => false # prop == 'false' => false # anything else => true prop == '' or prop == 'true' end |
permalink .to_prop(key) ⇒ Object
[View source]
31 32 33 34 |
# File 'lib/jar_dependencies.rb', line 31 def self.to_prop( key ) java.lang.System.getProperty( key.downcase.gsub( /_/, '.' ) ) || ENV[key.upcase.gsub( /[.]/, '_' ) ] end |
permalink .vendor? ⇒ Boolean
61 62 63 |
# File 'lib/jar_dependencies.rb', line 61 def self.vendor? to_boolean( VENDOR ) end |
permalink .verbose? ⇒ Boolean
53 54 55 |
# File 'lib/jar_dependencies.rb', line 53 def self.verbose? to_boolean( VERBOSE ) end |