raystool 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,7 @@ _rayscomp () {
19
19
  if [ $# -gt 2 ]; then
20
20
  cur="$3"
21
21
  fi
22
+
22
23
  for c in $1; do
23
24
  case "$c$4" in
24
25
  --*=*) all="$all$c$4$s" ;;
@@ -48,13 +49,10 @@ _rays_dir () {
48
49
  done
49
50
  }
50
51
 
51
- _rays_module_types="portlet hook theme servicebuilder layout ext ejb"
52
+ _rays_module_types="portlet hook theme servicebuilder layout ext"
52
53
 
53
54
  _rays_module_find () {
54
55
  local dir="$1/$2s" glob="*-$2"
55
- if [ $2 = "ejb" ]; then
56
- local dir="$1/ee/ejb"
57
- fi
58
56
 
59
57
 
60
58
  case "$2" in ext) dir="$1/$2" ;; esac
@@ -71,7 +69,7 @@ _rays_module () {
71
69
 
72
70
  while [[ $c -lt $COMP_CWORD ]] && [ -z "$module_dir" ]; do
73
71
  case "${COMP_WORDS[c]}" in
74
- portlet|hook|theme|layout|ext|servicebuilder|ejb)
72
+ portlet|hook|theme|layout|ext|servicebuilder)
75
73
  _rays_module_find "$dir" "${COMP_WORDS[c]}"
76
74
  return
77
75
  ;;
@@ -134,24 +132,28 @@ _rays_complete () {
134
132
  g)
135
133
  _rayscomp "
136
134
  $_rays_module_types
135
+ ejb
137
136
  $default_args
138
137
  "
139
138
  ;;
140
139
  build)
141
140
  _rayscomp "
142
141
  $(_rays_module "$c")
142
+ ear
143
143
  $default_args
144
144
  "
145
145
  ;;
146
146
  deploy)
147
147
  _rayscomp "
148
148
  $(_rays_module "$c")
149
+ ear
149
150
  --skip-test $default_args
150
151
  "
151
152
  ;;
152
153
  clean)
153
154
  _rayscomp "
154
155
  $(_rays_module "$c")
156
+ ear
155
157
  $default_args
156
158
  "
157
159
  ;;
@@ -1 +1 @@
1
- version: 1.2.2
1
+ version: 1.2.6
@@ -111,6 +111,7 @@ module Rays
111
111
 
112
112
  def load_third_party_dependencies
113
113
  require 'fileutils'
114
+ require 'pathname'
114
115
  require 'find'
115
116
  require 'yaml'
116
117
  require 'logger'
@@ -153,17 +153,20 @@ class RaysCommand < Clamp::Command
153
153
  # BUILDER
154
154
  #
155
155
  subcommand 'build', 'build module(s). build all modules if under project root or a specific module if under module\'s root' do
156
- parameter '[type]', 'a module type [portlet | hook | theme | layout | ext | ejb]'
156
+ parameter '[type]', 'a module type [portlet | hook | theme | layout | ext | ear]'
157
157
  parameter '[name]', 'a module name'
158
158
  option '--skip-test', :flag, 'use this option if you want to skip module tests'
159
159
 
160
160
  def execute
161
161
  modules = []
162
- if type.nil? and !name.nil?
163
- raise RaysException.new("Cannot build type w/o name.")
162
+ if type.nil? and !name.nil? and !'ear'.eql? type
163
+ raise RaysException.new("Please specify name for #{type}")
164
+ end
165
+
166
+ if 'ear'.eql? type
167
+ name = 'application'
164
168
  end
165
169
 
166
- module_instance = nil
167
170
  if !type.nil? and !name.nil?
168
171
  module_instance = Rays::AppModule::Manager.instance.get(type, name)
169
172
  else
@@ -184,17 +187,20 @@ class RaysCommand < Clamp::Command
184
187
  # DEPLOYER
185
188
  #
186
189
  subcommand 'deploy', 'deploy module(s). deploy all modules if under project root or a specific module if under module\'s root' do
