vraptor-scaffold 1.2.3 → 1.3.0.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/CHANGELOG.rdoc +7 -0
  2. data/Gemfile.lock +1 -1
  3. data/README.textile +1 -0
  4. data/lib/vraptor-scaffold/execution.rb +9 -8
  5. data/lib/vraptor-scaffold/generators/app/app_generator.rb +51 -9
  6. data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +38 -9
  7. data/lib/vraptor-scaffold/generators/app/templates/build.xml +146 -146
  8. data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath-gae.erb +15 -0
  9. data/lib/vraptor-scaffold/generators/app/templates/eclipse/project-gae.erb +47 -0
  10. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/com.google.gdt.eclipse.core.prefs +5 -0
  11. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/org.eclipse.jdt.core.prefs +8 -0
  12. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/org.eclipse.wst.common.component.tt +10 -0
  13. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/org.eclipse.wst.common.project.facet.core.xml +9 -0
  14. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/org.eclipse.wst.jsdt.ui.superType.container +1 -0
  15. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/org.eclipse.wst.jsdt.ui.superType.name +1 -0
  16. data/lib/vraptor-scaffold/generators/app/templates/gae/ObjectifyFactory.java.tt +30 -0
  17. data/lib/vraptor-scaffold/generators/app/templates/gae/appengine-web.xml.tt +13 -0
  18. data/lib/vraptor-scaffold/generators/app/templates/gae/ivysettings.xml +10 -0
  19. data/lib/vraptor-scaffold/generators/app/templates/gae/logging.properties +28 -0
  20. data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-objectify.java.tt +41 -0
  21. data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold.erb +1 -1
  22. data/lib/vraptor-scaffold/generators/app/templates/webapp/WEB-INF/web.xml.tt +2 -2
  23. data/lib/vraptor-scaffold/generators/scaffold/attribute.rb +1 -1
  24. data/lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb +7 -1
  25. data/lib/vraptor-scaffold/generators/scaffold/controller_generator/controller_generator.rb +10 -5
  26. data/lib/vraptor-scaffold/generators/scaffold/model_generator/model_generator.rb +10 -4
  27. data/lib/vraptor-scaffold/generators/scaffold/model_generator/objectify_model_generator.rb +20 -0
  28. data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/objectify_model.erb +33 -0
  29. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/objectify_repository_generator.rb +25 -0
  30. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator.rb +9 -4
  31. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/objectify_repository.erb +22 -0
  32. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/objectify_repository_impl.erb +16 -0
  33. data/lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb +10 -3
  34. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/freemarker_generator.rb +5 -4
  35. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/jsp_generator.rb +5 -4
  36. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/template_engine_generator.rb +7 -1
  37. data/lib/vraptor-scaffold/load_paths.rb +3 -1
  38. data/lib/vraptor-scaffold/runner.rb +1 -0
  39. data/lib/vraptor-scaffold/runner/start.rb +29 -0
  40. data/lib/vraptor-scaffold/version.rb +1 -1
  41. data/maven/repo/br/com/caelum/vraptor-gae/1.0/vraptor-gae-1.0.jar +0 -0
  42. data/spec/resources/vraptor-scaffold-objectify.properties +7 -0
  43. data/spec/spec_helper.rb +5 -0
  44. data/spec/vraptor-scaffold/configuration_spec.rb +3 -0
  45. data/spec/vraptor-scaffold/execution_spec.rb +5 -1
  46. data/spec/vraptor-scaffold/generators/app/app_generator_spec.rb +77 -2
  47. data/spec/vraptor-scaffold/generators/app/dependency_manager_spec.rb +18 -3
  48. data/spec/vraptor-scaffold/generators/app/templates/ObjectifyFactory.java +30 -0
  49. data/spec/vraptor-scaffold/generators/app/templates/{Repository.java → RepositoryJPA.java} +0 -0
  50. data/spec/vraptor-scaffold/generators/app/templates/RepositoryObjectify.java +41 -0
  51. data/spec/vraptor-scaffold/generators/app/templates/build.gradle +1 -1
  52. data/spec/vraptor-scaffold/generators/app/templates/build.xml +146 -0
  53. data/spec/vraptor-scaffold/generators/app/templates/classpath-gae +18 -0
  54. data/spec/vraptor-scaffold/generators/app/templates/freemarker-web.xml +1 -1
  55. data/spec/vraptor-scaffold/generators/app/templates/gae-jsp-web.xml +45 -0
  56. data/spec/vraptor-scaffold/generators/app/templates/ivy-gae.xml +45 -0
  57. data/spec/vraptor-scaffold/generators/app/templates/ivy.xml +1 -1
  58. data/spec/vraptor-scaffold/generators/app/templates/jsp-web.xml +1 -1
  59. data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +5 -5
  60. data/spec/vraptor-scaffold/generators/app/templates/pom.xml +5 -5
  61. data/spec/vraptor-scaffold/generators/app/templates/project-gae +47 -0
  62. data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +1 -1
  63. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +1 -1
  64. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +1 -1
  65. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +5 -5
  66. data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +1 -1
  67. data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +5 -5
  68. data/spec/vraptor-scaffold/generators/scaffold/attribute_spec.rb +5 -1
  69. data/spec/vraptor-scaffold/generators/scaffold/controller_generator/controller_generator_spec.rb +6 -2
  70. data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/freemarker_generator_spec.rb +4 -0
  71. data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/jsp_generator_spec.rb +4 -0
  72. data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +4 -0
  73. data/spec/vraptor-scaffold/generators/scaffold/model_generator/objectify_model_generator_spec.rb +40 -0
  74. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/ObjectifyFactory.java +33 -0
  75. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Objectify_Product.java +38 -0
  76. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/objectify_repository_generator_spec.rb +33 -0
  77. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator_spec.rb +12 -4
  78. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/Objectify_ProductRepository.java +22 -0
  79. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/Objectify_ProductRepositoryImpl.java +16 -0
  80. data/spec/vraptor-scaffold/generators/scaffold/scaffold_generator_spec.rb +14 -1
  81. data/spec/vraptor-scaffold/runner/scaffold_spec.rb +5 -5
  82. data/spec/vraptor-scaffold/runner/start_spec.rb +51 -0
  83. metadata +54 -19
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.3.0 / 2011-??-??
2
+
3
+ * New Features
4
+ * GAE support (vraptor new app --gae).
5
+ * Customizing templates.
6
+ * Added start command (vraptor start).
7
+
1
8
  == 1.2.3 / 2011-11-15
