jetty-run 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +67 -7
- data/bin/jetty-run +21 -66
- data/bin/jetty-run~ +80 -27
- data/lib/jetty-run.rb +20 -0
- data/lib/jetty_run.rb +20 -0
- data/lib/maven/jetty/Mavenfile +15 -0
- data/lib/maven/jetty/Mavenfile~ +11 -0
- data/lib/maven/jetty/cli.rb +34 -0
- data/lib/maven/jetty/cli.rb~ +52 -0
- data/lib/maven/jetty/jetty_project.rb +127 -0
- data/lib/maven/jetty/jetty_project.rb~ +69 -0
- data/lib/maven/jetty/override-rack-web.xml +31 -0
- data/lib/maven/jetty/override-rack-web.xml~ +19 -0
- data/lib/maven/jetty/override-rails-developement-web.xml~ +19 -0
- data/lib/maven/jetty/override-rails-development-web.xml +39 -0
- data/lib/maven/jetty/override-rails-production-web.xml +39 -0
- data/lib/maven/jetty/override-rails-production-web.xml~ +19 -0
- data/lib/maven/jetty/pom_magic.rb +89 -0
- data/lib/maven/jetty/pom_magic.rb~ +103 -0
- data/lib/maven/jetty/rack-web.xml +68 -0
- data/lib/maven/jetty/{web.xml → rack-web.xml~} +0 -0
- data/lib/maven/jetty/{rails_project.rb → rack_project.rb~} +0 -0
- data/lib/maven/jetty/rails-web.xml +68 -0
- data/lib/maven/jetty/rails-web.xml~ +48 -0
- data/lib/maven/jetty/server.keystore +0 -0
- data/lib/maven/jetty/version.rb +21 -1
- metadata +139 -77
- data/lib/maven/jetty/ruby_maven.rb +0 -24
data/README.md
CHANGED
@@ -1,15 +1,75 @@
|
|
1
|
-
# jetty run
|
1
|
+
# jetty run
|
2
2
|
|
3
|
-
|
3
|
+
* [![Build Status](https://secure.travis-ci.org/mkristian/jetty-run.png)](http://travis-ci.org/mkristian/jetty-run)
|
4
|
+
* [![Dependency Status](https://gemnasium.com/mkristian/jetty-run.png)](https://gemnasium.com/mkristian/jetty-run)
|
5
|
+
* [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/mkristian/jetty-run)
|
4
6
|
|
5
|
-
jetty will start with port 8080 (none ssl) and 8443 (ssl). the ssl certificate is ./src/test/resources/server.keystore with password '123456' - it will be copied there on the first run.
|
6
7
|
|
7
|
-
|
8
|
+
## install ##
|
8
9
|
|
9
|
-
|
10
|
+
first uninstall older ruby-maven (< 3.0.4.0.29.0) if present, they will otherwise conflict with jetty-run command
|
10
11
|
|
11
|
-
|
12
|
+
$ gem uninstall ruby-maven
|
13
|
+
$ gem install jetty-run
|
12
14
|
|
15
|
+
## usage ##
|
16
|
+
|
17
|
+
$ cd my_rails_app
|
18
|
+
$ jruby -S bundle install #optional
|
19
|
+
$ jetty-run
|
20
|
+
|
21
|
+
or for a rack application (assuming existiing config.ru)
|
22
|
+
|
23
|
+
$ cd my_rack_app
|
24
|
+
$ jruby -S bundle install #optional
|
25
|
+
$ jetty-run
|
26
|
+
|
27
|
+
regarding `bundle install`: it must work wth JRuby since JRuby is the runtime environment. but `bundle install` since jetty-run will resolve a valid gemset itself and creates a Gemfile.lock (with the help of bundler). in short; all gems must be for the java platform or you need to provide jruby alternative gems.
|
28
|
+
|
29
|
+
`jetty-run` works with both MRI and JRuby - MRI starts up slightly faster BUT **uses JRuby** when running the applicaton.
|
30
|
+
|
31
|
+
jetty-run will use Gemfile/Gemfile.lock and Jarfile/Jarfile.lock to setup an environment to start rails in development mode with jetty. it uses ruby-maven to achieve this, i.e. all missing jar dependencies (jetty itself and all its dependences) will be downloaded on the first run (that can take time since it first needs to download all the jars).
|
32
|
+
|
33
|
+
jetty will start with port 8080 (none ssl) and 8443 (ssl). the ssl certificate is ./target/server.keystore with password '123456'.
|
34
|
+
|
35
|
+
to customize jetty you can use the _Mavenfile_ which allows to reconfigure jetty-maven-plugin, i.e. the version of jetty
|
36
|
+
|
37
|
+
properties['jetty.version'] = '7.5.1.v20110908'
|
38
|
+
|
39
|
+
or you pass it in via the command line
|
40
|
+
|
41
|
+
$ jetty-run -- -Djetty.version=7.5.1.v20110908
|
42
|
+
|
43
|
+
**--** is used a separator after which you can use any maven open available. like `-- -X` gives you a complete maven debug output, etc.
|
44
|
+
|
45
|
+
## running any given war-file ##
|
46
|
+
|
47
|
+
jetty-run war /path/to/war-file
|
48
|
+
|
49
|
+
with this you can `warble` your warfile and use `jetty-run` to start it with jetty.
|
50
|
+
|
51
|
+
## more ##
|
52
|
+
|
53
|
+
see
|
54
|
+
|
55
|
+
jetty-run help
|
56
|
+
|
13
57
|
# note #
|
14
58
|
|
15
|
-
|
59
|
+
orginally the code was part the jruby-maven-plugins and slowly the functionality moved to the ruby side of things. so things are on the move and there is room for improvements . . .
|
60
|
+
|
61
|
+
contributing
|
62
|
+
------------
|
63
|
+
|
64
|
+
1. fork it
|
65
|
+
2. create your feature branch (`git checkout -b my-new-feature`)
|
66
|
+
3. commit your changes (`git commit -am 'Added some feature'`)
|
67
|
+
4. push to the branch (`git push origin my-new-feature`)
|
68
|
+
5. create new Pull Request
|
69
|
+
|
70
|
+
meta-fu
|
71
|
+
-------
|
72
|
+
|
73
|
+
bug-reports and pull request are most welcome. otherwise
|
74
|
+
|
75
|
+
enjoy :)
|
data/bin/jetty-run
CHANGED
@@ -1,62 +1,39 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# puts "usage: #{File.basename($0)} [-e <environment>] [--war [<path/to/warfile>]]"
|
4
|
-
# puts "\tdefault environment: development"
|
5
|
-
# exit 1
|
6
|
-
# end
|
7
|
-
|
8
|
-
# args = [__FILE__.gsub(/-/, ':').gsub(/.*[\/\\]/, '')]
|
9
|
-
# if ARGV.size == 2 && ARGV[0] == "-e"
|
10
|
-
# args << "-Drails.env=#{ARGV[1]}"
|
11
|
-
# args << "-Prun"
|
12
|
-
# elsif ARGV.size == 1 && ARGV[0] == "--war"
|
13
|
-
# args = ["jetty:run-war", "-Pwar"]
|
14
|
-
# elsif ARGV.size == 2 && ARGV[0] == "--war"
|
15
|
-
# args = ["jetty:deploy-war", "-DwebApp=#{ARGV[1]}", "-Pwar"]
|
16
|
-
# elsif ARGV.size == 3 && ARGV[0] == "-e" && ARGV[2] == "--war"
|
17
|
-
# args = ["jetty:run-war", "-Pwar", "-Drails.env=#{ARGV[1]}"]
|
18
|
-
# elsif ARGV.size == 3 && ARGV[1] == "-e" && ARGV[0] == "--war"
|
19
|
-
# args = ["jetty:run-war", "-Pwar", "-Drails.env=#{ARGV[2]}"]
|
20
|
-
# elsif ARGV.size == 4 && ARGV[0] == "-e" && ARGV[2] == "--war"
|
21
|
-
# args = ["jetty:deploy-war", "-Pwar", "-DwebApp=#{ARGV[3]}", "-Drails.env=#{ARGV[1]}"]
|
22
|
-
# elsif ARGV.size == 4 && ARGV[2] == "-e" && ARGV[0] == "--war"
|
23
|
-
# args = ["jetty:deploy-war", "-Pwar", "-DwebApp=#{ARGV[1]}", "-Drails.env=#{ARGV[3]}"]
|
24
|
-
# end
|
25
|
-
# ARGV.replace(args)
|
26
|
-
# if !File.exists?(File.join('config', 'web.xml')) && !File.exists?(File.join('src', 'main', 'webapp', 'WEB-INF', 'web.xml'))
|
27
|
-
# require 'fileutils'
|
28
|
-
# web_xml = Gem.find_files( 'maven/jetty/web.xml').first
|
29
|
-
# FileUtils.cp(web_xml, 'config')
|
30
|
-
# end
|
31
|
-
# load Gem.bin_path('ruby-maven', 'rmvn')
|
32
|
-
|
33
|
-
|
34
|
-
require 'maven/jetty/ruby_maven'
|
2
|
+
require 'maven/jetty/cli'
|
35
3
|
require 'thor'
|
36
4
|
|
37
5
|
class JettyCommand < Thor
|
38
6
|
no_tasks do
|
39
7
|
def mvn
|
40
|
-
@mvn ||= Maven::Jetty::
|
8
|
+
@mvn ||= Maven::Jetty::Cli.new
|
41
9
|
end
|
42
10
|
|
43
11
|
def exec(*args)
|
44
12
|
ARGV.clear # clean up in case another script gets executed
|
45
13
|
mvn.exec(args)
|
46
14
|
end
|
15
|
+
|
16
|
+
def maven_args
|
17
|
+
args = ARGV.dup
|
18
|
+
if i = args.index("--")
|
19
|
+
maven_args = args[i..-1]
|
20
|
+
end
|
21
|
+
maven_args ||= []
|
22
|
+
if options[ :pom ]
|
23
|
+
maven_args << '--pom'
|
24
|
+
maven_args << options[ :pom ]
|
25
|
+
end
|
26
|
+
maven_args
|
27
|
+
end
|
47
28
|
end
|
48
29
|
|
49
|
-
desc "[run]", "runs jetty with
|
50
|
-
method_option :environment, :aliases => '-e', :type => :string, :required => false, :desc => 'rails environment'
|
30
|
+
desc "[run]", "runs jetty with either rails filesystem layout or with config.ru"
|
31
|
+
method_option :environment, :aliases => '-e', :type => :string, :required => false, :desc => 'rails environment (no effect on rackup setups)'
|
51
32
|
method_option :port, :type => :numeric, :default => 8080, :desc => 'http port'
|
52
33
|
method_option :sslport, :type => :numeric, :default => 8443, :desc => 'https port'
|
34
|
+
method_option :pom, :type => :string, :default => '.jetty-pom.xml', :desc => 'name of pom file which get generated (jetty-run just generates a pom.xml which gets execued by maven)'
|
53
35
|
def server(*args)
|
54
|
-
|
55
|
-
args.delete('server')
|
56
|
-
if i = args.index("--")
|
57
|
-
maven_args = args[i..-1]
|
58
|
-
end
|
59
|
-
maven_args ||= []
|
36
|
+
maven_args = self.maven_args
|
60
37
|
maven_args << "-Drails.env=#{options[:environment]}" if options[:environment]
|
61
38
|
maven_args << "-Djetty.port=#{options[:port]}"
|
62
39
|
maven_args << "-Djetty.sslport=#{options[:sslport]}"
|
@@ -67,18 +44,14 @@ class JettyCommand < Thor
|
|
67
44
|
method_option :port, :type => :numeric, :default => 8080, :desc => 'http port'
|
68
45
|
method_option :sslport, :type => :numeric, :default => 8443, :desc => 'https port'
|
69
46
|
def war(file, *args)
|
70
|
-
|
71
|
-
if i = args.index("--")
|
72
|
-
maven_args = args[i..-1]
|
73
|
-
end
|
74
|
-
maven_args ||= []
|
47
|
+
maven_args = self.maven_args
|
75
48
|
maven_args << "-Djetty.war=#{file}"
|
76
49
|
maven_args << "-Djetty.port=#{options[:port]}"
|
77
50
|
maven_args << "-Djetty.sslport=#{options[:sslport]}"
|
78
51
|
exec(*(["jetty:deploy-war", "-Pwar"] + maven_args))
|
79
52
|
end
|
80
53
|
|
81
|
-
desc "pom", "dump the pom
|
54
|
+
desc "pom", "dump the jetty pom into pom.xml"
|
82
55
|
method_option :force, :type => :boolean, :default => false, :desc => 'force to overwrite pom.xml'
|
83
56
|
def pom(*args)
|
84
57
|
if File.exists?('pom.xml') && !options[:force]
|
@@ -87,28 +60,10 @@ class JettyCommand < Thor
|
|
87
60
|
mvn.dump_pom(options[:force])
|
88
61
|
end
|
89
62
|
end
|
90
|
-
|
91
|
-
def help(*args)
|
92
|
-
super(*args)
|
93
|
-
goal =
|
94
|
-
case args[0]
|
95
|
-
when 'server'
|
96
|
-
'run'
|
97
|
-
when 'war'
|
98
|
-
'deploy-war'
|
99
|
-
end
|
100
|
-
if goal
|
101
|
-
puts
|
102
|
-
puts "Maven Options: (from jetty maven plugin)"
|
103
|
-
exec ["jetty:help", "-Ddetail=true", "-Dgoal=#{goal}"]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
63
|
end
|
108
64
|
if i = ARGV.index('run')
|
109
65
|
ARGV[i] = 'server'
|
110
66
|
end
|
111
|
-
#p ARGV.detect {|a| p a ;a =~ /^[a-z]/ }
|
112
67
|
unless ARGV[0] =~ /^[a-z]/
|
113
68
|
ARGV.insert(0, 'server')
|
114
69
|
end
|
data/bin/jetty-run~
CHANGED
@@ -1,31 +1,84 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
require 'maven/jetty/ruby_maven'
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
class JettyCommand < Thor
|
6
|
+
no_tasks do
|
7
|
+
def mvn
|
8
|
+
@mvn ||= Maven::Jetty::RubyMaven.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def exec(*args)
|
12
|
+
ARGV.clear # clean up in case another script gets executed
|
13
|
+
mvn.exec(args)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "[run]", "runs jetty with a rails filesystem layout"
|
18
|
+
method_option :environment, :aliases => '-e', :type => :string, :required => false, :desc => 'rails environment'
|
19
|
+
method_option :port, :type => :numeric, :default => 8080, :desc => 'http port'
|
20
|
+
method_option :sslport, :type => :numeric, :default => 8443, :desc => 'https port'
|
21
|
+
def server(*args)
|
22
|
+
args = ARGV.dup
|
23
|
+
args.delete('server')
|
24
|
+
if i = args.index("--")
|
25
|
+
maven_args = args[i..-1]
|
26
|
+
end
|
27
|
+
maven_args ||= []
|
28
|
+
maven_args << "-Drails.env=#{options[:environment]}" if options[:environment]
|
29
|
+
maven_args << "-Djetty.port=#{options[:port]}"
|
30
|
+
maven_args << "-Djetty.sslport=#{options[:sslport]}"
|
31
|
+
exec(*(["jetty:run", "-Prun"] + maven_args))
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "war WARFILE", "runs jetty with a given warfile"
|
35
|
+
method_option :port, :type => :numeric, :default => 8080, :desc => 'http port'
|
36
|
+
method_option :sslport, :type => :numeric, :default => 8443, :desc => 'https port'
|
37
|
+
def war(file, *args)
|
38
|
+
args = ARGV.dup
|
39
|
+
if i = args.index("--")
|
40
|
+
maven_args = args[i..-1]
|
41
|
+
end
|
42
|
+
maven_args ||= []
|
43
|
+
maven_args << "-Djetty.war=#{file}"
|
44
|
+
maven_args << "-Djetty.port=#{options[:port]}"
|
45
|
+
maven_args << "-Djetty.sslport=#{options[:sslport]}"
|
46
|
+
exec(*(["jetty:deploy-war", "-Pwar"] + maven_args))
|
47
|
+
end
|
7
48
|
|
8
|
-
|
9
|
-
|
10
|
-
args
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
49
|
+
desc "pom", "dump the pom used into pom.xml"
|
50
|
+
method_option :force, :type => :boolean, :default => false, :desc => 'force to overwrite pom.xml'
|
51
|
+
def pom(*args)
|
52
|
+
if File.exists?('pom.xml') && !options[:force]
|
53
|
+
warn "abort. pom.xml already exist. use --force to overwrite"
|
54
|
+
else
|
55
|
+
mvn.dump_pom(options[:force])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def help(*args)
|
60
|
+
super(*args)
|
61
|
+
goal =
|
62
|
+
case args[0]
|
63
|
+
when 'server'
|
64
|
+
'run'
|
65
|
+
when 'war'
|
66
|
+
'deploy-war'
|
67
|
+
end
|
68
|
+
# TODO not sure whether or not these options are needed/helpful
|
69
|
+
# if goal
|
70
|
+
# puts
|
71
|
+
# puts "Maven Options: (from jetty maven plugin)"
|
72
|
+
# exec ["jetty:help", "-Ddetail=true", "-Dgoal=#{goal}"]
|
73
|
+
# end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
if i = ARGV.index('run')
|
78
|
+
ARGV[i] = 'server'
|
24
79
|
end
|
25
|
-
ARGV.
|
26
|
-
|
27
|
-
|
28
|
-
web_xml = Gem.find_files( 'maven/jetty/web.xml').first
|
29
|
-
FileUtils.cp(web_xml, 'config')
|
80
|
+
#p ARGV.detect {|a| p a ;a =~ /^[a-z]/ }
|
81
|
+
unless ARGV[0] =~ /^[a-z]/
|
82
|
+
ARGV.insert(0, 'server')
|
30
83
|
end
|
31
|
-
|
84
|
+
JettyCommand.start
|
data/lib/jetty-run.rb
CHANGED
@@ -1 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
1
21
|
require 'jetty_run'
|
data/lib/jetty_run.rb
CHANGED
@@ -1 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
1
21
|
require 'maven/jetty/version'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#-*- mode: ruby -*-
|
2
|
+
|
3
|
+
jar("org.jruby.rack:jruby-rack", '1.1.13.1')
|
4
|
+
if defined?( JRUBY_VERSION ) && JRUBY_VERSION =~ /^1\.7\./
|
5
|
+
jar("org.jruby:jruby-core", "${jruby.version}")
|
6
|
+
else
|
7
|
+
jar("org.jruby:jruby-complete", "${jruby.version}")
|
8
|
+
end
|
9
|
+
|
10
|
+
# lock down versions
|
11
|
+
properties['jruby.version'] = '1.7.3'
|
12
|
+
properties['jruby.plugins.version'] = '0.29.4'
|
13
|
+
properties['jetty.version'] = '8.1.9.v20130131'
|
14
|
+
|
15
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#-*- mode: ruby -*-
|
2
|
+
|
3
|
+
jar("org.jruby:jruby-complete", "1.7.2")
|
4
|
+
jar("org.jruby.rack:jruby-rack", '1.1.13.1')
|
5
|
+
|
6
|
+
# lock down versions
|
7
|
+
properties['jetty.version'] =
|
8
|
+
properties['jruby.version'] = '1.7.2'
|
9
|
+
properties['jruby.plugins.version'] = '0.29.3'
|
10
|
+
|
11
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'maven/ruby/cli'
|
22
|
+
require 'maven/jetty/pom_magic'
|
23
|
+
|
24
|
+
module Maven
|
25
|
+
module Jetty
|
26
|
+
class Cli < Maven::Ruby::Cli
|
27
|
+
|
28
|
+
def magic_pom( dir = '.', *args )
|
29
|
+
PomMagic.new.generate_pom( File.expand_path( dir ), *args )
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'ruby_maven'
|
2
|
+
require 'maven/jetty/rails_project'
|
3
|
+
|
4
|
+
module Maven
|
5
|
+
module Jetty
|
6
|
+
class Cli < Maven::Ruby::Cli
|
7
|
+
|
8
|
+
def magic_pom(dir = '.', *args)
|
9
|
+
|
10
|
+
if File.exists? File.join( 'config', 'application.rb' )
|
11
|
+
ensure_web_xml( dir, "rails" )
|
12
|
+
else
|
13
|
+
ensure_web_xml( dir, "rack" )
|
14
|
+
end
|
15
|
+
|
16
|
+
proj = JettyProject.new
|
17
|
+
proj.load_gemspec( first_gemspec( dir ) )
|
18
|
+
proj.load_gemfile( file( dir, 'Gemfile' ) )
|
19
|
+
proj.load_jarfile( file( dir, 'Jarfile' ) )
|
20
|
+
proj.load_gemfile( file( dir, 'Mavenfile' ) )
|
21
|
+
proj.add_defaults( :jruby_plugins => JRUBY_MAVEN_PLUGINS_VERSION )
|
22
|
+
pom = pom_xml(dir)
|
23
|
+
File.open(pom, 'w') do |f|
|
24
|
+
f.puts proj.to_xml
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def ensure_web_xml( dir = '.', flavour )
|
29
|
+
if !File.exists?(File.join( dir, 'config', 'web.xml')) && !File.exists?(File.join(dir, 'src', 'main', 'webapp', 'WEB-INF', 'web.xml'))
|
30
|
+
web_xml = Gem.find_files( "maven/jetty/#{flavour}-web.xml" ).first
|
31
|
+
FileUtils.cp(web_xml, 'config/web.xml')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def first_gemspec( dir = '.' )
|
36
|
+
gemspecs = Dir[ File.join( dir, "*.gemspec" ) ]
|
37
|
+
if gemspecs.size > 0
|
38
|
+
File.expand_path( gemspecs[ 0 ] )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def file( name, dir = '.' )
|
43
|
+
File.expand_path( File.join( dir, name ) )
|
44
|
+
end
|
45
|
+
|
46
|
+
def pom_xml( dir = '.' )
|
47
|
+
File.join( dir, ".pom.xml" )
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|