187
- parameter '[type]', 'a module type [portlet | hook | theme | layout | ext | ejb]'
190
+ parameter '[type]', 'a module type [portlet | hook | theme | layout | ext | ejb | ear]'
188
191
  parameter '[name]', 'a module name'
189
192
  option '--skip-test', :flag, 'use this option if you want to skip module tests'
190
193
 
191
194
  def execute
192
195
  modules = []
193
- if type.nil? and !name.nil?
194
- raise RaysException.new("Cannot build type w/o name.")
196
+ if type.nil? and !name.nil? and !'ear'.eql? type
197
+ raise RaysException.new("Please specify name for #{type}")
198
+ end
199
+
200
+ if 'ear'.eql? type
201
+ name = 'application'
195
202
  end
196
203
 
197
- module_instance = nil
198
204
  if !type.nil? and !name.nil?
199
205
  module_instance = Rays::AppModule::Manager.instance.get(type, name)
200
206
  else
@@ -219,13 +225,17 @@ class RaysCommand < Clamp::Command
219
225
  # CLEANER
220
226
  #
221
227
  subcommand 'clean', 'clean module(s). clean all modules if under project root or a specific module if under module\'s root' do
222
- parameter '[type]', 'a module type [portlet | hook | theme | layout | ext | ejb]'
228
+ parameter '[type]', 'a module type [portlet | hook | theme | layout | ext | ear]'
223
229
  parameter '[name]', 'a module name'
224
230
 
225
231
  def execute
226
232
  modules = []
227
- if type.nil? and !name.nil?
228
- raise RaysException.new("Cannot build type w/o name.")
233
+ if type.nil? and !name.nil? and !'ear'.eql? type
234
+ raise RaysException.new("Please specify name for #{type}")
235
+ end
236
+
237
+ if 'ear'.eql? type
238
+ name = 'application'
229
239
  end
230
240
 
231
241
  module_instance = nil
@@ -156,6 +156,13 @@ module Rays
156
156
  end
157
157
  end
158
158
 
159
+ #
160
+ # Group ID
161
+ #
162
+ def group_id
163
+ "#{Project.instance.package}.#{type}"
164
+ end
165
+
159
166
  def path
160
167
  File.join(self.class.base_path, @name)
161
168
  end
@@ -0,0 +1,34 @@
1
+ =begin
2
+ Copyright (c) 2012 Dmitri Carpov
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ =end
23
+
24
+ module Rays
25
+ module AppModule
26
+ class EARModule < Module
27
+ register :ear
28
+ directory 'ee'
29
+ builder Worker::Manager.instance.create :builder, :ear_maven
30
+ deployer Worker::Manager.instance.create :deployer, :ear
31
+ cleaner Worker::Manager.instance.create :cleaner, :maven
32
+ end
33
+ end
34
+ end
@@ -68,7 +68,7 @@ module Rays
68
68
  unless module_class.nil?
69
69
  base_path = module_class.base_path
70
70
  in_directory(base_path) do
71
- if File.exists?(File.join(base_path, "#{name}/.module"))
71
+ if File.exists?(File.join(base_path, "#{name}/.module")) or 'ee-container'.eql? name
72
72
  app_module = module_class.new(name)
73
73
  end
74
74
  end
@@ -49,6 +49,7 @@ module Rays
49
49
  @updaters[Gem::Version.create('1.2.3')] = 'update_1_2_3'
50
50
  @updaters[Gem::Version.create('1.2.4')] = 'update_1_2_4'
51
51
  @updaters[Gem::Version.create('1.2.5')] = 'update_1_2_5'
52
+ @updaters[Gem::Version.create('1.2.6')] = 'update_1_2_6'
52
53
  end
53
54
 
54
55
  def check
@@ -128,6 +129,10 @@ module Rays
128
129
  $log.info "Update info: fixed ejb jar file path bug"
129
130
  end
130
131
 
132
+ def update_1_2_6
133
+ $log.info "Update info: added ear packaging"
134
+ end
135
+
131
136
  def sync_version version
132
137
  @rays_content.properties['version'] = version.to_s
133
138
  @rays_content.write