2
9
 
3
10
  * Bugfixes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vraptor-scaffold (1.2.2)
4
+ vraptor-scaffold (1.3.0)
5
5
  activesupport (= 3.0.1)
6
6
  rake (= 0.9.2)
7
7
  thor (= 0.14.6)
data/README.textile CHANGED
@@ -44,6 +44,7 @@ h2. Contributors
44
44
  * Felipe Fontoura
45
45
  * Guilherme Silveira
46
46
  * José Guilherme Camara Ribeiro
47
+ * Laécio Freitas
47
48
  * Lucas Cavalcanti
48
49
  * Luiz Fernando Signorelli
49
50
  * Toshi Kurauchi
@@ -1,12 +1,12 @@
1
1
  module VraptorScaffold
2
2
 
3
3
  class Execution
4
-
4
+
5
5
  def run(args)
6
6
  action = args.shift
7
7
  runner_for(action).new.run(args)
8
8
  end
9
-
9
+
10
10
  def runner_for(action)
11
11
  VraptorScaffold::COMMANDS.fetch(action, Runner::CommandsHelp)
12
12
  end
@@ -14,11 +14,12 @@ module VraptorScaffold
14
14
  end
15
15
 
16
16
  COMMANDS = {"--help" => Runner::Generator,
17
- "-h" => Runner::Generator,
18
- "new" => Runner::Generator,
19
- "scaffold" => Runner::Scaffold,
20
- "plugin" => Runner::Plugin
21
- #"configure" => Runner::Configure
17
+ "-h" => Runner::Generator,
18
+ "new" => Runner::Generator,
19
+ "scaffold" => Runner::Scaffold,
20
+ "plugin" => Runner::Plugin,
21
+ "start" => Runner::Start
22
+ #"configure" => Runner::Configure
22
23
  }
23
-
24
+
24
25
  end
@@ -2,7 +2,7 @@ class AppGenerator < VraptorScaffold::Base
2
2
 
3
3
  TEMPLATE_ENGINES = %w( jsp ftl )
4
4
  BUILD_TOOLS = %w( ant mvn gradle )
