One thing with building lots of demos for upcoming presentations, labs, & etc. is that I'm having to use mvn archetype:create a lot and that command line is just hideous.
So I took a deep breath, stepped back, and wrote a Ruby script, newproj to simplify the process:
#!/usr/bin/ruby
require 'getoptlong'
opts = GetoptLong.new(
[ "--group", "-g", GetoptLong::REQUIRED_ARGUMENT ],
[ "--artifact", "-a", GetoptLong::REQUIRED_ARGUMENT ],
[ "--package", "-p", GetoptLong::OPTIONAL_ARGUMENT ],
[ "--version", "-v", GetoptLong::OPTIONAL_ARGUMENT ]
)
group = nil
artifact = nil
package = nil
version = "1.0.0-SNAPSHOT"
error = false
begin
opts.each do | opt, arg |
case opt
when "--group"
group = arg
when "--artifact"
artifact = arg
when "--package"
package = arg
when "--version"
version = arg
end
end
rescue GetoptLong::Error
error = true
end
if error || ARGV.length != 0 || group == nil || artifact == nil
puts "newproj: --group groupId --artifact arifactId [--package package] [--version version]"
exit 0
end
package = package || "#{group}.#{artifact}"
command = "mvn archetype:create -DarchetypeGroupId=org.apache.tapestry -DarchetypeArtifactId=quickstart -DarchetypeVersion=5.0.3"
command << " -DgroupId=#{group} -DartifactId=#{artifact} -DpackageName=#{package} -Dversion=#{version}"
puts command
Kernel::exec(command)
I'll eventually add to this; it needs the option to control the mvn -o (offline) flag, and further in the future, the ability to choose the correct archetype (once we add more than just quickstart). But this sure beats copying and pasting out of the documentation, like I've been doing.
Why don't you just create a script or bat file like this?
ReplyDeletemvn archetype:create -DarchetypeGroupId=org.apache.tapestry -DarchetypeArtifactId=quickstart -DarchetypeVersion=5.0.3 -DgroupId=$group -DartifactId=$artifact -DpackageName=$package -Dversion=$version
Good point, Christopher.
ReplyDeleteAlso, Id and Contribute need to be removed from the AppModule file. Looks like they've removed from tapestry-ioc.
I've updated this further and added it to the project: new-project.rb
ReplyDelete