@@ -66,7 +66,13 @@ module Rays
66
66
  def process_pom(module_pom)
67
67
  check_parent_pom
68
68
  add_parent_pom_to module_pom
69
- enable_client_ejb module_pom
69
+ end
70
+
71
+ def process_ejb(app_module)
72
+ check_parent_pom
73
+ register_ee_module app_module
74
+ register_ear_module app_module
75
+ enable_client_ejb app_module
70
76
  end
71
77
 
72
78
  private
@@ -139,7 +145,76 @@ module Rays
139
145
  File.open(module_pom, 'w') { |file| file.write doc.to_xml }
140
146
  end
141
147
 
142
- def enable_client_ejb(module_pom)
148
+ #
149
+ # ========= EE
150
+ #
151
+ def register_ee_module(app_module)
152
+ ee_pom = get_ee_pom
153
+ module_root = app_module.path
154
+ ee_root = File.dirname ee_pom
155
+ relative_path = Pathname.new(module_root).relative_path_from(Pathname.new(ee_root)).to_s
156
+
157
+ doc = Nokogiri::XML(open(ee_pom), &:noblanks)
158
+
159
+ module_node = Nokogiri::XML::Node.new('module', doc)
160
+ module_node.content = relative_path
161
+
162
+ doc.css('project > modules > module').first.add_previous_sibling module_node
163
+
164
+ File.open(ee_pom, 'w') { |file| file.write doc.to_xml }
165
+ end
166
+
167
+ def register_ear_module(app_module)
168
+ ear_pom = get_ear_pom
169
+
170
+ doc = Nokogiri::XML(open(ear_pom), &:noblanks)
171
+
172
+
173
+ # add to dependencies
174
+ dependency_node = Nokogiri::XML::Node.new('dependency', doc)
175
+ group_id_node = Nokogiri::XML::Node.new('groupId', doc)
176
+ group_id_node.content = app_module.group_id
177
+ artifact_id_node = Nokogiri::XML::Node.new('artifactId', doc)
178
+ artifact_id_node.content = app_module.name
179
+ version_node = Nokogiri::XML::Node.new('version', doc)
180
+ version_node.content = Project.instance.version
181
+ type_node = Nokogiri::XML::Node.new('type', doc)
182
+ type_node.content = app_module.type
183
+ dependency_node.add_child group_id_node
184
+ dependency_node.add_child artifact_id_node
185
+ dependency_node.add_child version_node
186
+ dependency_node.add_child type_node
187
+
188
+ doc.css('project > dependencies').first.add_child dependency_node
189
+
190
+ # add to modules
191
+ if app_module.type.eql? 'ejb'
192
+ module_node = Nokogiri::XML::Node.new('ejbModule', doc)
193
+ group_id_node = Nokogiri::XML::Node.new('groupId', doc)
194
+ group_id_node.content = app_module.group_id
195
+ artifact_id_node = Nokogiri::XML::Node.new('artifactId', doc)
196
+ artifact_id_node.content = app_module.name
197
+ module_id_node = Nokogiri::XML::Node.new('moduleId', doc)
198
+ module_id_node.content = app_module.name
199
+ bundle_file_name_node = Nokogiri::XML::Node.new('bundleFileName', doc)
200
+ bundle_file_name_node.content = "#{app_module.name}.jar"
201
+ module_node.add_child group_id_node
202
+ module_node.add_child artifact_id_node
203
+ module_node.add_child module_id_node
204
+ module_node.add_child bundle_file_name_node
205
+
206
+ doc.css('project > build > plugins > plugin').each do |node|
207
+ next unless node.css('artifactId').first.content.eql? 'maven-ear-plugin'
208
+ node.css('configuration > modules').first.add_child module_node
209
+ end
210
+
211
+ end
212
+
213
+ File.open(ear_pom, 'w') { |file| file.write doc.to_xml }
214
+ end
215
+
216
+ def enable_client_ejb(app_module)
217
+ module_pom = File.join app_module.path, '/pom.xml'
143
218
  doc = Nokogiri::XML(open(module_pom), &:noblanks)
144
219
 