5
- ORMS = %w( jpa hibernate )
5
+ ORMS = %w( jpa hibernate objectify )
6
6
  IVY_JAR = "ivy-2.2.0.jar"
7
7
 
8
8
  argument :project_path
@@ -22,6 +22,9 @@ class AppGenerator < VraptorScaffold::Base
22
22
  class_option :heroku, :type => :boolean, :aliases => "-h",
23
23
  :desc => "heroku project"
24
24
 
25
+ class_option :gae, :type => :boolean, :aliases => "-g",
26
+ :desc => "google app engine project"
27
+
25
28
  class_option :repositories_package, :aliases => "-r", :default => "repositories",
26
29
  :desc => "Define repositories package"
27
30
 
@@ -72,12 +75,22 @@ class AppGenerator < VraptorScaffold::Base
72
75
  template("ivy.erb", "ivy.xml")
73
76
  copy_file(IVY_JAR)
74
77
  end
78
+ if options[:gae]
79
+ copy_file("gae/ivysettings.xml", "ivysettings.xml")
80
+ end
75
81
  end
76
82
 
77
83
  def configure_gradle
78
84
  template("build.gradle.erb", "build.gradle") if build_tool == "gradle"
79
85
  end
80
86
 
87
+ def configure_vraptor_packages
88
+ vraptor_util_package = "br.com.caelum.vraptor.util"
89
+ @vraptor_packages = []
90
+ @vraptor_packages += ["#{vraptor_util_package}.#{orm}"] if orm == "jpa" or orm == "hibernate"
91
+ @vraptor_packages += ["#{vraptor_util_package}.gae"] if options[:gae]
92
+ end
93
+
81
94
  def create_main_java
82
95
  empty_directory Configuration::MAIN_SRC
83
96
  @src = File.join(Configuration::MAIN_SRC, options[:package].gsub(".", File::Separator))
@@ -93,13 +106,17 @@ class AppGenerator < VraptorScaffold::Base
93
106
  def create_models_directory
94
107
  models_folder = File.join @src, options[:models_package]
95
108
  empty_directory models_folder
96
- template("models/Entity.erb", "#{models_folder}/Entity.java")
109
+ template("models/Entity.erb", "#{models_folder}/Entity.java") unless options[:gae]
97
110
  end
98
111
 
99
112
  def create_repositories_directory
100
113
  repositories_folder = File.join @src, options[:repositories_package]
101
114
  empty_directory repositories_folder
102
- template("orm/Repository-#{options[:orm]}.java.tt", "#{repositories_folder}/Repository.java")
115
+ if options[:gae]
116
+ template("orm/Repository-objectify.java.tt", "#{repositories_folder}/Repository.java")
117
+ else
118
+ template("orm/Repository-#{orm}.java.tt", "#{repositories_folder}/Repository.java")
119
+ end
103
120
  end
104
121
 
105
122
  def create_main_resources
@@ -107,8 +124,12 @@ class AppGenerator < VraptorScaffold::Base
107
124
  end
108
125
 
109
126
  def configure_orm
110
- if (options[:orm] == "hibernate")
127
+ if (orm == "hibernate")
111
128
  copy_file("orm/hibernate.cfg.xml", (File.join Configuration::MAIN_RESOURCES, "hibernate.cfg.xml"))
129
+ elsif orm == "objectify"
130
+ infra_folder = File.join @src, "infra"
131
+ empty_directory infra_folder
132
+ template("gae/ObjectifyFactory.java.tt", "#{@src}/infra/ObjectifyFactory.java")
112
133
  else
113
134
  metainf = File.join Configuration::MAIN_RESOURCES, 'META-INF'
114
135
  empty_directory metainf
@@ -118,6 +139,10 @@ class AppGenerator < VraptorScaffold::Base
118
139
 
119
140
  def create_webapp
120
141
  directory("webapp", Configuration::WEB_APP)
142
+ if @options[:gae]
143
+ template("gae/appengine-web.xml.tt", "#{Configuration::WEB_INF}/appengine-web.xml")
144
+ copy_file("gae/logging.properties", "#{Configuration::WEB_INF}/logging.properties")
145
+ end
121
146
  end
122
147
 
123
148
  def create_javascripts
@@ -149,13 +174,25 @@ class AppGenerator < VraptorScaffold::Base
149
174
  private
150
175
  def build_tool
151
176
  return "mvn" if options[:heroku]
