maven_gem 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +5 -1
- data/Rakefile +5 -1
- data/lib/maven_gem.rb +1 -1
- data/lib/pom2gem.rb +57 -5
- metadata +8 -8
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -5,7 +5,11 @@ require 'hoe'
|
|
5
5
|
require './lib/maven_gem.rb'
|
6
6
|
|
7
7
|
Hoe.new('maven_gem', MavenGem::VERSION) do |p|
|
8
|
-
p.rubyforge_name = '
|
8
|
+
p.rubyforge_name = 'jruby-extras'
|
9
|
+
p.url = "http://github.com/jruby/maven_gem"
|
10
|
+
p.author = "charles.nutter@sun.com"
|
11
|
+
p.summary = "maven_gem is a command and RubyGems plugin for packaging Maven artifacts as gems."
|
12
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
9
13
|
p.developer('Charles Oliver Nutter', 'charles.nutter@sun.com')
|
10
14
|
end
|
11
15
|
|
data/lib/maven_gem.rb
CHANGED
data/lib/pom2gem.rb
CHANGED
@@ -19,6 +19,50 @@ module MavenGem
|
|
19
19
|
pom_doc = REXML::Document.new(Net::HTTP.get(uri))
|
20
20
|
from_doc(pom_doc, options)
|
21
21
|
end
|
22
|
+
|
23
|
+
# Unless the maven version string is a valid Gem version string create a substitute
|
24
|
+
# gem version string by dividing the maven version string into it's numeric elements
|
25
|
+
# and joining them back together with '.' characters.
|
26
|
+
#
|
27
|
+
# The string 'alpha' in a maven version string is converted to '0'.
|
28
|
+
# The string 'beta' in a maven version string is converted to '1'.
|
29
|
+
#
|
30
|
+
# In general gem versions strings need to either be an Integer or start with a
|
31
|
+
# digit and a '.'.
|
32
|
+
#
|
33
|
+
# For example the flying saucer core-renderer jar that uses itext to generate a
|
34
|
+
# pdf from styled xhtml input has a version string of "R8pre2".
|
35
|
+
#
|
36
|
+
# Installing this jar:
|
37
|
+
#
|
38
|
+
# jruby -S gem maven org/xhtmlrenderer core-renderer R8pre2
|
39
|
+
#
|
40
|
+
# results in:
|
41
|
+
#
|
42
|
+
# Successfully installed core-renderer-8.2-java
|
43
|
+
# 1 gem installed
|
44
|
+
#
|
45
|
+
# jruby -S gem list core-renderer
|
46
|
+
#
|
47
|
+
# *** LOCAL GEMS ***
|
48
|
+
#
|
49
|
+
# core-renderer (8.2)
|
50
|
+
#
|
51
|
+
# In addition the following constants are created in the new maven gem:
|
52
|
+
#
|
53
|
+
# CoreRenderer::VERSION # => "8.2"
|
54
|
+
# CoreRenderer::MAVEN_VERSION # => "R8pre2"
|
55
|
+
#
|
56
|
+
def self.maven_to_gem_version(maven_version)
|
57
|
+
maven_version = maven_version.gsub(/alpha/, '0')
|
58
|
+
maven_version = maven_version.gsub(/beta/, '1')
|
59
|
+
maven_numbers = maven_version.gsub(/\D+/, '.').split('.').find_all { |i| i.length > 0 }
|
60
|
+
if maven_numbers.empty?
|
61
|
+
'0.0.0'
|
62
|
+
else
|
63
|
+
maven_numbers.join('.')
|
64
|
+
end
|
65
|
+
end
|
22
66
|
|
23
67
|
def self.from_doc(pom_doc, options = {})
|
24
68
|
begin
|
@@ -29,6 +73,8 @@ module MavenGem
|
|
29
73
|
artifact = nil
|
30
74
|
group = nil
|
31
75
|
version = nil
|
76
|
+
maven_version = nil
|
77
|
+
titleized_classname = nil
|
32
78
|
|
33
79
|
puts "Processing POM" if options[:verbose]
|
34
80
|
pom_doc.elements.each("/project/*") do |element|
|
@@ -36,11 +82,13 @@ module MavenGem
|
|
36
82
|
when "artifactId"
|
37
83
|
spec.name = element.text
|
38
84
|
artifact = element.text
|
85
|
+
titleized_classname = artifact.chomp('.rb').split('-').collect { |e| e.capitalize }.join
|
39
86
|
when "groupId"
|
40
87
|
group = element.text
|
41
88
|
when "version"
|
42
|
-
|
43
|
-
version =
|
89
|
+
maven_version = element.text
|
90
|
+
version = MavenGem::PomSpec.maven_to_gem_version(maven_version)
|
91
|
+
spec.version = version
|
44
92
|
when "description"
|
45
93
|
spec.description = element.text
|
46
94
|
when "dependencies"
|
@@ -78,7 +126,11 @@ module MavenGem
|
|
78
126
|
jar_contents = Net::HTTP.get(uri)
|
79
127
|
File.open("#{gem_dir}/lib/#{jar_file}", 'w') {|f| f.write(jar_contents)}
|
80
128
|
|
81
|
-
ruby_file_contents = <<
|
129
|
+
ruby_file_contents = <<HEREDOC
|
130
|
+
module #{titleized_classname}
|
131
|
+
VERSION = '#{version}'
|
132
|
+
MAVEN_VERSION = '#{maven_version}'
|
133
|
+
end
|
82
134
|
begin
|
83
135
|
require 'java'
|
84
136
|
require File.dirname(__FILE__) + '/#{jar_file}'
|
@@ -86,7 +138,7 @@ rescue LoadError
|
|
86
138
|
puts 'JAR-based gems require JRuby to load. Please visit www.jruby.org.'
|
87
139
|
raise
|
88
140
|
end
|
89
|
-
|
141
|
+
HEREDOC
|
90
142
|
ruby_file = "#{gem_dir}/lib/#{artifact}.rb"
|
91
143
|
puts "Writing #{ruby_file}" if options[:verbose]
|
92
144
|
File.open(ruby_file, 'w') do |file|
|
@@ -133,4 +185,4 @@ if __FILE__ == $0
|
|
133
185
|
else
|
134
186
|
raise ArgumentError, "specify filename or URL on command line"
|
135
187
|
end
|
136
|
-
end
|
188
|
+
end
|
metadata
CHANGED
@@ -9,20 +9,20 @@ email:
|
|
9
9
|
- charles.nutter@sun.com
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
summary:
|
13
|
-
|
12
|
+
summary: maven_gem is a command and RubyGems plugin for packaging Maven artifacts
|
13
|
+
as gems.
|
14
14
|
post_install_message:
|
15
15
|
extra_rdoc_files:
|
16
16
|
- History.txt
|
17
17
|
- Manifest.txt
|
18
18
|
- README.txt
|
19
|
-
homepage: http://
|
19
|
+
homepage: http://github.com/jruby/maven_gem
|
20
20
|
signing_key:
|
21
21
|
name: maven_gem
|
22
22
|
rdoc_options:
|
23
23
|
- --main
|
24
24
|
- README.txt
|
25
|
-
rubyforge_project:
|
25
|
+
rubyforge_project: jruby-extras
|
26
26
|
autorequire:
|
27
27
|
licenses: []
|
28
28
|
|
@@ -54,17 +54,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version:
|
55
55
|
extensions: []
|
56
56
|
|
57
|
-
rubygems_version: 1.3.
|
57
|
+
rubygems_version: 1.3.3
|
58
58
|
requirements: []
|
59
59
|
|
60
60
|
authors:
|
61
|
-
-
|
62
|
-
date: 2009-
|
61
|
+
- charles.nutter@sun.comCharles Oliver Nutter
|
62
|
+
date: 2009-05-14 05:00:00 +00:00
|
63
63
|
platform: ruby
|
64
64
|
test_files:
|
65
65
|
- test/test_maven_gem.rb
|
66
66
|
version: !ruby/object:Gem::Version
|
67
|
-
version: 0.0.
|
67
|
+
version: 0.0.2
|
68
68
|
require_paths:
|
69
69
|
- lib
|
70
70
|
dependencies:
|