145
220
  doc.css('project > build > plugins > plugin').each do |node|
@@ -169,7 +244,88 @@ module Rays
169
244
  end
170
245
  end
171
246
 
172
- private
247
+ def get_ee_pom
248
+ ee_dir = File.join $rays_config.project_root, "ee"
249
+ FileUtils.mkdir_p ee_dir unless Dir.exists? ee_dir
250
+ ee_pom_file = File.join ee_dir, "pom.xml"
251
+
252
+ unless File.exist? ee_pom_file
253
+ builder = Nokogiri::XML::Builder.new do |xml|
254
+ xml.project(:xmlns => 'http://maven.apache.org/POM/4.0.0', :'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
255
+ :'xsi:schemaLocation' => 'http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd') {
256
+
257
+ xml.modelVersion '4.0.0'
258
+ xml.name "#{Project.instance.name} EE Parent"
259
+ xml.groupId "#{Project.instance.package}"
260
+ xml.artifactId "ee-parent"
261
+ xml.packaging 'pom'
262
+
263
+ xml.modules {
264
+ xml.module 'ear'
265
+ }
266
+ }
267
+ end
268
+
269
+ File.open(ee_pom_file, 'w') { |file| file.write builder.to_xml }
270
+ add_parent_pom_to ee_pom_file
271
+ end
272
+
273
+ ee_pom_file
274
+ end
275
+
276
+ def get_ear_pom
277
+ ear_dir = File.join $rays_config.project_root, "ee/ear"
278
+ FileUtils.mkdir_p ear_dir unless Dir.exists? ear_dir
279
+ ear_pom_file = File.join ear_dir, 'pom.xml'
280
+
281
+ unless File.exist? ear_pom_file
282
+ builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
283
+ xml.project(:xmlns => 'http://maven.apache.org/POM/4.0.0', :'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
284
+ :'xsi:schemaLocation' => 'http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd') {
285
+
286
+ xml.modelVersion '4.0.0'
287
+
288
+ xml._parent do
289
+ xml.groupId "#{Project.instance.package}"
290
+ xml.artifactId 'ee-parent'
291
+ xml.version "#{Project.instance.version}"
292
+ xml.relativePath '../pom.xml'
293
+ end
294
+
295
+ xml.name "#{Project.instance.name} EE Container"
296
+ xml.groupId "#{Project.instance.package}.ear"
297
+ xml.artifactId 'application'
298
+ xml.packaging 'ear'
299
+
300
+ xml.dependencies
301
+
302
+ xml.build {
303
+ xml.plugins {
304
+ xml.plugin {
305
+ xml.groupId 'org.apache.maven.plugins'
306
+ xml.artifactId 'maven-ear-plugin'
307
+
308
+ xml.configuration {
309
+ xml.defaultJavaBundleDir 'APP-INF/lib'
310
+ xml.modules
311
+ }
312
+ }
313
+ }
314
+ }
315
+ }
316
+ end
317
+
318
+ doc = Nokogiri::XML(builder.to_xml, &:noblanks)
319
+ doc.css('project > _parent').first.name = 'parent'
320
+
321
+ File.open(ear_pom_file, 'w') { |file| file.write doc.to_xml }
322
+
323
+ end
324
+
325
+ ear_pom_file
326
+ end
327
+
328
+
173
329
  def parent_group_id
174
330
  "#{Project.instance.package}.#{Project.instance.name}"
175
331
  end
@@ -39,6 +39,23 @@ module Rays
39
39
  end
40
40
  end
41
41
 
42
+ # EAR Maven builder
43
+ class EARMaven < BaseWorker
44
+ register :builder, :ear_maven
45
+ include Singleton
46
+
47
+ def build(app_module, skip_test = false)
48
+ execute('build', app_module) do
49
+ test_args = ''
50
+ test_args = '-Dmaven.skip.tests=true' if skip_test
51
+
52
+ rays_exec("#{$rays_config.mvn} clean")
53
+ $log.info("Installing EE modules to the local repository")
54
+ rays_exec("#{$rays_config.mvn} install #{test_args}")
55
+ end
56
+ end
57
+ end
58
+
42
59
  # EJB Maven builder