177
+ return "ant" if options[:gae]
152
178
  options[:build_tool]
153
179
  end
154
180
 
181
+ def orm
182
+ return "objectify" if options[:gae]
183
+ options[:orm]
184
+ end
185
+
155
186
  def create_eclipse_files
156
- template("eclipse/project.erb", ".project")
157
- template("eclipse/classpath.erb", ".classpath")
158
- directory("eclipse/settings", ".settings")
187
+ if options[:gae]
188
+ template("eclipse/classpath-gae.erb", ".classpath")
189
+ template("eclipse/project-gae.erb", ".project")
190
+ directory("eclipse/settings-gae", ".settings")
191
+ else
192
+ template("eclipse/classpath.erb", ".classpath")
193
+ template("eclipse/project.erb", ".project")
194
+ directory("eclipse/settings", ".settings")
195
+ end
159
196
  end
160
197
 
161
198
  def validate
@@ -167,8 +204,13 @@ class AppGenerator < VraptorScaffold::Base
167
204
  puts "Template engine #{options[:template_engine]} is not supported. The supported template engines are: #{TEMPLATE_ENGINES.join(", ")}"
168
205
  Kernel::exit
169
206
  end
170
- unless ORMS.include? options[:orm]
171
- puts "ORM #{options[:orm]} is not supported. The supported object-relational mapping are: #{ORMS.join(", ")}"
207
+ unless ORMS.include? orm
208
+ puts "ORM #{orm} is not supported. The supported object-relational mapping are: #{ORMS.join(", ")}"
209
+ Kernel::exit
210
+ end
211
+
212
+ if options[:heroku] and options[:gae]
213
+ puts "You cannot create gae and heroku template project together"
172
214
  Kernel::exit
173
215
  end
174
216
 
@@ -9,6 +9,7 @@ class DependencyManager
9
9
  def compile_scope
10
10
  dependencies = append_freemarker_dependency_if_necessary default_dependencies
11
11
  dependencies = append_heroku_dependencies_if_necessary dependencies
12
+ dependencies = append_gae_dependencies_if_necessary dependencies
12
13
  dependencies
13
14
  end
14
15
 
@@ -27,15 +28,27 @@ class DependencyManager
27
28
 
28
29
  private
29
30
  def default_dependencies
30
- hibernate_version = "3.6.7.Final"
31
- [Dependency.new("br.com.caelum", "vraptor", "3.4.0"),
32
- Dependency.new("org.hsqldb", "hsqldb", "2.2.4"),
33
- Dependency.new("opensymphony", "sitemesh", "2.4.2"), Dependency.new("javax.servlet", "jstl", "1.2"),
34
- Dependency.new("org.hibernate", "hibernate-entitymanager", hibernate_version),
35
- Dependency.new("org.hibernate", "hibernate-c3p0", hibernate_version),
36
- Dependency.new("org.hibernate", "hibernate-validator", "4.2.0.Final"),
37
- Dependency.new("joda-time", "joda-time", "2.0"),
38
- Dependency.new("com.thoughtworks.xstream", "xstream", "1.4.1")]
31
+ dependencies = []
32
+ if options[:gae]
33
+ dependencies += [Dependency.new("br.com.caelum", "vraptor", "3.3.1")]
34
+ else
35
+ dependencies += [Dependency.new("br.com.caelum", "vraptor", "3.4.0")]
36
+ end
37
+
38
+ dependencies += [Dependency.new("opensymphony", "sitemesh", "2.4.2"),
39
+ Dependency.new("javax.servlet", "jstl", "1.2")]
40
+
41
+ unless @options[:gae]
42
+ hibernate_version = "3.6.7.Final"
43
+ dependencies += [Dependency.new("org.hsqldb", "hsqldb", "2.2.4"),
44
+ Dependency.new("org.hibernate", "hibernate-entitymanager", hibernate_version),
45
+ Dependency.new("org.hibernate", "hibernate-c3p0", hibernate_version)]
46
+ end
47
+
48
+ dependencies += [Dependency.new("org.hibernate", "hibernate-validator", "4.2.0.Final"),
49
+ Dependency.new("joda-time", "joda-time", "2.0"),
50
+ Dependency.new("com.thoughtworks.xstream", "xstream", "1.4.1")]
51
+ dependencies
39
52
  end
40
53
 
41
54
  def append_heroku_dependencies_if_necessary dependencies
