Module: Jars
- Defined in:
- lib/jar_dependencies.rb,
lib/jars/lock.rb,
lib/jars/version.rb,
lib/jars/classpath.rb,
lib/jars/installer.rb,
lib/jars/maven_exec.rb
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: Classpath, Installer, JarDetails, Lock, MavenExec
Constant Summary collapse
- VERSION =
'0.1.14'.freeze
- JarInstaller =
to stay backward compatible
Installer
- MAVEN_SETTINGS =
'JARS_MAVEN_SETTINGS'.freeze
- LOCAL_MAVEN_REPO =
'JARS_LOCAL_MAVEN_REPO'.freeze
- LOCK =
lock file to use
'JARS_LOCK'.freeze
- HOME =
where the locally stored jars are search for or stored
'JARS_HOME'.freeze
- SKIP =
skip the gem post install hook
'JARS_SKIP'.freeze
- NO_REQUIRE =
just do not require any jars
'JARS_NO_REQUIRE'.freeze
- QUIET =
no more warnings on conflict. this still requires jars but will not warn. it is needed to load jars from (default) gems which do contribute to any dependency manager (maven, gradle, jbundler)
'JARS_QUIET'.freeze
- VERBOSE =
show maven output
'JARS_VERBOSE'.freeze
- DEBUG =
maven debug
'JARS_DEBUG'.freeze
- VENDOR =
vendor jars inside gem when installing gem
'JARS_VENDOR'.freeze
- RESOLVE =
resolve jars from Jars.lock
'JARS_RESOLVE'.freeze
Class Method Summary collapse
- .debug? ⇒ Boolean
- .freeze_loading ⇒ Object
- .home ⇒ Object
- .local_maven_repo ⇒ Object
- .lock ⇒ Object
- .maven_global_settings ⇒ Object
- .maven_user_settings ⇒ Object (also: maven_settings)
- .no_more_warnings ⇒ Object
- .no_require? ⇒ Boolean
- .quiet? ⇒ Boolean
- .require_jar(group_id, artifact_id, *classifier_version) ⇒ Object
- .require_jars_lock ⇒ Object
- .require_jars_lock!(scope = :runtime) ⇒ Object
- .reset ⇒ Object
- .resolve? ⇒ Boolean
- .skip? ⇒ Boolean
- .to_boolean(key) ⇒ Object
- .vendor? ⇒ Boolean
- .verbose? ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.debug? ⇒ Boolean
82 83 84 |
# File 'lib/jar_dependencies.rb', line 82 def debug? to_boolean( DEBUG ) end |
.freeze_loading ⇒ Object
98 99 100 |
# File 'lib/jar_dependencies.rb', line 98 def freeze_loading @frozen = true end |
.home ⇒ Object
151 152 153 154 155 156 |
# File 'lib/jar_dependencies.rb', line 151 def home @_jars_home_ ||= absolute(to_prop(HOME)) || detect_local_repository(maven_user_settings) || detect_local_repository(maven_global_settings) || File.join( user_home, '.m2', 'repository' ) end |
.local_maven_repo ⇒ Object
106 107 108 |
# File 'lib/jar_dependencies.rb', line 106 def local_maven_repo to_prop( LOCAL_MAVEN_REPO ) || home end |
.lock ⇒ Object
102 103 104 |
# File 'lib/jar_dependencies.rb', line 102 def lock to_prop( LOCK ) || 'Jars.lock' end |
.maven_global_settings ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/jar_dependencies.rb', line 135 def maven_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.exists?(settings) else settings = false end @_jars_maven_global_settings_ = settings end @_jars_maven_global_settings_ || nil end |
.maven_user_settings ⇒ Object Also known as: maven_settings
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/jar_dependencies.rb', line 115 def maven_user_settings unless instance_variable_defined?(:@_jars_maven_user_settings_) @_jars_maven_user_settings_ = nil end if ( @_jars_maven_user_settings_ ||= nil ).nil? if settings = absolute( to_prop( MAVEN_SETTINGS ) ) unless File.exists?(settings) warn "configured ENV['#{MAVEN_SETTINGS}'] = '#{settings}' not found" unless quiet? settings = false end else # use maven default (user) settings settings = File.join( user_home, '.m2', 'settings.xml' ) settings = false unless File.exists?(settings) end @_jars_maven_user_settings_ = settings end @_jars_maven_user_settings_ || nil end |
.no_more_warnings ⇒ Object
94 95 96 |
# File 'lib/jar_dependencies.rb', line 94 def no_more_warnings @silent = true end |
.no_require? ⇒ Boolean
70 71 72 |
# File 'lib/jar_dependencies.rb', line 70 def no_require? ( @frozen ||= false ) || to_boolean( NO_REQUIRE ) end |
.quiet? ⇒ Boolean
74 75 76 |
# File 'lib/jar_dependencies.rb', line 74 def quiet? ( @silent ||= false ) || to_boolean( QUIET ) end |
.require_jar(group_id, artifact_id, *classifier_version) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/jar_dependencies.rb', line 178 def require_jar( group_id, artifact_id, *classifier_version ) require_jars_lock 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 |
.require_jars_lock ⇒ Object
170 171 172 173 174 175 176 |
# File 'lib/jar_dependencies.rb', line 170 def require_jars_lock @@jars_lock ||= false unless @@jars_lock require_jars_lock! @@jars_lock ||= true end end |
.require_jars_lock!(scope = :runtime) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/jar_dependencies.rb', line 158 def require_jars_lock!( scope = :runtime ) # funny error during spec where it tries to load it again # and finds it as gem instead of the LOAD_PATH require 'jars/classpath' unless defined? Jars::Classpath classpath = Jars::Classpath.new if jars_lock = classpath.jars_lock @@jars_lock = jars_lock classpath.require( scope ) no_more_warnings end end |
.reset ⇒ Object
110 111 112 113 |
# File 'lib/jar_dependencies.rb', line 110 def reset instance_variables.each { |var| instance_variable_set(var, nil) } ( @@jars ||= {} ).clear end |
.resolve? ⇒ Boolean
90 91 92 |
# File 'lib/jar_dependencies.rb', line 90 def resolve? to_boolean( RESOLVE ) end |
.skip? ⇒ Boolean
66 67 68 |
# File 'lib/jar_dependencies.rb', line 66 def skip? to_boolean( SKIP ) end |
.to_boolean(key) ⇒ Object
61 62 63 64 |
# File 'lib/jar_dependencies.rb', line 61 def to_boolean( key ) prop = to_prop( key ) ! prop.nil? && ( prop.empty? || prop.eql?('true') ) end |
.vendor? ⇒ Boolean
86 87 88 |
# File 'lib/jar_dependencies.rb', line 86 def vendor? to_boolean( VENDOR ) end |
.verbose? ⇒ Boolean
78 79 80 |
# File 'lib/jar_dependencies.rb', line 78 def verbose? to_boolean( VERBOSE ) end |
Instance Method Details
#to_prop(key) ⇒ Object
50 51 52 53 54 |
# File 'lib/jar_dependencies.rb', line 50 def to_prop( key ) key = key.gsub( '_', '.' ) ENV_JAVA[ ( key.downcase!; key ) ] || ENV[ ( key.gsub!( '.', '_' ); key.upcase!; key ) ] end |