Diff
Modified: trunk/rails-integration/plugins/goldspike-snapshot/lib/create_war.rb (583 => 584)
--- trunk/rails-integration/plugins/goldspike-snapshot/lib/create_war.rb 2007-05-13 12:30:18 UTC (rev 583)
+++ trunk/rails-integration/plugins/goldspike-snapshot/lib/create_war.rb 2007-05-13 12:32:50 UTC (rev 584)
@@ -9,6 +9,7 @@
require 'java_library'
require 'war_config'
require 'packer'
+require 'util'
module War
class Creator
@@ -46,7 +47,7 @@
end
def assemble
- puts 'Assembling web application'
+ WLog.info 'Assembling web application'
add_java_libraries
if config.standalone
add_ruby_libraries
@@ -57,7 +58,7 @@
private
def create_war
- puts 'Creating web archive'
+ WLog.info 'Creating web archive'
@webapp_packer.create_war
end
Modified: trunk/rails-integration/plugins/goldspike-snapshot/lib/java_library.rb (583 => 584)
--- trunk/rails-integration/plugins/goldspike-snapshot/lib/java_library.rb 2007-05-13 12:30:18 UTC (rev 583)
+++ trunk/rails-integration/plugins/goldspike-snapshot/lib/java_library.rb 2007-05-13 12:32:50 UTC (rev 584)
@@ -4,18 +4,25 @@
# + An artifact in a local maven repo: ~/.m2/repository/org/jruby/jruby/0.9.1/jruby-0.9.1/jar
# + An artifact in a remote maven repo: http://www.ibiblio.com/maven2/org/jruby/jruby/0.9.1/jruby-0.9.1/jar
#
+require 'util'
+
module War
class JavaLibrary
- attr_accessor :artifact, :version, :locations
+ attr_accessor :artifact, :version, :locations, :config
- def initialize(artifact, version, locations)
+ def initialize(artifact, version, config)
+ WLog.debug("intializing library " + artifact)
+ @config = config
@artifact = artifact
@version = version
+ check_locations = local_locations(name, version)
+
if locations.is_a?(String)
- locations = [ locations ]
- end
- @locations = locations
+ locations = [ locations ]
+ end
+ check_locations += locations
+ @locations = check_locations
end
def file
@@ -80,5 +87,50 @@
def to_s
"#{artifact}-#{version}"
end
+
+
+ def local_locations(artifact, version, type='jar')
+ WLog.debug("locations for " + artifact + " " + version);
+ paths = []
+ if config.local_java_lib
+ paths << File.join(local_java_lib, "#{artifact}-#{version}.#{type}")
+ paths << File.join(local_java_lib, "#{artifact}.#{type}")
+ end
+ if config.jruby_home
+ paths << File.join(jruby_home, 'lib', "#{artifact}-#{version}.#{type}")
+ paths << File.join(jruby_home, 'lib', "#{artifact}.#{type}")
+ end
+ WLog.debug("paths: " + paths.join("\n"))
+ return paths
+ end
+
end #class
+
+ class MavenLibrary < JavaLibrary
+
+ attr_accessor :group, :name, :version, :config
+
+ def initialize (group, name, version, config)
+ @config = config
+ @group = group
+ @locations = maven_locations(group, name, version)
+ end
+
+ def maven_locations(group, artifact, version, type='jar')
+ paths = []
+ maven_local_repository = config.maven_local_repository
+ maven_remote_repository = config.maven_remote_repository
+ if maven_local_repository
+ paths << File.join(maven_local_repository, group.gsub('.', File::SEPARATOR), artifact, version, "#{artifact}-#{version}.#{type}")
+ end
+ if maven_remote_repository
+ paths << "#{maven_remote_repository}/#{group.gsub('.', '/')}/#{artifact}/#{version}/#{artifact}-#{version}.#{type}"
+ end
+ return paths
+ end
+
+ end
+
+
+
end #module
\ No newline at end of file
Modified: trunk/rails-integration/plugins/goldspike-snapshot/lib/packer.rb (583 => 584)
--- trunk/rails-integration/plugins/goldspike-snapshot/lib/packer.rb 2007-05-13 12:30:18 UTC (rev 583)
+++ trunk/rails-integration/plugins/goldspike-snapshot/lib/packer.rb 2007-05-13 12:32:50 UTC (rev 584)
@@ -1,4 +1,6 @@
+require 'util'
+
module War
class Packer
@@ -23,7 +25,7 @@
if File.directory?(f)
File.makedirs(target_file)
elsif File.file?(f)
- # puts " Copying #{f} to #{relative}"
+ WLog.debug " Copying #{f} to #{relative}"
File.makedirs(File.dirname(target_file))
install(f, target_file)
end
@@ -70,7 +72,7 @@
for library in config.java_libraries.values
target = File.join(lib, library.file)
unless File.exists?(target)
- puts " Adding Java library #{library}"
+ WLog.info " Adding Java library #{library}"
library.install(config, target)
end
end
Modified: trunk/rails-integration/plugins/goldspike-snapshot/lib/war_config.rb (583 => 584)
--- trunk/rails-integration/plugins/goldspike-snapshot/lib/war_config.rb 2007-05-13 12:30:18 UTC (rev 583)
+++ trunk/rails-integration/plugins/goldspike-snapshot/lib/war_config.rb 2007-05-13 12:32:50 UTC (rev 584)
@@ -3,7 +3,11 @@
# By Robert Egglestone
# Fausto Lelli
#
+require 'util'
+
module War
+
+
class Configuration
include Singleton
@@ -56,6 +60,8 @@
attr_accessor :jetty_java_opts
def initialize
+
+ WLog.debug("initializing configuration")
# default internal locations
@staging = RAILS_ROOT
@excludes = []
@@ -153,17 +159,16 @@
end
end
- def java_library(name, version, locations)
+ def java_library(name, version)
+ WLog.debug("defining java library : " + name + " " + version)
# check local sources first, then the list
- check_locations = local_locations(name, version)
- locations = [ locations ] if locations.is_a?(String)
- check_locations += locations
- JavaLibrary.new(name, version, check_locations)
+ JavaLibrary.new(name, version, self)
end
def maven_library(group, name, version)
- locations = maven_locations(group, name, version)
- java_library(name, version, locations)
+ WLog.debug("defining maven library : " + group + " " + name + " " + version)
+ #locations = maven_locations(group, name, version)
+ MavenLibrary.new(group, name, version, self)
end
def add_java_library(lib)
@@ -182,30 +187,7 @@
@gem_libraries.delete(name)
end
- def local_locations(artifact, version, type='jar')
- paths = []
- if local_java_lib
- paths << File.join(local_java_lib, "#{artifact}-#{version}.#{type}")
- paths << File.join(local_java_lib, "#{artifact}.#{type}")
- end
- if jruby_home
- paths << File.join(jruby_home, 'lib', "#{artifact}-#{version}.#{type}")
- paths << File.join(jruby_home, 'lib', "#{artifact}.#{type}")
- end
- return paths
- end
-
- def maven_locations(group, artifact, version, type='jar')
- paths = []
- if maven_local_repository
- paths << File.join(maven_local_repository, group.gsub('.', File::SEPARATOR), artifact, version, "#{artifact}-#{version}.#{type}")
- end
- if maven_remote_repository
- paths << "#{maven_remote_repository}/#{group.gsub('.', '/')}/#{artifact}/#{version}/#{artifact}-#{version}.#{type}"
- end
- return paths
- end
-
+
# This class is responsable for loading the war.rb dsl and parsing it to
# evaluated War::Configuration
# <note>will need to readjust this package impl </note>
@@ -262,8 +244,8 @@
end
def add_gem(*val)
- puts "Warning: add_gem takes at most two arguments" if val.size > 2
- @result.add_gem(val[0], val[1])
+ puts "Warning: add_gem takes at most two arguments" if val.size > 2
+ @result.add_gem(val[0], val[1])
end
def datasource_jndi(*val)
@@ -276,15 +258,15 @@
end
def datasource_jndi_name(*val)
- puts "Warning: datasource_jndi_name takes at most one argument" if val.size > 1
- @result.datasource_jndi_name = val[0]
+ puts "Warning: datasource_jndi_name takes at most one argument" if val.size > 1
+ @result.datasource_jndi_name = val[0]
end
# method hook for library property
def include_library(name, properties)
if properties == nil or properties[:version] == nil or properties[:locations] == nil
- puts "Warning: in library #{name}, 'version' and 'locations' specifications are mandatory"
- return
+ puts "Warning: in library #{name}, 'version' and 'locations' specifications are mandatory"
+ return
end
begin
@result.add_java_library(@result.java_library(name, properties[:version], properties[:locations]))