gwt-run 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +47 -0
  3. data/bin/gwt +98 -0
  4. data/bin/gwt~ +97 -0
  5. data/bin/jetty-run~ +84 -0
  6. data/lib/gwt-run.rb +21 -0
  7. data/lib/gwt-run.rb~ +1 -0
  8. data/lib/gwt_run.rb +21 -0
  9. data/lib/gwt_run.rb~ +1 -0
  10. data/lib/jetty-run.rb~ +1 -0
  11. data/lib/jetty_run.rb~ +1 -0
  12. data/lib/maven/gwt/Mavenfile +68 -0
  13. data/lib/maven/gwt/Mavenfile~ +62 -0
  14. data/lib/maven/gwt/cli.rb +34 -0
  15. data/lib/maven/gwt/cli.rb~ +14 -0
  16. data/lib/maven/gwt/generator.rb +86 -0
  17. data/lib/maven/gwt/generator.rb~ +62 -0
  18. data/lib/maven/gwt/jetty_project.rb~ +69 -0
  19. data/lib/maven/gwt/layout.rb +51 -0
  20. data/lib/maven/gwt/layout.rb~ +27 -0
  21. data/lib/maven/gwt/pom_magic.rb +74 -0
  22. data/lib/maven/gwt/pom_magic.rb~ +54 -0
  23. data/lib/maven/gwt/rack-web.xml +86 -0
  24. data/lib/maven/gwt/rack-web.xml~ +48 -0
  25. data/lib/maven/gwt/rack_gwt.rb~ +7 -0
  26. data/lib/maven/gwt/rack_project.rb~ +105 -0
  27. data/lib/maven/gwt/rails-web.xml +68 -0
  28. data/lib/maven/gwt/rails-web.xml~ +48 -0
  29. data/lib/maven/gwt/rails_project.rb~ +13 -0
  30. data/lib/maven/gwt/ruby_maven.rb~ +24 -0
  31. data/lib/maven/gwt/templates/Application.java +68 -0
  32. data/lib/maven/gwt/templates/Application.java~ +46 -0
  33. data/lib/maven/gwt/templates/Application.ui.xml +30 -0
  34. data/lib/maven/gwt/templates/Application.ui.xml~ +9 -0
  35. data/lib/maven/gwt/templates/EntryPoint.java +80 -0
  36. data/lib/maven/gwt/templates/EntryPoint.java~ +55 -0
  37. data/lib/maven/gwt/templates/Module.gwt.xml +44 -0
  38. data/lib/maven/gwt/templates/Module.gwt.xml~ +24 -0
  39. data/lib/maven/gwt/templates/ModuleDevelopment.gwt.xml +31 -0
  40. data/lib/maven/gwt/templates/ModuleDevelopment.gwt.xml~ +7 -0
  41. data/lib/maven/gwt/templates/gwt.css +95 -0
  42. data/lib/maven/gwt/templates/index.html +49 -0
  43. data/lib/maven/gwt/templates/index.html~ +29 -0
  44. data/lib/maven/gwt/version.rb +25 -0
  45. data/lib/maven/gwt/version.rb~ +5 -0
  46. data/lib/maven/gwt/web.xml~ +37 -0
  47. data/lib/rack/gwt/rack_gwt.rb~ +7 -0
  48. data/lib/rack/gwt/static.rb +58 -0
  49. data/lib/rack/gwt/static.rb~ +28 -0
  50. metadata +188 -0
