kody 0.0.2
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.
- checksums.yaml +7 -0
- data/bin/kody +41 -0
- data/lib/kody.rb +58 -0
- data/lib/kody/app.rb +73 -0
- data/lib/kody/builder/attribute_builder.rb +88 -0
- data/lib/kody/builder/class_builder.rb +159 -0
- data/lib/kody/builder/project_builder.rb +15 -0
- data/lib/kody/builder/relation_builder.rb +110 -0
- data/lib/kody/engine/demoiselle/datatype.rb +93 -0
- data/lib/kody/engine/demoiselle/demoiselle.rb +320 -0
- data/lib/kody/engine/demoiselle/templates/beans.xml.tpl +4 -0
- data/lib/kody/engine/demoiselle/templates/businnes.tpl +14 -0
- data/lib/kody/engine/demoiselle/templates/entity.tpl +62 -0
- data/lib/kody/engine/demoiselle/templates/enumeration.tpl +28 -0
- data/lib/kody/engine/demoiselle/templates/exemplo.xmi +123 -0
- data/lib/kody/engine/demoiselle/templates/messages.tpl +7 -0
- data/lib/kody/engine/demoiselle/templates/persistence.tpl +13 -0
- data/lib/kody/engine/demoiselle/templates/persistence.xml.tpl +23 -0
- data/lib/kody/engine/demoiselle/templates/pom.xml.tpl +46 -0
- data/lib/kody/engine/demoiselle/templates/view_edit.tpl +42 -0
- data/lib/kody/engine/demoiselle/templates/view_list.tpl +46 -0
- data/lib/kody/engine/demoiselle/templates/view_mb_edit.tpl +48 -0
- data/lib/kody/engine/demoiselle/templates/view_mb_list.tpl +47 -0
- data/lib/kody/engine/generic/generic.rb +151 -0
- data/lib/kody/model.rb +20 -0
- data/lib/kody/modules.rb +19 -0
- data/lib/kody/parser.rb +13 -0
- data/lib/kody/properties.rb +41 -0
- data/lib/kody/string.rb +16 -0
- data/lib/kody/util.rb +17 -0
- metadata +174 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class Relation
|
4
|
+
|
5
|
+
attr_reader :annotations
|
6
|
+
attr_reader :imports
|
7
|
+
|
8
|
+
# UmlAssociationEnd
|
9
|
+
def initialize(uml_class_from, uml_association_end, model, type, nullable = true)
|
10
|
+
|
11
|
+
@type = type
|
12
|
+
@nullable = nullable
|
13
|
+
|
14
|
+
@name = uml_association_end.name
|
15
|
+
@fetch = nil
|
16
|
+
|
17
|
+
@visibility = uml_association_end.visibility
|
18
|
+
@visibility = "private" if @visibility.empty?
|
19
|
+
|
20
|
+
participant = model.find_recursive_class_by_id(uml_association_end.participant)
|
21
|
+
@uml_class_name_to = participant.name unless participant.nil?
|
22
|
+
|
23
|
+
@name = @uml_class_name_to.lower_camel_case if @name.empty? && !@uml_class_name_to.nil?
|
24
|
+
|
25
|
+
@annotations = Array.new
|
26
|
+
@imports = Array.new
|
27
|
+
|
28
|
+
class_to_under = @uml_class_name_to.underscore
|
29
|
+
class_from_under = uml_class_from.name.underscore
|
30
|
+
|
31
|
+
case type
|
32
|
+
|
33
|
+
when "OneToOne"
|
34
|
+
@att_type = @uml_class_name_to
|
35
|
+
|
36
|
+
when "ManyToOne"
|
37
|
+
@join_column_name = "#{@name}_fk"
|
38
|
+
@att_type = @uml_class_name_to
|
39
|
+
@target_entity = "#{@uml_class_name_to}.class"
|
40
|
+
|
41
|
+
@annotations << "@ManyToOne(targetEntity=#{@uml_class_name_to}.class)"
|
42
|
+
@annotations << "@JoinColumn(name = \"#{class_to_under}_fk\", nullable = #{@nullable})"
|
43
|
+
|
44
|
+
@imports << "javax.persistence.ManyToOne"
|
45
|
+
@imports << "javax.persistence.JoinColumn"
|
46
|
+
|
47
|
+
when "OneToMany"
|
48
|
+
@att_type = "List<#{@uml_class_name_to}>"
|
49
|
+
@initialize = " = new ArrayList<#{@uml_class_name_to}>()"
|
50
|
+
|
51
|
+
@annotations << '@OneToMany(mappedBy="' + class_from_under + '")'
|
52
|
+
@imports << "javax.persistence.OneToMany"
|
53
|
+
@imports << "java.util.ArrayList"
|
54
|
+
@imports << "java.util.List"
|
55
|
+
|
56
|
+
when "ManyToMany"
|
57
|
+
@att_type = "List<#{@uml_class_name_to}>"
|
58
|
+
@initialize = " = new ArrayList<#{@uml_class_name_to}>()"
|
59
|
+
@imports << "java.util.ArrayList"
|
60
|
+
@imports << "java.util.List"
|
61
|
+
|
62
|
+
if uml_association_end.first
|
63
|
+
join_table = "#{class_to_under}_#{class_from_under}"
|
64
|
+
else
|
65
|
+
join_table = "#{class_from_under}_#{class_to_under}"
|
66
|
+
end
|
67
|
+
|
68
|
+
join_column = "#{class_from_under}_fk"
|
69
|
+
inverse_join_column = "#{class_to_under}_fk"
|
70
|
+
|
71
|
+
@annotations << "@ManyToMany(targetEntity=#{@uml_class_name_to}.class)"
|
72
|
+
@annotations << '@JoinTable(name = "' +
|
73
|
+
join_table + '", joinColumns = { @JoinColumn(name = "' +
|
74
|
+
join_column + '") }, inverseJoinColumns = { @JoinColumn(name = "' +
|
75
|
+
inverse_join_column + '") })'
|
76
|
+
|
77
|
+
@imports << "javax.persistence.ManyToMany"
|
78
|
+
@imports << "javax.persistence.JoinTable"
|
79
|
+
@imports << "javax.persistence.JoinColumn"
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
uml_association_end.tagged_values.each do |t|
|
84
|
+
#puts "Tag: " + t.name + ", " + t.value
|
85
|
+
|
86
|
+
case t.name
|
87
|
+
when '@andromda.hibernate.cascade'
|
88
|
+
@cascade = Datatype.cascade(t.value)
|
89
|
+
|
90
|
+
when '@andromda.hibernate.orderByColumns'
|
91
|
+
@imports << "javax.persistence.OrderBy"
|
92
|
+
@annotations << '@OrderBy("' + t.value + '")'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def to_liquid
|
99
|
+
{
|
100
|
+
'annotations'=>@annotations,
|
101
|
+
'att_type'=>@att_type,
|
102
|
+
'name'=>@name,
|
103
|
+
'initialize'=>@initialize,
|
104
|
+
'visibility'=>@visibility,
|
105
|
+
'uml_class_to'=>@uml_class_name_to,
|
106
|
+
'type'=>@type
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
|
2
|
+
class Datatype
|
3
|
+
|
4
|
+
def Datatype.java_type(type)
|
5
|
+
types = {
|
6
|
+
|
7
|
+
# UML Standard Profile
|
8
|
+
'UML Standard Profile::boolean' => "boolean",
|
9
|
+
'UML Standard Profile::byte' => "byte",
|
10
|
+
'UML Standard Profile::char' => "char",
|
11
|
+
'UML Standard Profile::date' => "java.util.Date",
|
12
|
+
'UML Standard Profile::double' => "double",
|
13
|
+
'UML Standard Profile::float' => "float",
|
14
|
+
'UML Standard Profile::Integer' => "Integer",
|
15
|
+
'UML Standard Profile::int' => "int",
|
16
|
+
'UML Standard Profile::long' => "long",
|
17
|
+
'UML Standard Profile::short' => "short",
|
18
|
+
|
19
|
+
# AndroMda 3.1
|
20
|
+
'datatype::Blob' => "java.sql.Blob",
|
21
|
+
'datatype::boolean' => "boolean",
|
22
|
+
'datatype::Boolean' => "Boolean",
|
23
|
+
'datatype::boolean[]' => "boolean[]",
|
24
|
+
'datatype::Boolean[]' => "Boolean[]",
|
25
|
+
'datatype::byte' => "byte",
|
26
|
+
'datatype::Byte' => "Byte",
|
27
|
+
'datatype::Byte[]' => "Byte[]",
|
28
|
+
'datatype::byte[]' => "byte[]",
|
29
|
+
'datatype::char' => "char",
|
30
|
+
'datatype::char[]' => "char[]",
|
31
|
+
'datatype::Character' => "Character",
|
32
|
+
'datatype::Character[]' => "Character[]",
|
33
|
+
'datatype::Clob' => "String",
|
34
|
+
'datatype::Collection' => "java.util.Collection",
|
35
|
+
'datatype::Date' => "java.util.Date",
|
36
|
+
'datatype::Date[]' => "java.util.Date[]",
|
37
|
+
'datatype::DateTime' => "java.util.Date",
|
38
|
+
'datatype::DateTime[]' => "java.util.Date[]",
|
39
|
+
'datatype::Decimal' => "java.math.BigDecimal",
|
40
|
+
'datatype::Decimal[]' => "java.math.BigDecimal[]",
|
41
|
+
'datatype::Document' => "org.w3c.dom.Document",
|
42
|
+
'datatype::Double' => "Double",
|
43
|
+
'datatype::double' => "double",
|
44
|
+
'datatype::Double[]' => "Double[]",
|
45
|
+
'datatype::double[]' => "double[]",
|
46
|
+
'datatype::File' => "java.io.File",
|
47
|
+
'datatype::File[]' => "java.io.File[]",
|
48
|
+
'datatype::float' => "float",
|
49
|
+
'datatype::Float' => "Float",
|
50
|
+
'datatype::float[]' => "float[]",
|
51
|
+
'datatype::Float[]' => "Float[]",
|
52
|
+
'datatype::int' => "int",
|
53
|
+
'datatype::int[]' => "int[]",
|
54
|
+
'datatype::Integer' => "Integer",
|
55
|
+
'datatype::Integer[]' => "Integer[]",
|
56
|
+
'datatype::List' => "java.util.List",
|
57
|
+
'datatype::long' => "long",
|
58
|
+
'datatype::Long' => "Long",
|
59
|
+
'datatype::Long[]' => "Long[]",
|
60
|
+
'datatype::long[]' => "long[]",
|
61
|
+
'datatype::Map' => "java.util.Map",
|
62
|
+
'datatype::Mappings' => "java.util.Map",
|
63
|
+
'datatype::Money' => "java.math.BigDecimal",
|
64
|
+
'datatype::Object' => "Object",
|
65
|
+
'datatype::Object[]' => "Object[]",
|
66
|
+
'datatype::Set' => "java.util.Set",
|
67
|
+
'datatype::short' => "short",
|
68
|
+
'datatype::Short' => "Short",
|
69
|
+
'datatype::short[]' => "short[]",
|
70
|
+
'datatype::Short[]' => "Short[]",
|
71
|
+
'datatype::String' => "String",
|
72
|
+
'datatype::String[]' => "String[]",
|
73
|
+
'datatype::Time' => "java.util.Date",
|
74
|
+
'datatype::Time[]' => "java.util.Date[]",
|
75
|
+
'datatype::Timestamp' => "java.util.Date",
|
76
|
+
'datatype::Timestamp[]' => "java.util.Date[]",
|
77
|
+
'datatype::TreeNode' => "Object",
|
78
|
+
'datatype::URI' => "java.net.URI",
|
79
|
+
'datatype::URI[]' => "java.net.URI[]",
|
80
|
+
'datatype::URL' => "java.net.URL",
|
81
|
+
'datatype::URL[]' => "java.net.URL[]",
|
82
|
+
'datatype::void' => "void"
|
83
|
+
}
|
84
|
+
|
85
|
+
convert_type = types[type]
|
86
|
+
convert_type = type if convert_type.nil?
|
87
|
+
convert_type
|
88
|
+
end
|
89
|
+
|
90
|
+
def Datatype.short_java_type(type)
|
91
|
+
convert_type = Datatype.convert_type(type)
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,320 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'liquid'
|
3
|
+
require 'kody/modules'
|
4
|
+
require 'kody/string'
|
5
|
+
require 'kody/properties'
|
6
|
+
require 'kody/builder/class_builder'
|
7
|
+
require 'kody/builder/project_builder'
|
8
|
+
require 'kody/engine/demoiselle/datatype'
|
9
|
+
|
10
|
+
class Demoiselle
|
11
|
+
|
12
|
+
attr_accessor :output
|
13
|
+
attr_accessor :model
|
14
|
+
attr_accessor :properties
|
15
|
+
|
16
|
+
def initialize(model=nil)
|
17
|
+
@output = Dir.pwd
|
18
|
+
@hash = Hash.new
|
19
|
+
|
20
|
+
@model = model
|
21
|
+
if !model.nil?
|
22
|
+
@properties = Properties.load(@output)
|
23
|
+
initialize_builders
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(model, properties)
|
28
|
+
@output = Dir.pwd
|
29
|
+
@hash = Hash.new
|
30
|
+
@properties = properties
|
31
|
+
@model = model
|
32
|
+
if !model.nil?
|
33
|
+
initialize_builders
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def name
|
38
|
+
return "Demoiselle"
|
39
|
+
end
|
40
|
+
|
41
|
+
def version
|
42
|
+
return "2.3.2"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Cria um novo projeto
|
46
|
+
def create_project(params)
|
47
|
+
|
48
|
+
create_dirs(params)
|
49
|
+
create_properties_file(params)
|
50
|
+
create_maven_project(params)
|
51
|
+
#generate_pom_xml(params)
|
52
|
+
|
53
|
+
App.logger.info "Project #{params[:project_name]} created."
|
54
|
+
end
|
55
|
+
|
56
|
+
def generate
|
57
|
+
generate_domain
|
58
|
+
generate_enumerations
|
59
|
+
generate_businnes
|
60
|
+
generate_persistence_xml
|
61
|
+
end
|
62
|
+
|
63
|
+
# Cria o arquivo de configuração do maven
|
64
|
+
def generate_pom_xml params
|
65
|
+
template = load_template("pom.xml.tpl")
|
66
|
+
path = output + "/" + params[:project_name] + "/" + params[:project_type] + "/"
|
67
|
+
file_name = "pom.xml"
|
68
|
+
|
69
|
+
rendered = template.render(
|
70
|
+
'project' => ProjectBuilder.new(params[:project_group], params[:project_name]))
|
71
|
+
save(rendered, path, file_name)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Gera os Beans e os DAOs
|
75
|
+
def generate_domain
|
76
|
+
@entities.each do |e|
|
77
|
+
generate_class(e)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Gera as enumerações
|
82
|
+
def generate_enumerations
|
83
|
+
@enumerations.each do |e|
|
84
|
+
generate_class(e)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Gera as classes da camada de negócio baseada nas entidades
|
89
|
+
def generate_businnes
|
90
|
+
@entities.each do |e|
|
91
|
+
generate_bc(e)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Gera o arquivo de configuração do JPA
|
96
|
+
def generate_persistence_xml
|
97
|
+
template = load_template("persistence.xml.tpl")
|
98
|
+
path = output + "/src/main/resources/META-INF/"
|
99
|
+
file_name = "persistence.xml"
|
100
|
+
rendered = template.render('classes' => @entities)
|
101
|
+
save(rendered, path, file_name)
|
102
|
+
path = output + "/src/test/resources/META-INF/"
|
103
|
+
save(rendered, path, file_name)
|
104
|
+
end
|
105
|
+
|
106
|
+
public
|
107
|
+
def convert_type(type)
|
108
|
+
Datatype.java_type(type)
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
def initialize_builders
|
113
|
+
App.logger.info "Initializing builders..."
|
114
|
+
|
115
|
+
@entities = Array.new
|
116
|
+
@enumerations = Array.new
|
117
|
+
|
118
|
+
@model.classes.each do |clazz|
|
119
|
+
initialize_class(clazz)
|
120
|
+
end
|
121
|
+
|
122
|
+
App.logger.info "Builders initialized"
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
def initialize_package(package)
|
127
|
+
|
128
|
+
#App.logger.debug "Package: #{package.name}"
|
129
|
+
package.classes.sort.each do |c|
|
130
|
+
initialize_class(c)
|
131
|
+
end
|
132
|
+
|
133
|
+
package.packages.sort.each do |p|
|
134
|
+
initialize_package(p)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
private
|
139
|
+
def initialize_class(clazz)
|
140
|
+
|
141
|
+
#App.logger.debug "Class: #{clazz.name}"
|
142
|
+
class_builder = ClassBuilder.new(clazz, self)
|
143
|
+
|
144
|
+
case class_builder.stereotype
|
145
|
+
when :entity
|
146
|
+
@entities << class_builder
|
147
|
+
when :enumeration
|
148
|
+
@enumerations << class_builder
|
149
|
+
else
|
150
|
+
return
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
private
|
155
|
+
def generate_class(clazz)
|
156
|
+
|
157
|
+
@hash['class'] = clazz
|
158
|
+
generate_classes(clazz)
|
159
|
+
generate_dao(clazz)
|
160
|
+
end
|
161
|
+
|
162
|
+
private
|
163
|
+
def load_template(template_name)
|
164
|
+
@templates = Hash.new if @templates.nil?
|
165
|
+
return @templates[template_name] if !(@templates[template_name]).nil?
|
166
|
+
|
167
|
+
full_template_name = File.expand_path File.dirname(__FILE__) + "/templates/" + template_name
|
168
|
+
arquivo_template = File.read(full_template_name)
|
169
|
+
template = Liquid::Template.parse(arquivo_template)
|
170
|
+
Liquid::Template.register_filter(TextFilter)
|
171
|
+
|
172
|
+
@templates[template_name] = template
|
173
|
+
|
174
|
+
App.logger.info "Template '#{template_name}' loaded..."
|
175
|
+
|
176
|
+
return template
|
177
|
+
end
|
178
|
+
|
179
|
+
private
|
180
|
+
def generate_classes(clazz)
|
181
|
+
|
182
|
+
case clazz.stereotype
|
183
|
+
when :entity
|
184
|
+
template = load_template("entity.tpl")
|
185
|
+
when :enumeration
|
186
|
+
template = load_template("enumeration.tpl")
|
187
|
+
else
|
188
|
+
return
|
189
|
+
end
|
190
|
+
|
191
|
+
@rendered = template.render(@hash)
|
192
|
+
path = output + "/src/main/java/" + clazz.package.gsub(".", "/") + "/"
|
193
|
+
file_name = clazz.name + ".java"
|
194
|
+
save(@rendered, path, file_name)
|
195
|
+
end
|
196
|
+
|
197
|
+
private
|
198
|
+
def generate_dao(clazz)
|
199
|
+
if clazz.stereotype == :entity
|
200
|
+
template = load_template("persistence.tpl")
|
201
|
+
|
202
|
+
@rendered = template.render(@hash)
|
203
|
+
|
204
|
+
path = output + "/src/main/java/" + clazz.persistence_package.gsub(".", "/") + "/"
|
205
|
+
file_name = clazz.name + "DAO.java"
|
206
|
+
save(@rendered, path, file_name)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def generate_bc(clazz)
|
211
|
+
if clazz.stereotype == :entity
|
212
|
+
|
213
|
+
@hash['class'] = clazz
|
214
|
+
|
215
|
+
template = load_template("businnes.tpl")
|
216
|
+
@rendered = template.render(@hash)
|
217
|
+
|
218
|
+
path = output + "/src/main/java/" + clazz.business_package.gsub(".", "/") + "/"
|
219
|
+
file_name = clazz.name + "BC.java"
|
220
|
+
save(@rendered, path, file_name)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def generate_view
|
225
|
+
template = load_template("view_mb_list.tpl")
|
226
|
+
@rendered = template.render(@hash)
|
227
|
+
|
228
|
+
path = output + "/src/main/java/" + clazz.view_package.gsub(".", "/") + "/"
|
229
|
+
file_name = clazz.name + "ListMB.java"
|
230
|
+
save(@rendered, path, file_name)
|
231
|
+
|
232
|
+
template = load_template("view_mb_edit.tpl")
|
233
|
+
@rendered = template.render(@hash)
|
234
|
+
|
235
|
+
path = output + "/src/main/java/" + clazz.view_package.gsub(".", "/") + "/"
|
236
|
+
file_name = clazz.name + "EditMB.java"
|
237
|
+
save(@rendered, path, file_name)
|
238
|
+
end
|
239
|
+
|
240
|
+
def generate_web
|
241
|
+
template = load_template("view_list.tpl")
|
242
|
+
@hash["managed_bean"] = clazz.name.lower_camel_case + "ListMB"
|
243
|
+
@rendered = template.render(@hash)
|
244
|
+
|
245
|
+
path = output + "/src/main/webapp/"
|
246
|
+
file_name = clazz.name.underscore + "_list.xhtml"
|
247
|
+
save(@rendered, path, file_name)
|
248
|
+
|
249
|
+
template = load_template("view_edit.tpl")
|
250
|
+
@rendered = template.render(@hash)
|
251
|
+
|
252
|
+
path = output + "/src/main/webapp/"
|
253
|
+
file_name = clazz.name.underscore + "_edit.xhtml"
|
254
|
+
save(@rendered, path, file_name)
|
255
|
+
end
|
256
|
+
|
257
|
+
def generate_messages(classes)
|
258
|
+
template = load_template("messages.tpl")
|
259
|
+
@rendered = template.render('classes' => classes)
|
260
|
+
|
261
|
+
path = output + "/src/main/resources/"
|
262
|
+
file_name = "messages2.properties"
|
263
|
+
|
264
|
+
save(@rendered, path, file_name)
|
265
|
+
end
|
266
|
+
|
267
|
+
private
|
268
|
+
|
269
|
+
def save(content, path, file_name)
|
270
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
271
|
+
|
272
|
+
file = File.new("#{path}#{file_name}", "w")
|
273
|
+
file.write(content)
|
274
|
+
file.close
|
275
|
+
|
276
|
+
App.logger.debug "Template saved in #{path}#{file_name}"
|
277
|
+
end
|
278
|
+
|
279
|
+
def create_dirs(params)
|
280
|
+
path = "#{@output}/#{params[:project_name]}"
|
281
|
+
FileUtils.mkdir_p(path)
|
282
|
+
FileUtils.mkdir_p("#{path}/mda")
|
283
|
+
FileUtils.mkdir_p("#{path}/templates")
|
284
|
+
FileUtils.mkdir_p("#{path}/project")
|
285
|
+
end
|
286
|
+
|
287
|
+
def create_properties_file(params)
|
288
|
+
|
289
|
+
path = "#{@output}/#{params[:project_name]}"
|
290
|
+
|
291
|
+
project_name = params[:project_name]
|
292
|
+
project_group = params[:project_group]
|
293
|
+
|
294
|
+
properties = Hash.new
|
295
|
+
params.each do |propertie, value|
|
296
|
+
properties[propertie.gsub("_", ".")] = value
|
297
|
+
end
|
298
|
+
properties["project.persistence.package"] = "#{project_group}.#{project_name}.persistence"
|
299
|
+
properties["project.business.package"] = "#{project_group}.#{project_name}.business"
|
300
|
+
Properties.create(path, properties)
|
301
|
+
end
|
302
|
+
|
303
|
+
def create_maven_project(params)
|
304
|
+
project_name = params[:project_name]
|
305
|
+
project_group = params[:project_group]
|
306
|
+
Dir.chdir("#{@output}/#{project_name}/project")
|
307
|
+
|
308
|
+
command = "mvn archetype:generate -DgroupId=#{project_group} -DartifactId=#{project_name}"
|
309
|
+
command = "#{command} -DarchetypeGroupId=br.gov.frameworkdemoiselle.archetypes"
|
310
|
+
command = "#{command} -DarchetypeArtifactId=demoiselle-minimal"
|
311
|
+
command = "#{command} -DarchetypeVersion=#{version} -DinteractiveMode=false"
|
312
|
+
|
313
|
+
App.logger.info "Criando projeto maven..."
|
314
|
+
system command
|
315
|
+
if !$?.nil? && $?.exitstatus != 0
|
316
|
+
raise "Falha ao criar o projeto com maven.\n#{command}"
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
end
|