@@ -47,6 +60,22 @@ class DependencyManager
47
60
  dependencies
48
61
  end
49
62
 
63
+ def append_gae_dependencies_if_necessary dependencies
64
+ if @options[:gae]
65
+ appengine_version = "1.6.0"
66
+ dependencies += [Dependency.new("com.googlecode.objectify", "objectify", "3.1"),
67
+ Dependency.new("br.com.caelum", "vraptor-gae", "1.0"),
68
+ Dependency.new("commons-fileupload", "commons-fileupload", "1.2.2"),
69
+ Dependency.new("com.google.appengine", "appengine-api-1.0-sdk", appengine_version),
70
+ Dependency.new("com.google.appengine", "appengine-api-labs", appengine_version),
71
+ Dependency.new("com.google.appengine", "appengine-jsr107cache", appengine_version),
72
+ Dependency.new("net.sf.jsr107cache", "jsr107cache", "1.1"),
73
+ Dependency.new("org.apache.geronimo.specs", "geronimo-jpa_3.0_spec", "1.1.1")]
74
+ end
75
+
76
+ dependencies
77
+ end
78
+
50
79
  def append_freemarker_dependency_if_necessary dependencies
51
80
  dependencies << Dependency.new("org.freemarker", "freemarker", "2.3.18") if @options[:template_engine] == 'ftl'
52
81
  dependencies