43
60
  class EJBMaven < BaseWorker
44
61
  register :builder, :ejb_maven
@@ -46,6 +46,26 @@ module Rays
46
46
  end
47
47
  end
48
48
 
49
+ # EAR deployer
50
+ class EJBDeploy < BaseWorker
51
+ register :deployer, :ear
52
+
53
+ include Singleton
54
+
55
+ def deploy(app_module)
56
+ execute('deploy', app_module) do
57
+ env = $rays_config.environment
58
+ file_to_deploy = File.expand_path("./ear/target/#{app_module.name}-#{Project.instance.version}.ear")
59
+ file_to_deploy = File.expand_path("./ear/target/#{app_module.name}.ear") unless File.exists? file_to_deploy
60
+ if env.liferay.remote?
61
+ env.liferay.remote.copy_to(file_to_deploy, env.liferay.service.deploy)
62
+ else
63
+ FileUtils.cp(file_to_deploy, env.liferay.service.deploy)
64
+ end
65
+ end
66
+ end
67
+ end
68
+
49
69
  # EJB deployer
50
70
  class EJBDeploy < BaseWorker
51
71
  register :deployer, :ejb
@@ -58,14 +58,12 @@ module Rays
58
58
  " -DarchetypeGroupId=org.codehaus.mojo.archetypes" <<
59
59
  " -DarchetypeArtifactId=ejb-javaee6" <<
60
60
  " -DarchetypeVersion=1.5" <<
61
- " -DgroupId=#{Project.instance.package}.#{app_module.type}" <<
61
+ " -DgroupId=#{app_module.group_id}" <<
62
62
  " -DartifactId=#{app_module.name}" <<
63
63
  " -Dversion=#{Project.instance.version}" <<
64
64
  " -Dpackaging=war -B"
65
65
  rays_exec(create_cmd)
66
- Utils::FileUtils.find_down(app_module.path, 'pom\.xml').each do |pom_file|
67
- MavenUtil.process_pom pom_file
68
- end
66
+ MavenUtil.process_ejb app_module
69
67
  end
70
68
  end
71
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raystool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-08 00:00:00.000000000 Z
12
+ date: 2012-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
16
- requirement: &83529160 !ruby/object:Gem::Requirement
16
+ requirement: &85713630 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *83529160
24
+ version_requirements: *85713630
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rsolr
27
- requirement: &83528940 !ruby/object:Gem::Requirement
27
+ requirement: &85713410 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *83528940
35
+ version_requirements: *85713410
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: colorize
38
- requirement: &83528730 !ruby/object:Gem::Requirement
38
+ requirement: &85713200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *83528730
46
+ version_requirements: *85713200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: net-ssh
49
- requirement: &83528520 !ruby/object:Gem::Requirement
49
+ requirement: &85712990 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *83528520
57
+ version_requirements: *85712990
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: highline
60
- requirement: &83528310 !ruby/object:Gem::Requirement
60
+ requirement: &85712780 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *83528310
68
+ version_requirements: *85712780
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: safe_shell
71
- requirement: &83528100 !ruby/object:Gem::Requirement
71
+ requirement: &85712570 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *83528100
79
+ version_requirements: *85712570
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: nokogiri
82
- requirement: &83527890 !ruby/object:Gem::Requirement
82
+ requirement: &85712360 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *83527890
90
+ version_requirements: *85712360
91
91
  description: Command line tool to create and manage liferay projects
92
92
  email: dmitri.carpov@gmail.com
93
93
  executables:
@@ -103,6 +103,7 @@ files:
103
103
  - lib/rays/models/appmodule/ejb.rb
104
104
  - lib/rays/models/appmodule/ext.rb
105
105
  - lib/rays/models/appmodule/manager.rb
106
+ - lib/rays/models/appmodule/ear.rb
106
107
  - lib/rays/models/appmodule/base.rb
107
108
  - lib/rays/models/appmodule/servicebuilder.rb
108
109
  - lib/rays/models/appmodule/hook.rb