lib/maven/tools/gem_project.rb in maven-tools-0.32.4 vs lib/maven/tools/gem_project.rb in maven-tools-0.32.5
- old
+ new
@@ -15,35 +15,18 @@
# 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.
-#
-# TODO make nice require after ruby-maven uses the same ruby files
-require File.join(File.dirname(File.dirname(__FILE__)), 'model', 'model.rb')
require File.join(File.dirname(__FILE__), 'gemfile_lock.rb')
require File.join(File.dirname(__FILE__), 'versions.rb')
-require File.join(File.dirname(__FILE__), 'jarfile.rb')
+require File.join(File.dirname(__FILE__), 'maven_project.rb')
module Maven
module Tools
- class ArtifactPassthrough
-
- def initialize(&block)
- @block = block
- end
-
- def add_artifact(a)
- @block.call(a)
- end
-
- def add_repository(name, url)
- end
- end
-
- class GemProject < Maven::Model::Project
+ class GemProject < MavenProject
tags :dummy
def initialize(artifact_id = dir_name, version = "0.0.0", &block)
super("rubygems", artifact_id, version, &block)
packaging "gem"
@@ -59,11 +42,11 @@
end
private :add_param
def load_gemspec(specfile)
require 'rubygems'
- if specfile.is_a? ::Gem::Specification
+ if specfile.is_a? ::Gem::Specification
spec = specfile
else
spec = ::Gem::Specification.load(specfile)
@gemspec = specfile
end
@@ -102,16 +85,16 @@
#add_param(config, "hasRdoc", spec.has_rdoc)
add_param(config, "extraRdocFiles", spec.extra_rdoc_files)
add_param(config, "rdocOptions", spec.rdoc_options)
add_param(config, "requirePaths", spec.require_paths, ["lib"])
add_param(config, "rubyforgeProject", spec.rubyforge_project)
- add_param(config, "requiredRubygemsVersion",
- spec.required_rubygems_version && spec.required_rubygems_version != ">= 0" ? "<![CDATA[#{spec.required_rubygems_version}]]>" : nil)
+ add_param(config, "requiredRubygemsVersion",
+ spec.required_rubygems_version && spec.required_rubygems_version.to_s != ">= 0" ? "<![CDATA[#{spec.required_rubygems_version}]]>" : nil)
add_param(config, "bindir", spec.bindir, "bin")
- add_param(config, "requiredRubyVersion",
- spec.required_ruby_version && spec.required_ruby_version != ">= 0" ? "<![CDATA[#{spec.required_ruby_version}]]>" : nil)
- add_param(config, "postInstallMessage",
+ add_param(config, "requiredRubyVersion",
+ spec.required_ruby_version && spec.required_ruby_version.to_s != ">= 0" ? "<![CDATA[#{spec.required_ruby_version}]]>" : nil)
+ add_param(config, "postInstallMessage",
spec.post_install_message ? "<![CDATA[#{spec.post_install_message}]]>" : nil)
add_param(config, "executables", spec.executables)
add_param(config, "extensions", spec.extensions)
add_param(config, "platform", spec.platform, 'ruby')
@@ -125,15 +108,15 @@
# files.delete("./#{f}")
# end
# end
#add_param(config, "extraFiles", files)
add_param(config, "files", spec.files)
-
+
plugin('gem').with(config) if config.size > 0
spec.dependencies.each do |dep|
- scope =
+ scope =
case dep.type
when :runtime
"compile"
when :development
"test"
@@ -170,21 +153,10 @@
add_param(config, "requirements", req)
end
end
end
- def load_mavenfile(file)
- file = file.path if file.is_a?(File)
- if File.exists? file
- @current_file = file
- content = File.read(file)
- eval content
- else
- self
- end
- end
-
def load_gemfile(file)
file = file.path if file.is_a?(File)
if File.exists? file
@current_file = file
content = File.read(file)
@@ -206,32 +178,18 @@
# cleanup versions from deps
if @lock
dependencies.each do |d|
if d.group_id == 'rubygems' && @lock.keys.member?( d.artifact_id )
- d.version = nil
+ d.version = nil
end
end
end
else
self
end
end
-
- def load_jarfile(file)
- jars = Jarfile.new(file)
- if jars.exists?
- container = ArtifactPassthrough.new do |a|
- artifactId, groupId, extension, version = a.split(/:/)
- send(extension.to_sym, "#{artifactId}:#{groupId}", version)
- end
- if !jars.exists_lock? || jars.mtime > jars.mtime_lock
- jars.populate_unlocked container
- end
- jars.populate_locked container
- end
- end
def dir_name
File.basename(File.expand_path("."))
end
private :dir_name
@@ -239,11 +197,11 @@
def add_defaults(args = {})
versions = VERSIONS
versions = versions.merge(args) if args
name "#{dir_name} - gem" unless name
-
+
packaging "gem" unless packaging
repository("rubygems-releases").url = "http://rubygems-proxy.torquebox.org/releases" unless repository("rubygems-releases").url
has_prereleases = dependencies.detect { |d| d.type.to_sym == :gem && d.version =~ /[a-zA-Z]/ }
@@ -251,11 +209,11 @@
repository("rubygems-prereleases") do |r|
r.url = "http://rubygems-proxy.torquebox.org/prereleases"
# r.releases(:enabled => false)
r.snapshots(:enabled => true)
end
- end
+ end
# TODO go through all plugins to find out any SNAPSHOT version !!
if versions[:jruby_plugins] =~ /-SNAPSHOT$/ || properties['jruby.plugins.version'] =~ /-SNAPSHOT$/
plugin_repository("sonatype-snapshots") do |nexus|
nexus.url = "http://oss.sonatype.org/content/repositories/snapshots"
@@ -278,11 +236,11 @@
j.version = versions[:jar_plugin] unless j.version
j.in_phase('prepare-package').execute_goal(:jar).with :outputDirectory => '${project.basedir}/lib', :finalName => '${project.artifactId}'
end
end
end
-
+
if @bundler_deps && @bundler_deps.size > 0
plugin(:bundler)
bdeps = []
# first get the locked gems
@bundler_deps.each do |args, dep|
@@ -296,22 +254,22 @@
end
# any unlocked gems now
@bundler_deps.each do |args, dep|
bdeps << args unless has_gem? args[0]
end
-
+
# now add the deps to bundler plugin
# avoid to setup bundler if it has no deps
- if bdeps.size > 0
+ if bdeps.size > 0
plugin(:bundler) do |bundler|
# install will be triggered on initialize phase
bundler.execution.goals << "install"
bdeps.each do |d|
bundler.gem(d)
end
-
+
# use the locked down version if available
if @lock
bundler.dependencies.each do |d|
if d.group_id == 'rubygems' && @lock.keys.member?( d.artifact_id )
d.version = @lock[ d.artifact_id ].version
@@ -342,35 +300,35 @@
add_test_plugin("minitest", "test")
add_test_plugin("minitest", "spec", 'spec')
end
self.properties = {
- "project.build.sourceEncoding" => "UTF-8",
- "gem.home" => "${project.build.directory}/rubygems",
+ "project.build.sourceEncoding" => "UTF-8",
+ "gem.home" => "${project.build.directory}/rubygems",
"gem.path" => "${project.build.directory}/rubygems",
"jruby.plugins.version" => versions[:jruby_plugins]
}.merge(self.properties)
has_plugin_gems = build.plugins.detect do |k, pl|
pl.dependencies.detect { |d| d.type.to_sym == :gem } if pl.dependencies
end
-
+
if has_plugin_gems
plugin_repository("rubygems-releases").url = "http://rubygems-proxy.torquebox.org/releases" unless plugin_repository("rubygems-releases").url
-
+
# unless plugin_repository("rubygems-prereleases").url
# plugin_repository("rubygems-prereleases") do |r|
# r.url = "http://rubygems-proxy.torquebox.org/prereleases"
# r.releases(:enabled => false)
# r.snapshots(:enabled => true)
# end
# end
end
# TODO
configs = {
- :gem => [:initialize],
- :rails3 => [:initialize, :pom],
+ :gem => [:initialize],
+ :rails3 => [:initialize, :pom],
:bundler => [:install]
}.collect do |name, goals|
if plugin?(name)
{
:pluginExecutionFilter => {
@@ -384,12 +342,12 @@
end
end
configs.delete_if { |c| c.nil? }
if configs.size > 0
build.plugin_management do |pm|
- options = {
- :lifecycleMappingMetadata => {
+ options = {
+ :lifecycleMappingMetadata => {
:pluginExecutions => Maven::Model::NamedArray.new(:pluginExecution) do |e|
# sort them - handy for testing
configs.sort {|m,n| m[:pluginExecutionFilter][:artifactId].to_s <=> n[:pluginExecutionFilter][:artifactId].to_s }.each { |c| e << c }
end
}
@@ -412,11 +370,11 @@
a.jar 'de.saumya.mojo:gem-assembly-descriptors', '${jruby.plugins.version}'
end
end
end
end
-
+
def has_gem?(gem)
self.gem?(gem)
end
def add_test_plugin(name, test_dir, goal = 'test')
@@ -434,10 +392,10 @@
def stack
@stack ||= [[:default]]
end
private :stack
-
+
def group(*args, &block)
stack << args
block.call if block
stack.pop
end