@@ -1,146 +1,146 @@
1
- <project name="vraptor-scaffold" default="war" xmlns:ivy="antlib:org.apache.ivy.ant">
2
-
3
- <property file="build.properties" />
4
-
5
- <!-- paths -->
6
- <path id="lib.path.id">
7
- <fileset dir="${lib.dir}" />
8
- <fileset dir="lib/provided" />
9
- </path>
10
- <path id="test.path.id">
11
- <fileset dir="lib/test" />
12
- <path refid="lib.path.id" />
13
- <pathelement location="${test.build.dir}" />
14
- <pathelement location="${build.dir}" />
15
- </path>
16
-
17
- <!-- =================================
18
- target: resolve
19
- ================================= -->
20
- <target name="resolve" description="--> retrieve dependencies with ivy">
21
- <path id="ivy.lib.path">
22
- <pathelement location="${ivy.jar.file}" />
23
- </path>
24
- <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
25
-
26
- <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]" sync="true" />
27
- <delete dir="${lib.dir}" includes="**/*.*" />
28
- <copy todir="${lib.dir}">
29
- <fileset dir="lib/default">
30
- <include name="*.jar" />
31
- </fileset>
32
- </copy>
33
- </target>
34
-
35
- <!-- =================================
36
- target: compile
37
- ================================= -->
38
- <target name="compile" depends="resolve" description="--> compile">
39
- <mkdir dir="${build.dir}" />
40
- <delete dir="${build.dir}" includes="**/*.*" />
41
- <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="lib.path.id" debug="on" />
42
- <copy todir="${build.dir}">
43
- <fileset dir="${resources.dir}">
44
- <include name="**/*.*" />
45
- </fileset>
46
- </copy>
47
- </target>
48
-
49
- <!-- =================================
50
- target: compile test
51
- ================================= -->
52
- <target name="compile-test" depends="compile" description="--> compile test">
53
- <mkdir dir="${test.build.dir}" />
54
- <delete dir="${test.build.dir}" includes="**/*.*" />
55
- <javac srcdir="${test.src.dir}" destdir="${test.build.dir}" classpathref="test.path.id" debug="on" />
56
- <copy todir="${test.build.dir}">
57
- <fileset dir="${test.resources.dir}">
58
- <include name="**/*.*" />
59
- </fileset>
60
- </copy>
61
- </target>
62
-
63
- <!-- =================================
64
- target: run tests
65
- ================================= -->
66
- <target name="test" depends="compile-test" description="--> run all tests">
67
- <mkdir dir="${output.dir}/test-results" />
68
- <junit haltonfailure="yes">
69
- <batchtest fork="yes" todir="${output.dir}/test-results">
70
- <fileset dir="${test.src.dir}">
71
- <include name="**/*Test.java" />
72
- </fileset>
73
- </batchtest>
74
- <formatter type="brief" usefile="false" />
75
- <formatter type="xml" />
76
- <classpath refid="test.path.id" />
77
- </junit>
78
- </target>
79
-
80
- <!-- =================================
81
- target: war
82
- ================================= -->
83
- <target name="war" description="--> generate war file" depends="test">
84
- <war destfile="${output.dir}/${project.name}.war">
85
- <zipfileset dir="${webapp.dir}" />
86
- </war>
87
- </target>
88
-
89
- <!-- =================================
90
- target: jetty.run
91
- ================================= -->
92
- <target name="jetty.run" description="--> run jetty server" depends="compile">
93
- <path id="jetty.path.id">
94
- <fileset dir="lib/jetty" />
95
- </path>
96
- <taskdef classpathref="jetty.path.id" resource="tasks.properties" loaderref="jetty.loader" />
97
- <jetty tempDirectory="${output.dir}/jetty-temp">
98
- <webApp name="${project.name}" warfile="${webapp.dir}" contextpath="/" scanIntervalSeconds="3">
99
- <scanTargets dir="${build.dir}">
100
- <include name="**/*"/>
101
- </scanTargets>
102
- </webApp>
103
- </jetty>
104
- </target>
105
-
106
- <!-- =================================
107
- target: minify
108
- ================================= -->
109
- <target name="minify" depends="resolve" description="minify js and css">
110
- <property name="yuicompressor.jar" value="lib/minify/yuicompressor-2.3.6.jar" />
111
-
112
- <fileset dir="${js.dir}" includes="*.js" excludes="all.min.js" id="alljs" />
113
- <fileset dir="${css.dir}" includes="*.css" excludes="*.min.css" id="allcss" />
114
-
115
- <delete file="${css.dir}/all.css" />
116
- <concat destfile="${css.dir}/all.css" fixlastline="true">
117
- <fileset refid="allcss" />
118
- </concat>
119
-
120
- <java jar="${yuicompressor.jar}" fork="true">
121
- <arg value="${css.dir}/all.css" />
122
- <arg value="-o" />
123
- <arg value="${css.dir}/all.min.css" />
124
- </java>
125
-
126
- <delete file="${js.dir}/all.js" />
127
- <concat destfile="${js.dir}/all.js" fixlastline="true">
128
- <fileset refid="alljs" />
129
- </concat>
130
-
131
- <java jar="${yuicompressor.jar}" fork="true">
132
- <arg value="${js.dir}/all.js" />
133
- <arg value="-o" />
134
- <arg value="${js.dir}/all.min.js" />
135
- </java>
136
- </target>
137
-
138
- <!-- =================================
139
- target: report
140
- ================================= -->
141
- <target name="report" depends="resolve" description="--> generates a report of dependencies">
142
- <mkdir dir="${output.dir}/reports" />
143
- <ivy:report todir="${output.dir}/reports" />
144
- </target>
145
-
146
- </project>
1
+ <project name="vraptor-scaffold" default="war" xmlns:ivy="antlib:org.apache.ivy.ant">
2
+
3
+ <property file="build.properties" />
4
+
5
+ <!-- paths -->
6
+ <path id="lib.path.id">
7
+ <fileset dir="${lib.dir}" />
8
+ <fileset dir="lib/provided" />
9
+ </path>
10
+ <path id="test.path.id">
11
+ <fileset dir="lib/test" />
12
+ <path refid="lib.path.id" />
13
+ <pathelement location="${test.build.dir}" />
14
+ <pathelement location="${build.dir}" />
15
+ </path>
16
+
17
+ <!-- =================================
18
+ target: resolve
19
+ ================================= -->
20
+ <target name="resolve" description="--> retrieve dependencies with ivy">
21
+ <path id="ivy.lib.path">
22
+ <pathelement location="${ivy.jar.file}" />
23
+ </path>
24
+ <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
25
+
26
+ <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]" sync="true" />
27
+ <delete dir="${lib.dir}" includes="**/*.*" />
28
+ <copy todir="${lib.dir}">
29
+ <fileset dir="lib/default">
30
+ <include name="*.jar" />
31
+ </fileset>
32
+ </copy>
33
+ </target>
34
+
35
+ <!-- =================================
36
+ target: compile
37
+ ================================= -->
38
+ <target name="compile" depends="resolve" description="--> compile">
39
+ <mkdir dir="${build.dir}" />
40
+ <delete dir="${build.dir}" includes="**/*.*" />
41
+ <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="lib.path.id" debug="on" />
42
+ <copy todir="${build.dir}">
43
+ <fileset dir="${resources.dir}">
44
+ <include name="**/*.*" />
45
+ </fileset>
46
+ </copy>
47
+ </target>
48
+
49
+ <!-- =================================
50
+ target: compile test
51
+ ================================= -->
52
+ <target name="compile-test" depends="compile" description="--> compile test">
53
+ <mkdir dir="${test.build.dir}" />
54
+ <delete dir="${test.build.dir}" includes="**/*.*" />
55
+ <javac srcdir="${test.src.dir}" destdir="${test.build.dir}" classpathref="test.path.id" debug="on" />
56
+ <copy todir="${test.build.dir}">
57
+ <fileset dir="${test.resources.dir}">
58
+ <include name="**/*.*" />
59
+ </fileset>
60
+ </copy>
61
+ </target>
62
+
63
+ <!-- =================================
64
+ target: run tests
65
+ ================================= -->
66
+ <target name="test" depends="compile-test" description="--> run all tests">
67
+ <mkdir dir="${output.dir}/test-results" />
68
+ <junit haltonfailure="yes">
69
+ <batchtest fork="yes" todir="${output.dir}/test-results">
70
+ <fileset dir="${test.src.dir}">
71
+ <include name="**/*Test.java" />
72
+ </fileset>
73
+ </batchtest>
74
+ <formatter type="brief" usefile="false" />
75
+ <formatter type="xml" />
76
+ <classpath refid="test.path.id" />
77
+ </junit>
78
+ </target>
79
+
80
+ <!-- =================================
81
+ target: war
82
+ ================================= -->
83
+ <target name="war" description="--> generate war file" depends="test">
84
+ <war destfile="${output.dir}/${project.name}.war">
85
+ <zipfileset dir="${webapp.dir}" />
86
+ </war>
87
+ </target>
88
+
89
+ <!-- =================================
90
+ target: jetty.run
91
+ ================================= -->
92
+ <target name="jetty.run" description="--> run jetty server" depends="compile">
93
+ <path id="jetty.path.id">
94
+ <fileset dir="lib/jetty" />
95
+ </path>
96
+ <taskdef classpathref="jetty.path.id" resource="tasks.properties" loaderref="jetty.loader" />
97
+ <jetty tempDirectory="${output.dir}/jetty-temp">
98
+ <webApp name="${project.name}" warfile="${webapp.dir}" contextpath="/" scanIntervalSeconds="3">
99
+ <scanTargets dir="${build.dir}">
100
+ <include name="**/*"/>
101
+ </scanTargets>
102
+ </webApp>
103
+ </jetty>
104
+ </target>
105
+
106
+ <!-- =================================
107
+ target: minify
108
+ ================================= -->
109
+ <target name="minify" depends="resolve" description="minify js and css">
110
+ <property name="yuicompressor.jar" value="lib/minify/yuicompressor-2.3.6.jar" />
111
+
112
+ <fileset dir="${js.dir}" includes="*.js" excludes="all.min.js" id="alljs" />
113
+ <fileset dir="${css.dir}" includes="*.css" excludes="*.min.css" id="allcss" />
114
+
115
+ <delete file="${css.dir}/all.css" />
116
+ <concat destfile="${css.dir}/all.css" fixlastline="true">
117
+ <fileset refid="allcss" />
118
+ </concat>
119
+
120
+ <java jar="${yuicompressor.jar}" fork="true">
121
+ <arg value="${css.dir}/all.css" />
122
+ <arg value="-o" />
123
+ <arg value="${css.dir}/all.min.css" />
124
+ </java>
125
+
126
+ <delete file="${js.dir}/all.js" />
127
+ <concat destfile="${js.dir}/all.js" fixlastline="true">
128
+ <fileset refid="alljs" />
129
+ </concat>
130
+
131
+ <java jar="${yuicompressor.jar}" fork="true">
132
+ <arg value="${js.dir}/all.js" />
133
+ <arg value="-o" />
134
+ <arg value="${js.dir}/all.min.js" />
135
+ </java>
136
+ </target>
137
+
138
+ <!-- =================================
139
+ target: report
140
+ ================================= -->
141
+ <target name="report" depends="resolve" description="--> generates a report of dependencies">
142
+ <mkdir dir="${output.dir}/reports" />
143
+ <ivy:report todir="${output.dir}/reports" />
144
+ </target>
145
+
146
+ </project>