The Maven archetype for Tapestry projects is really useful for getting up and running quickly.
However, that's not what I use day-to-day. That command line is so long and ugly!
I use the following Ruby script as a wrapper around Maven:
#!/usr/bin/ruby require 'optparse' $group = nil $artifact = nil $package = nil $archetypeVersion = nil $version = "1.0.0-SNAPSHOT" $offline = false $opts = OptionParser.new do |opts| opts.banner = "Usage: new-project.rb [options]" opts.on("-g", "--group GROUP", "The group id for the new project") do |value| $group = value end opts.on("-a", "--artifact ARTIFACT", "The artifact for the new project") do |value| $artifact = value end opts.on("-p", "--package PACKAGE", "The root package for source code in the new project") do |value| $package = value end opts.on("-v", "--version VERSION", "The version number of the new project") do |value| $version = value end opts.on("-o", "--offline", "Execute Maven in offline mode") { $offline = true } opts.on("-V", "--archetype-version VERSION", "Version of the Tapestry quickstart archetype") do |value| $archetypeVersion = value end opts.on("-h", "--help", "Help for this command") do puts opts exit end end def fail(message) puts "Error: #{message}" puts $opts exit end begin $opts.parse! rescue OptionParser::InvalidOption fail $! end fail "Unexpected command line argument" if ARGV.length > 0 fail "Must specify group" unless $group fail "Must specify artifact" unless $artifact $package = $package || "#$group.#$artifact" command = ["mvn"] command << "-o" if $offline command << [ "archetype:create", "-DarchetypeGroupId=org.apache.tapestry", "-DarchetypeArtifactId=quickstart", "-DgroupId=#$group", "-DartifactId=#$artifact", "-DartifactVersion=#$version", "-DpackageName=#$package"] if $archetypeVersion command << "-DarchetypeVersion=#$archetypeVersion" end command = command.join ' ' exec command
A typical usage is thus: new-project -g com.example -a myapp
... and we're off and running.
Hi
ReplyDeleteI am interested to use tapestry-ioc in application server ... Can we have a maven quickstart archetype to create JavaEE project based only on tapestry-ioc ? Or indicate which existing maven archetype can do the job? I am not really versed in maven ! Thanks.