@@ -0,0 +1,62 @@
1
+ #-*- mode: ruby -*-
2
+
3
+ jar('org.jruby.rack:jruby-rack', '1.1.13.1').exclusions << 'org.jruby:jruby-complete'
4
+ jar('org.jruby:jruby-core', '${jruby.version}')
5
+ jar('com.google.gwt:gwt-user', '${gwt.version}').scope :provided
6
+
7
+ jar('org.fusesource.restygwt:restygwt', '1.3').scope :provided
8
+ jar('javax.ws.rs:jsr311-api', '1.1').scope :provided
9
+ jar('com.google.gwt.inject:gin', '1.5.0').scope :provided
10
+ jar('javax.validation:validation-api', '1.0.0.GA').scope :provided
11
+ jar('javax.validation:validation-api', '1.0.0.GA', 'sources').scope :provided
12
+
13
+ plugin('org.codehaus.mojo:gwt-maven-plugin', '${gwt.version}') do |gwt|
14
+ gwt.with({ :warSourceDirectory => "${basedir}/public",
15
+ :webXml => "${basedir}/public/WEB-INF/web.xml",
16
+ :webappDirectory => "${basedir}/public",
17
+ :hostedWebapp => "${basedir}/public",
18
+ :inplace => true,
19
+ :logLevel => "INFO",
20
+ :treeLogger => true,
21
+ :extraJvmArgs => "-Xmx512m",
22
+ :gen => "${project.build.directory}/generated",
23
+ :runTarget => "APP_NAME.html"
24
+ })
25
+ gwt.executions.goals << ["clean", "compile", "test"]
26
+ end
27
+
28
+ profile :development do |p|
29
+ p.activation.by_default
30
+ p.plugin('org.codehaus.mojo:gwt-maven-plugin', '${gwt.version}') do |gwt|
31
+ gwt.with({ :module => 'GWT_MODULEDevelopment',
32
+ :style => "DETAILED",
33
+ :includes => "**/GWT_MODULEGWTTestSuite.java",
34
+ :draftCompile => true })
35
+ end
36
+ end
37
+
38
+ profile :production do |p|
39
+ p.plugin('org.codehaus.mojo:gwt-maven-plugin', '${gwt.version}') do |gwt|
40
+ gwt.with({ :module => 'GWT_MODULE',
41
+ :style => "OBF",
42
+ :draftCompile => false,
43
+ :disableClassMetadata => true,
44
+ :disableCastChecking => true,
45
+ :optimizationLevel => 9})
46
+ end
47
+ end
48
+
49
+ #-- Macs need the -d32 -XstartOnFirstThread jvm options -->
50
+ profile("mac") do |mac|
51
+ mac.activation.os.family "mac"
52
+ mac.plugin('org.codehaus.mojo:gwt-maven-plugin', '${gwt.version}').with(:extraJvmArgs => "-d32 -XstartOnFirstThread -Xmx512m")
53
+ end
54
+
55
+ # lock down versions
56
+ properties['gwt.version'] = '2.5.1-rc1'
57
+ properties['jruby.version'] = '1.7.2'
58
+ properties['jruby.plugins.version'] = '0.29.4'
59
+ # jetty version to run it in standalone jetty via jetty-run
60
+ properties['jetty.version'] = '8.1.9.v20130131'
61
+
62
+ # 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/gwt/pom_magic'
23
+
24
+ module Maven
25
+ module Gwt
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,14 @@
1
+ require 'maven/ruby/cli'
2
+ require 'maven/gwt/pom_magic'
3
+
4
+ module Maven
5
+ module Gwt
6
+ class Cli < Maven::Ruby::Cli
7
+
8
+ def magic_pom( dir = '.', *args )
9
+ PomMagic.new.generate_pom( File.expand_path( dir ), *args )
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,86 @@
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/gwt/layout'
22
+ require 'thor/group'
23
+ require 'thor/actions'
24
+
25
+ module Maven
26
+ module Gwt
27
+ class Generator < Thor::Group
28
+ include Thor::Actions
29
+
30
+ source_root( File.join( File.dirname( __FILE__ ), 'templates' ) )
31
+
32
+ def layout
33
+ @layout ||= Layout.new
34
+ end
35
+
36
+ def base_package
37
+ @base_package ||= @java_package + '.client'
38
+ end
39
+
40
+ def basedir
41
+ @basedir ||= File.join( layout.java_root, *@java_package.split( /\./ ) )
42
+ end
43
+
44
+ def clientdir
45
+ @clientdir ||= File.join( basedir, 'client' )
46
+ end
47
+
48
+ def application_name
49
+ @application_name ||= File.basename( @basedir )
50
+ end
51
+
52
+ def application_name_humanized
53
+ @application_name_humanized ||= application_name.split( /_/ ).collect{ |p| p.capitalize }.join( ' ' )
54
+ end
55
+
56
+ def application_class_name
57
+ @application_name ||= camelize( application_name )
58
+ end
59
+
60
+ def camelize( str )
61
+ str.split( "_" ).collect { |s| s.capitalize }.join
62
+ end
63
+
64
+ def setup( java_package, app_name = nil )
65
+ @java_package = java_package
66
+ @application_name = app_name
67
+ template( 'Module.gwt.xml',
68
+ "#{basedir}/#{application_class_name}.gwt.xml" )
69
+ template( 'ModuleDevelopment.gwt.xml',
70
+ "#{basedir}/#{application_class_name}Development.gwt.xml" )
71
+ template( 'EntryPoint.java',
72
+ "#{clientdir}/#{application_class_name}EntryPoint.java" )
73
+ template( 'Application.java',
74
+ "#{clientdir}/#{application_class_name}Application.java" )
75
+ template( 'Application.ui.xml',
76
+ "#{clientdir}/#{application_class_name}Application.ui.xml" )
77
+ template( 'index.html',
78
+ 'public/index.html' )
79
+ template( 'gwt.css',
80
+ "public/#{application_name}.css" )
81
+
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,62 @@
1
+ require 'maven/gwt/layout'
2
+ require 'thor/group'
3
+ require 'thor/actions'
4
+
5
+ module Maven
6
+ module Gwt
7
+ class Generator < Thor::Group
8
+ include Thor::Actions
9
+
10
+ source_root( File.join( File.dirname( __FILE__ ), 'templates' ) )
11
+
12
+ def layout
13
+ @layout ||= Layout.new
14
+ end
15
+
16
+ def base_package
17
+ @base_package ||= @java_package + '.client'
18
+ end
19
+
20
+ def basedir
21
+ @basedir ||= File.join( layout.java_root, *@java_package.split( /\./ ) )
22
+ end
23
+
24
+ def clientdir
25
+ @clientdir ||= File.join( basedir, 'client' )
26
+ end
27
+
28
+ def application_name
29
+ @application_name ||= File.basename( @basedir )
30
+ end
31
+
32
+ def application_class_name
33
+ @application_name ||= camelize( application_name )
34
+ end
35
+
36
+ def camelize( str )
37
+ str.split( "_" ).collect { |s| s.capitalize }.join
38
+ end
39
+
40
+ def setup( java_package, app_name = nil )
41
+ @java_package = java_package
42
+ @application_name = app_name
43
+ template( 'Module.gwt.xml',
44
+ "#{basedir}/#{application_class_name}.gwt.xml" )
45
+ template( 'ModuleDevelopment.gwt.xml',
46
+ "#{basedir}/#{application_class_name}Development.gwt.xml" )
47
+ template( 'EntryPoint.java',
48
+ "#{clientdir}/#{application_class_name}EntryPoint.java" )
49
+ template( 'Application.java',
50
+ "#{clientdir}/#{application_class_name}Application.java" )
51
+ template( 'Application.ui.xml',
52
+ "#{clientdir}/#{application_class_name}Application.ui.xml" )
53
+ template( 'index.html',
54
+ 'public/index.html' )
55
+ template( 'gwt.css',
56
+ "public/#{application_name}.css" )
57
+
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,69 @@
1
+ require 'maven/tools/rails_project'
2
+
3
+ module Maven
4
+ module Jetty
5
+ class RackProject < Maven::Tools::GemProject
6
+
7
+ tags :dummy
8
+
9
+ private
10
+
11
+ CONNECTOR_XML = <<-XML
12
+
13
+ <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
14
+ <port>${jetty.port}</port>
15
+ </connector>
16
+ <connector implementation="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
17
+ <port>${jetty.sslport}</port>
18
+ <keystore>${project.basedir}/src/test/resources/server.keystore</keystore>
19
+ <keyPassword>123456</keyPassword>
20
+ <password>123456</password>
21
+ </connector>
22
+ XML
23
+
24
+ public
25
+
26
+
27
+ def add_defaults
28
+ super
29
+ self.properties.merge!({
30
+ "jetty.version" => '7.6.4.v20120524',
31
+ "jetty.war" => "${project.build.directory}/${project.build.finalName}.war",
32
+ "jetty.port" => '8080',
33
+ "jetty.sslport" => '8443'
34
+ })
35
+
36
+ profile(:war).plugin("org.mortbay.jetty:jetty-maven-plugin",
37
+ "${jetty.version}")do |jetty|
38
+ options = {
39
+ :war => "${jetty.war}",
40
+ :connectors => CONNECTOR_XML
41
+ }
42
+ jetty.with options
43
+ end
44
+
45
+ profile(:run) do |run|
46
+ overrideDescriptor = '${project.build.directory}/jetty/override-${rails.env}-web.xml'
47
+ run.activation.by_default
48
+ run.plugin("org.mortbay.jetty:jetty-maven-plugin",
49
+ "${jetty.version}") do |jetty|
50
+ options = {
51
+ :webAppConfig => {
52
+ :overrideDescriptor => overrideDescriptor
53
+ },
54
+ :systemProperties => {
55
+ :systemProperty => {
56
+ :name => 'jbundle.skip',
57
+ :value => 'true'
58
+ }
59
+ },
60
+ :connectors => CONNECTOR_XML
61
+ }
62
+ options[:webXml] = 'config/web.xml' if File.exists?('config/web.xml')
63
+ jetty.with options
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,51 @@
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
+ module Maven
22
+ module Gwt
23
+ class Layout
24
+
25
+ def initialize( dir = '.' )
26
+ @dir = dir
27
+ end
28
+
29
+ def java_root
30
+ @java_root ||= File.join( @dir, 'src', 'main', 'java' )
31
+ end
32
+
33
+ def public_dir
34
+ @public_dir ||= File.join( @dir, 'public' )
35
+ end
36
+
37
+ def find_gwt_xml( path = java_root )
38
+ Dir[ File.join( path, "*" ) ].each do |path|
39
+ if File.directory?( path )
40
+ result = find_gwt_xml( path )
41
+ return result if result
42
+ elsif File.file?( path )
43
+ return path if (path =~ /.gwt.xml$/) && ! (path =~ /Development.gwt.xml$/)
44
+ end
45
+ end
46
+ nil
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,27 @@
1
+ module Maven
2
+ module Gwt
3
+ class Layout
4
+
5
+ def initialize( dir = '.' )
6
+ @dir = dir
7
+ end
8
+
9
+ def java_root
10
+ @java_root ||= File.join( @dir, 'src', 'main', 'java' )
11
+ end
12
+
13
+ def find_gwt_xml( path = java_root )
14
+ Dir[ File.join( path, "*" ) ].each do |path|
15
+ if File.directory?( path )
16
+ result = find_gwt_xml( path )
17
+ return result if result
18
+ elsif File.file?( path )
19
+ return path if (path =~ /.gwt.xml$/) && ! (path =~ /Development.gwt.xml$/)
20
+ end
21
+ end
22
+ nil
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,74 @@
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/jetty/pom_magic'
22
+ require 'maven/tools/gem_project'
23
+ require 'maven/gwt/layout'
24
+ require 'fileutils'
25
+
26
+ module Maven
27
+ module Gwt
28
+ class PomMagic < Maven::Jetty::PomMagic
29
+
30
+ def generate_pom( dir = '.', *args )
31
+
32
+ proj = Maven::Tools::GemProject.new
33
+
34
+ ensure_web_xml( dir, proj )
35
+ ensure_mavenfile( dir )
36
+
37
+ load_standard_files( dir, proj )
38
+
39
+ pom_xml( dir, proj, args )
40
+ end
41
+
42
+ def gwt_module( layout )
43
+ gwt_module = layout.find_gwt_xml
44
+ unless gwt_module
45
+ path = layout.java_root.sub( /#{File.expand_path( '.' )}/, '').sub( /^\//, '' )
46
+ e = StandardError.new "no gwt module found in '#{path}'. try to run the command below to setup a minimal gwt application.\n\n\t\t#{File.basename( $0 )} setup JAVA_PACKAGE [APP_NAME]\n\n"
47
+
48
+ def e.backtrace
49
+ []
50
+ end
51
+ raise e
52
+ end
53
+ gwt_module
54
+ end
55
+
56
+ def ensure_mavenfile( dir )
57
+ unless File.exists?( File.join( dir, 'Mavenfile' ) )
58
+ layout = Layout.new( dir )
59
+ file = File.expand_path( gwt_module( layout ) )
60
+ gwt_module = file.sub( /#{layout.java_root}\/?/, '' ).sub( /.gwt.xml$/, '' ).gsub( /\//, '.')
61
+ app_name = gwt_module.sub( /.*\./, '' )
62
+ unless File.exists?( File.join( layout.public_dir, app_name + ".html" ) )
63
+ app_name = 'index'
64
+ end
65
+ super dir, File.dirname( __FILE__ ), 'GWT_MODULE' => gwt_module, 'APP_NAME' => app_name, 'GWT_MODULE_NAME' => gwt_module.sub( /.*\./, '' )
66
+ end
67
+ end
68
+
69
+ def ensure_web_xml( dir, proj )
70
+ super dir, proj, File.dirname( __FILE__ ), File.join( dir, 'public', 'WEB-INF', 'web.xml' )
71
+ end
72
+ end
73
+ end
74
+ end