Skip to content

Instantly share code, notes, and snippets.

@wjrogers
Created February 26, 2010 16:26
Show Gist options
  • Save wjrogers/315869 to your computer and use it in GitHub Desktop.
Save wjrogers/315869 to your computer and use it in GitHub Desktop.
require 'nokogiri'
# Standard maven2 repository
repositories.remote << 'http://www.ibiblio.org/maven2'
repositories.remote << 'http://www.terracotta.org/download/reflector/maven2'
# constants?
GERONIMO_ACTIVEMQ_RA = 'org.apache.geronimo.modules:geronimo-activemq-ra:rar:2.2'
# the project
desc 'project description'
define 'project-name' do
project.group = 'group'
project.version = '1.1'
compile.with [
'commons-httpclient:commons-httpclient:jar:3.0.1',
'commons-lang:commons-lang:jar:2.4',
'commons-logging:commons-logging:jar:1.1.1',
'org.apache.activemq:activemq-core:jar:5.3.0',
'org.apache.geronimo.framework:geronimo-kernel:jar:2.2',
'org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1',
'org.apache.geronimo.specs:geronimo-ejb_3.0_spec:jar:1.0.1',
'org.apache.geronimo.specs:geronimo-annotation_1.0_spec:jar:1.1.1',
GERONIMO_ACTIVEMQ_RA,
'org.apache.xmlbeans:xmlbeans:jar:2.4.0',
'org.quartz-scheduler:quartz:jar:1.7.2',
'log4j:log4j:jar:1.2.14',
artifact('com.microsoft:sqljdbc4:jar:2.0').from(file 'lib/sqljdbc4.jar'),
]
package(:ear)
package(:ear).add GERONIMO_ACTIVEMQ_RA, :path => ''
package(:ear).add :ejb => package(:jar)
# monkey-patch EarTask to generate a working application.xml
class << package(:ear)
def descriptor_xml
original = Nokogiri::XML(super) { |op| op.noblanks }
builder = Nokogiri::XML::Builder.with(original.at 'application') do |xml|
# insert the connector archive declaration
xml.module {
xml.connector Artifact.hash_to_file_name(Artifact.to_hash GERONIMO_ACTIVEMQ_RA)
}
end
builder.to_xml
end
end
# generate the geronimo-application.xml
gax = GeronimoApplicationXml.define_task _(:target, 'geronimo-application.xml')
gax.project = self
package(:ear).enhance [ gax ]
package(:ear).include gax, :path => 'META-INF'
end
class GeronimoApplicationXml < Rake::FileTask
attr_accessor :project
def initialize(*args)
super
enhance do |task|
File.open(task.name, 'wb') { |f| f.write task.xml }
end
end
def xml
@xml ||= geronimo_application_xml
end
def needed?
super || xml != File.read(self.to_s) rescue true
end
def geronimo_application_xml
builder = Nokogiri::XML::Builder.new do |xml|
# lots of boring XML generation
end
builder.to_xml
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment