maven-require 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3ac9e757cc19f0c80550c17484e3c0260de9af28c6581510f25cbc402496e1ee
4
+ data.tar.gz: fb8898d3015deea0d8bff48b8070a88200c9d9ed18c1f22d95e2d9a8ed2d8e62
5
+ SHA512:
6
+ metadata.gz: 73178c069b444aee33792cd2f42084a640b5fbba7813b8f7626aa878f34d5fd7a9dbd5efe71146ecc4da507c2cde734430cf4ea4af8ac16f8dc96721678d5242
7
+ data.tar.gz: 2973e59199203c450f0aafc922781bb26681de0d30996b9c0a9af8282a0fa5182a6fdec8cfe88a273f8462d69892a95471a6c0dbb2e7e4a8d2ac481b28596300
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in maven_require.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Maven Require for JRuby
2
+
3
+ Why shouldn't interactively loading Java libraries be as easy as using Ruby gems?
4
+
5
+ If you using JRuby, `maven_require` lets you install and use Maven-published Java libraries interactively.
6
+ For non-interactive use, we recommend creating a `Jarfile` with `jar-dependencies`, which this gem is based on.
7
+
8
+ ## Installation
9
+
10
+ ```ruby
11
+ gem install maven-require
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ruby
17
+ require 'maven_require'
18
+ maven_require 'groupid:artifactid' # installs latest
19
+ maven_require 'groupid', 'artifactid' # installs latest
20
+ maven_require 'groupid:artifactid:version' # installs specified version
21
+ maven_require 'groupid', 'artifactid','version' # installs specified version
22
+
23
+ # load a set of items, resolved together
24
+ maven_require do |deps|
25
+ deps.jar 'groupid:artifactid' # installs latest
26
+ deps.jar 'groupid', 'artifactid' # installs latest
27
+ deps.jar 'groupid:artifactid:version' # installs specified version
28
+ deps.jar 'groupid', 'artifactid','version' # installs specified version
29
+ end
30
+ ```
31
+
32
+ If you are requiring multiple dependencies, it is hightly recommended to use the block form as it resolves all transitive dependencies together
33
+
34
+ NOTE: multiple calls to maven_require will re-resolve the given artifact.
35
+
36
+ ## Development
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/byteit101/maven_require.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MavenRequire
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+ require 'jar_dependencies'
3
+ require 'jars/installer'
4
+ require 'jars/maven_factory'
5
+ require 'jars/gemspec_artifacts'
6
+ require 'tempfile'
7
+
8
+ def maven_require *args
9
+ builder = MavenRequire::RequireMavenBuilder.new
10
+ if args.empty?
11
+ yield builder
12
+ else
13
+ builder.jar(*args)
14
+ end
15
+ MavenRequire::RuntimeInstaller.new(builder).execute
16
+ end
17
+
18
+ module MavenRequire
19
+ class RequireMavenBuilder
20
+ def initialize
21
+ @items = []
22
+ @options = {}
23
+ end
24
+ def [](k)
25
+ @options[k]
26
+ end
27
+ def []=(k,v)
28
+ @options[k] = v
29
+ end
30
+ def options
31
+ @options
32
+ end
33
+ def jar(group, artifact=nil, ver='LATEST')
34
+ if artifact.nil?
35
+ @items << "jar #{group.gsub(":", ",")}#{group.split(":").length == 2 ? ', LATEST' : ""}"
36
+ else
37
+ @items << "jar #{group}, #{artifact}, #{ver}"
38
+ end
39
+ end
40
+ def requirements
41
+ @items
42
+ end
43
+ end
44
+
45
+ class RuntimeInstaller
46
+ def initialize(builder)
47
+ @options = builder.options
48
+ @list = builder
49
+ end
50
+ def resolve_dependencies_list(file)
51
+ factory = Jars::MavenFactory.new(@options)
52
+ #maven = factory.maven_new(File.expand_path('../gemspec_pom.rb', __FILE__))
53
+ # Extract the path to the jar_dependencies' pom
54
+ maven = factory.maven_new(File.expand_path('../gemspec_pom.rb', $LOADED_FEATURES.find{|x|x =~ /jars\/maven_factory\.rb$/}))
55
+
56
+ maven.attach_jars(@list, false)
57
+
58
+ maven['outputAbsoluteArtifactFilename'] = 'true'
59
+ maven['includeTypes'] = 'jar'
60
+ maven['outputScope'] = 'true'
61
+ maven['useRepositoryLayout'] = 'true'
62
+ maven['outputDirectory'] = Jars.home.to_s
63
+ maven['outputFile'] = file.to_s
64
+
65
+ maven.exec('dependency:copy-dependencies', 'dependency:list')
66
+ end
67
+ def execute
68
+ Tempfile.open("deps.lst") do |deps_file|
69
+ raise LoadError, "Maven Resolve failed (see stdout/stderr)" unless resolve_dependencies_list(deps_file.path)
70
+
71
+ puts File.read deps_file.path if Jars.debug?
72
+
73
+ jars = Jars::Installer.load_from_maven(deps_file.path)
74
+ raise LoadError, "Maven Resolve returned no results" unless jars.length >= 1
75
+ jars.each do |id|
76
+ require(id.file)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/maven_require/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "maven-require"
7
+ spec.version = MavenRequire::VERSION
8
+ spec.authors = ["Patrick Plenefisch"]
9
+ spec.email = ["simonpatp@gmail.com"]
10
+
11
+ spec.summary = "Interactively resolve Maven coordinates as a require line"
12
+ spec.description = "A gem to add maven_require, a method to install and load maven coordinates into the current session in JRuby"
13
+ spec.homepage = "https://github.com/byteit101/maven_require"
14
+ spec.required_ruby_version = ">= 2.4.0"
15
+ spec.platform = "java"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ # same license scheme as JRuby
20
+ spec.licenses = ["EPL-2.0", "GPL-2.0+", "LGPL-2.1+"]
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+
30
+ spec.executables = []
31
+ spec.require_paths = ["lib"]
32
+
33
+ # jar depdendencies is builtin to jruby
34
+ spec.add_dependency "jar-dependencies", "~> 0.4"
35
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maven-require
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: java
6
+ authors:
7
+ - Patrick Plenefisch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.4'
19
+ name: jar-dependencies
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.4'
27
+ description: A gem to add maven_require, a method to install and load maven coordinates
28
+ into the current session in JRuby
29
+ email:
30
+ - simonpatp@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rspec"
36
+ - Gemfile
37
+ - README.md
38
+ - Rakefile
39
+ - lib/maven_require.rb
40
+ - lib/maven_require/version.rb
41
+ - maven-require.gemspec
42
+ homepage: https://github.com/byteit101/maven_require
43
+ licenses:
44
+ - EPL-2.0
45
+ - GPL-2.0+
46
+ - LGPL-2.1+
47
+ metadata:
48
+ homepage_uri: https://github.com/byteit101/maven_require
49
+ source_code_uri: https://github.com/byteit101/maven_require
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 2.4.0
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 3.2.14
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Interactively resolve Maven coordinates as a require line
69
+ test_files: []