blufin 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 (113) hide show
  1. checksums.yaml +7 -0
  2. data/bin/bf +5 -0
  3. data/bin/blufin +5 -0
  4. data/lib/blufin.rb +245 -0
  5. data/lib/core/code_scanners/common/scanner_common.rb +83 -0
  6. data/lib/core/code_scanners/common/scanner_java.rb +106 -0
  7. data/lib/core/code_scanners/scanner_java_embedded_objects.rb +386 -0
  8. data/lib/core/code_scanners/scanner_java_enums.rb +125 -0
  9. data/lib/core/code_scanners/scanner_java_source.rb +29 -0
  10. data/lib/core/code_scanners/scanner_java_tests.rb +157 -0
  11. data/lib/core/error_handling/schema_error.rb +9 -0
  12. data/lib/core/error_handling/sql_error.rb +21 -0
  13. data/lib/core/error_handling/sql_error_handler.rb +149 -0
  14. data/lib/core/error_handling/yml_error.rb +21 -0
  15. data/lib/core/error_handling/yml_error_handler.rb +437 -0
  16. data/lib/core/mysql.rb +347 -0
  17. data/lib/core/opt.rb +21 -0
  18. data/lib/core/site/site.rb +26 -0
  19. data/lib/core/site/site_auth.rb +88 -0
  20. data/lib/core/site/site_embedded.rb +27 -0
  21. data/lib/core/site/site_ports.rb +9 -0
  22. data/lib/core/site/site_resolver.rb +276 -0
  23. data/lib/core/site/site_services.rb +162 -0
  24. data/lib/core/site/site_ui.rb +16 -0
  25. data/lib/core/yml/config/yml_config_validator.rb +219 -0
  26. data/lib/core/yml/maven/yml_maven_validator.rb +1132 -0
  27. data/lib/core/yml/resource/yml_resource_validator.rb +154 -0
  28. data/lib/core/yml/schema/yml_schema_flags.rb +9 -0
  29. data/lib/core/yml/schema/yml_schema_validator.rb +1850 -0
  30. data/lib/core/yml/yml_cache_handler.rb +115 -0
  31. data/lib/core/yml/yml_common.rb +487 -0
  32. data/lib/core/yml/yml_meta_writer_base.rb +300 -0
  33. data/lib/core/yml/yml_outputter.rb +307 -0
  34. data/lib/core/yml/yml_validator_base.rb +630 -0
  35. data/lib/core/yml_writers/yml_configuration_writer.rb +40 -0
  36. data/lib/core/yml_writers/yml_java_api_resource_writer.rb +348 -0
  37. data/lib/core/yml_writers/yml_java_cron_type_writer.rb +113 -0
  38. data/lib/core/yml_writers/yml_java_css_dependency_writer.rb +59 -0
  39. data/lib/core/yml_writers/yml_java_dao_writer.rb +364 -0
  40. data/lib/core/yml_writers/yml_java_dto_writer.rb +251 -0
  41. data/lib/core/yml_writers/yml_java_embedded_object_writer.rb +968 -0
  42. data/lib/core/yml_writers/yml_java_enum_writer.rb +161 -0
  43. data/lib/core/yml_writers/yml_java_js_dependency_writer.rb +59 -0
  44. data/lib/core/yml_writers/yml_java_message_type_writer.rb +106 -0
  45. data/lib/core/yml_writers/yml_java_meta_writer.rb +173 -0
  46. data/lib/core/yml_writers/yml_java_model_writer.rb +510 -0
  47. data/lib/core/yml_writers/yml_java_pom_writer.rb +1050 -0
  48. data/lib/core/yml_writers/yml_java_resource_data_writer.rb +251 -0
  49. data/lib/core/yml_writers/yml_java_sdk_writer.rb +732 -0
  50. data/lib/core/yml_writers/yml_java_validator_writer.rb +280 -0
  51. data/lib/core/yml_writers/yml_java_worker_writer.rb +81 -0
  52. data/lib/core/yml_writers/yml_sql_structure_writer.rb +307 -0
  53. data/lib/core/yml_writers/yml_sql_template_writer.rb +243 -0
  54. data/lib/core/yml_writers/yml_vue_service_writer.rb +170 -0
  55. data/lib/core/yml_writers/yml_writer_base.rb +114 -0
  56. data/lib/routes/api_list.rb +35 -0
  57. data/lib/routes/api_meta.rb +59 -0
  58. data/lib/routes/build.rb +46 -0
  59. data/lib/routes/create/create_api.rb +35 -0
  60. data/lib/routes/create/create_ui.rb +84 -0
  61. data/lib/routes/export.rb +56 -0
  62. data/lib/routes/generate/generate_api.rb +225 -0
  63. data/lib/routes/generate/generate_img_favicon.rb +56 -0
  64. data/lib/routes/generate/generate_img_landing.rb +94 -0
  65. data/lib/routes/generate/generate_lambda.rb +43 -0
  66. data/lib/routes/lint.rb +35 -0
  67. data/lib/routes/mysql_reset.rb +43 -0
  68. data/lib/routes/release_blufin.rb +351 -0
  69. data/lib/routes/run.rb +35 -0
  70. data/lib/version.rb +1 -0
  71. data/opt/README.MD +2 -0
  72. data/opt/config/schema.yml +73 -0
  73. data/opt/config/template.yml +25 -0
  74. data/opt/sql/data/config/data-client.sql +7 -0
  75. data/opt/sql/data/config/data-db-configuration-property.sql +47 -0
  76. data/opt/sql/data/config/data-db-configuration.sql +9 -0
  77. data/opt/sql/data/config/data-db.sql +175 -0
  78. data/opt/sql/data/config/data-profile-api.sql +47 -0
  79. data/opt/sql/data/config/data-profile-cron.sql +0 -0
  80. data/opt/sql/data/config/data-profile-worker.sql +0 -0
  81. data/opt/sql/data/config/data-profile.sql +87 -0
  82. data/opt/sql/data/config/data-project.sql +95 -0
  83. data/opt/sql/structure/blufin-master-structure-fks.sql +65 -0
  84. data/opt/sql/structure/blufin-master-structure.sql +97 -0
  85. data/opt/sql/structure/blufin-mock-structure-fks.sql +38 -0
  86. data/opt/sql/structure/blufin-mock-structure.sql +98 -0
  87. data/opt/sql/templates/config/template-client.sql +7 -0
  88. data/opt/sql/templates/config/template-db-configuration-property.sql +11 -0
  89. data/opt/sql/templates/config/template-db-configuration.sql +9 -0
  90. data/opt/sql/templates/config/template-db.sql +21 -0
  91. data/opt/sql/templates/config/template-profile-api.sql +11 -0
  92. data/opt/sql/templates/config/template-profile-cron.sql +7 -0
  93. data/opt/sql/templates/config/template-profile-worker.sql +7 -0
  94. data/opt/sql/templates/config/template-profile.sql +21 -0
  95. data/opt/sql/templates/config/template-project.sql +23 -0
  96. data/opt/yml/api/schema/config/client.yml +14 -0
  97. data/opt/yml/api/schema/config/db.yml +45 -0
  98. data/opt/yml/api/schema/config/db_configuration.yml +22 -0
  99. data/opt/yml/api/schema/config/db_configuration_property.yml +22 -0
  100. data/opt/yml/api/schema/config/profile.yml +53 -0
  101. data/opt/yml/api/schema/config/profile_api.yml +22 -0
  102. data/opt/yml/api/schema/config/profile_cron.yml +14 -0
  103. data/opt/yml/api/schema/config/profile_worker.yml +14 -0
  104. data/opt/yml/api/schema/config/project.yml +48 -0
  105. data/opt/yml/api/schema/mock/mock.yml +99 -0
  106. data/opt/yml/api/schema/mock/mock_nested_if_enum.yml +16 -0
  107. data/opt/yml/api/schema/mock/mock_nested_if_enum_system.yml +16 -0
  108. data/opt/yml/api/schema/mock/mock_nested_linked.yml +43 -0
  109. data/opt/yml/api/schema/mock/mock_nested_multiple.yml +61 -0
  110. data/opt/yml/api/schema/mock/mock_nested_single.yml +67 -0
  111. data/opt/yml/api/schema/mock/mock_nested_single_super_deep.yml +32 -0
  112. data/opt/yml/api/schema/mock/mock_nested_single_super_super_deep.yml +17 -0
  113. metadata +240 -0
@@ -0,0 +1,1050 @@
1
+ module Blufin
2
+
3
+ class YmlJavaPomWriter < Blufin::YmlWriterBase
4
+
5
+ PLACEHOLDER_GROUP = '{{--GROUP--}}'
6
+ PLACEHOLDER_GROUP_PARENT = '{{--GROUP-PARENT--}}'
7
+ PLACEHOLDER_ARTIFACT = '{{--ARTIFACT--}}'
8
+ PLACEHOLDER_ARTIFACT_PARENT = '{{--ARTIFACT-PARENT--}}'
9
+ PLACEHOLDER_PARENT = '{{--PARENT--}}'
10
+ PLACEHOLDER_TITLE = '{{--TITLE--}}'
11
+ PLACEHOLDER_MODULES = '{{--MODULES--}}'
12
+ PLACEHOLDER_MODULE = '{{--MODULE--}}'
13
+ PLACEHOLDER_MODULE_NAME = '{{--MODULE-NAME--}}'
14
+ PLACEHOLDER_MODULE_TITLE = '{{--MODULE-TITLE--}}'
15
+ PLACEHOLDER_DEPENDENCIES = '{{--DEPENDENCIES--}}'
16
+ PLACEHOLDER_DEPENDENCIES_MANAGED = '{{--DEPENDENCIES-MANAGED--}}'
17
+ PLACEHOLDER_BLUFIN_VERSION = '{{--BLUFIN-VERSION--}}'
18
+ PLACEHOLDER_APP_VERSION = '{{--APP-VERSION--}}'
19
+ PLACEHOLDER_BUILD = '{{--BUILD--}}'
20
+ PLACEHOLDER_BUILD_TYPE = '{{--BUILD-TYPE--}}'
21
+ PLACEHOLDER_BUILD_CLASS = '{{--BUILD-CLASS--}}'
22
+ PLACEHOLDER_DISTRIBUTION = '{{--DISTRIBUTION--}}'
23
+
24
+ MANAGED = 'managed'
25
+ INTERNAL = 'internal'
26
+ MVN = 'mvn'
27
+ APP = 'app'
28
+
29
+ # Initialize the class.
30
+ # @return void
31
+ def initialize(maven_data_blufin, maven_data_app = nil, site = nil)
32
+
33
+ raise RuntimeError, "Expected @maven_data_blufin to be a Hash, instead got: #{maven_data_blufin.class}" if maven_data_blufin.nil? || !maven_data_blufin.is_a?(Hash)
34
+
35
+ @maven_data_blufin = maven_data_blufin
36
+
37
+ @dependencies_mvn = nil
38
+ @used_modules_sourced = []
39
+ @used_modules_mvn = []
40
+
41
+ @blufin_core_libs = @maven_data_blufin[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS]
42
+ @blufin_core_libs_with_children = @maven_data_blufin[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS_WITH_CHILDREN]
43
+
44
+ unless maven_data_app.nil? || site.nil?
45
+
46
+ raise RuntimeError, "Expected @@maven_data_app to be a Hash, instead got: #{maven_data_app.class}" unless maven_data_app.is_a?(Hash)
47
+
48
+ @maven_data_app = maven_data_app
49
+
50
+ @site = Blufin::SiteResolver::validate_site(site)
51
+ @site_name = Blufin::SiteResolver::get_site_name(@site)
52
+ @site_name_camel_cased = Blufin::SiteResolver::get_site_name_camel_cased(@site)
53
+ @site_title = Blufin::SiteResolver::get_site_title(@site)
54
+ @site_domain = Blufin::SiteResolver::get_site_domain(@site)
55
+ @site_location = "#{Blufin::SiteResolver::get_site_location(@site)}/"
56
+
57
+ @app_core_libs = @maven_data_app[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS]
58
+ @app_core_libs_with_children = @maven_data_app[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS_WITH_CHILDREN]
59
+
60
+ end
61
+
62
+ @template_tests = <<TEMPLATE
63
+ <!-- TEST -->
64
+ <dependency>
65
+ <groupId>org.hamcrest</groupId>
66
+ <artifactId>hamcrest-core</artifactId>
67
+ <scope>test</scope>
68
+ </dependency>
69
+ <dependency>
70
+ <groupId>org.mockito</groupId>
71
+ <artifactId>mockito-core</artifactId>
72
+ <scope>test</scope>
73
+ <exclusions>
74
+ <exclusion>
75
+ <groupId>org.hamcrest</groupId>
76
+ <artifactId>hamcrest-core</artifactId>
77
+ </exclusion>
78
+ </exclusions>
79
+ </dependency>
80
+ <dependency>
81
+ <groupId>junit</groupId>
82
+ <artifactId>junit-dep</artifactId>
83
+ <scope>test</scope>
84
+ <exclusions>
85
+ <exclusion>
86
+ <groupId>org.hamcrest</groupId>
87
+ <artifactId>hamcrest-core</artifactId>
88
+ </exclusion>
89
+ </exclusions>
90
+ </dependency>
91
+ TEMPLATE
92
+
93
+ @template_build = <<TEMPLATE
94
+ <build>
95
+ <plugins>
96
+ <!-- This Plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family. -->
97
+ <plugin>
98
+ <groupId>org.apache.maven.plugins</groupId>
99
+ <artifactId>maven-enforcer-plugin</artifactId>
100
+ <version>3.0.0-M2</version>
101
+ <executions>
102
+ <execution>
103
+ <id>enforce</id>
104
+ <configuration>
105
+ <rules>
106
+ <DependencyConvergence />
107
+ <requireMavenVersion>
108
+ <version>3.6.0</version>
109
+ </requireMavenVersion>
110
+ </rules>
111
+ </configuration>
112
+ <goals>
113
+ <goal>enforce</goal>
114
+ </goals>
115
+ </execution>
116
+ </executions>
117
+ </plugin>
118
+ #{PLACEHOLDER_BUILD_TYPE}
119
+ </plugins>
120
+ </build>
121
+ TEMPLATE
122
+
123
+ @template_build_private = <<TEMPLATE
124
+ <!-- This Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. -->
125
+ <plugin>
126
+ <groupId>org.apache.maven.plugins</groupId>
127
+ <artifactId>maven-surefire-plugin</artifactId>
128
+ <version>2.19.1</version>
129
+ <configuration>
130
+ <argLine>-Duser.language=en -Duser.region=US</argLine>
131
+ <parallel>classes</parallel>
132
+ <threadCount>8</threadCount>
133
+ <perCoreThreadCount>true</perCoreThreadCount>
134
+ </configuration>
135
+ </plugin>
136
+ <!-- This Plugin looks for bugs in your code. -->
137
+ <plugin>
138
+ <groupId>org.codehaus.mojo</groupId>
139
+ <artifactId>findbugs-maven-plugin</artifactId>
140
+ <version>3.0.4</version>
141
+ <configuration>
142
+ <effort>Max</effort>
143
+ <threshold>Default</threshold>
144
+ <xmlOutput>true</xmlOutput>
145
+ <excludeFilterFile>${basedir}/../findbugs-exclude.xml</excludeFilterFile>
146
+ </configuration>
147
+ <executions>
148
+ <execution>
149
+ <goals>
150
+ <goal>check</goal>
151
+ </goals>
152
+ </execution>
153
+ </executions>
154
+ </plugin>
155
+ <!-- This Plugin builds byte-code/binary '.jar' files. -->
156
+ <plugin>
157
+ <groupId>org.apache.maven.plugins</groupId>
158
+ <artifactId>maven-jar-plugin</artifactId>
159
+ <version>3.1.1</version>
160
+ <configuration>
161
+ <archive>
162
+ <manifest>
163
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
164
+ </manifest>
165
+ </archive>
166
+ </configuration>
167
+ <executions>
168
+ <execution>
169
+ <phase>package</phase>
170
+ <goals>
171
+ <goal>test-jar</goal>
172
+ </goals>
173
+ </execution>
174
+ </executions>
175
+ </plugin>
176
+ TEMPLATE
177
+
178
+ @template_build_public = <<TEMPLATE
179
+ <!-- This Plugin is used to compile the sources of your project (required for Maven Central). -->
180
+ <plugin>
181
+ <groupId>org.apache.maven.plugins</groupId>
182
+ <artifactId>maven-source-plugin</artifactId>
183
+ <version>2.2.1</version>
184
+ <executions>
185
+ <execution>
186
+ <id>attach-sources</id>
187
+ <goals>
188
+ <goal>jar-no-fork</goal>
189
+ </goals>
190
+ </execution>
191
+ </executions>
192
+ </plugin>
193
+ <!-- This Plugin is used to compile the java-docs of your project (required for Maven Central). -->
194
+ <plugin>
195
+ <groupId>org.apache.maven.plugins</groupId>
196
+ <artifactId>maven-javadoc-plugin</artifactId>
197
+ <version>2.9.1</version>
198
+ <executions>
199
+ <execution>
200
+ <id>attach-javadocs</id>
201
+ <goals>
202
+ <goal>jar</goal>
203
+ </goals>
204
+ </execution>
205
+ </executions>
206
+ </plugin>
207
+ <!-- This Plugin does the PGP/GPG signing (required for Maven Central). -->
208
+ <plugin>
209
+ <groupId>org.apache.maven.plugins</groupId>
210
+ <artifactId>maven-gpg-plugin</artifactId>
211
+ <version>1.6</version>
212
+ <executions>
213
+ <execution>
214
+ <id>sign-artifacts</id>
215
+ <phase>verify</phase>
216
+ <goals>
217
+ <goal>sign</goal>
218
+ </goals>
219
+ <configuration>
220
+ <gpgArguments>
221
+ <arg>--pinentry-mode</arg>
222
+ <arg>loopback</arg>
223
+ </gpgArguments>
224
+ </configuration>
225
+ </execution>
226
+ </executions>
227
+ </plugin>
228
+ <!-- The Nexus Staging Maven Plugin is the recommended way to deploy your components to OSSRH and release them to the Central Repository. -->
229
+ <plugin>
230
+ <groupId>org.sonatype.plugins</groupId>
231
+ <artifactId>nexus-staging-maven-plugin</artifactId>
232
+ <version>1.6.7</version>
233
+ <extensions>true</extensions>
234
+ <configuration>
235
+ <serverId>ossrh</serverId>
236
+ <nexusUrl>https://oss.sonatype.org/</nexusUrl>
237
+ <autoReleaseAfterClose>true</autoReleaseAfterClose>
238
+ </configuration>
239
+ </plugin>
240
+ <!-- https://central.sonatype.org/pages/apache-maven.html#performing-a-release-deployment-with-the-maven-release-plugin -->
241
+ <!--
242
+ <plugin>
243
+ <groupId>org.apache.maven.plugins</groupId>
244
+ <artifactId>maven-release-plugin</artifactId>
245
+ <version>2.5.3</version>
246
+ <configuration>
247
+ <autoVersionSubmodules>true</autoVersionSubmodules>
248
+ <useReleaseProfile>false</useReleaseProfile>
249
+ <releaseProfiles>release</releaseProfiles>
250
+ <goals>deploy</goals>
251
+ </configuration>
252
+ </plugin>
253
+ -->
254
+ TEMPLATE
255
+
256
+ @template_distribution_management = <<TEMPLATE
257
+
258
+
259
+ <distributionManagement>
260
+ <snapshotRepository>
261
+ <id>ossrh</id>
262
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
263
+ </snapshotRepository>
264
+ <repository>
265
+ <id>ossrh</id>
266
+ <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
267
+ </repository>
268
+ </distributionManagement>
269
+
270
+ <build>
271
+ <plugins>
272
+ <plugin>
273
+ <groupId>org.apache.maven.plugins</groupId>
274
+ <artifactId>maven-gpg-plugin</artifactId>
275
+ <version>1.6</version>
276
+ <executions>
277
+ <execution>
278
+ <id>sign-artifacts</id>
279
+ <phase>verify</phase>
280
+ <goals>
281
+ <goal>sign</goal>
282
+ </goals>
283
+ <configuration>
284
+ <gpgArguments>
285
+ <arg>--pinentry-mode</arg>
286
+ <arg>loopback</arg>
287
+ </gpgArguments>
288
+ </configuration>
289
+ </execution>
290
+ </executions>
291
+ </plugin>
292
+ <plugin>
293
+ <groupId>org.sonatype.plugins</groupId>
294
+ <artifactId>nexus-staging-maven-plugin</artifactId>
295
+ <version>1.6.7</version>
296
+ <extensions>true</extensions>
297
+ <configuration>
298
+ <serverId>ossrh</serverId>
299
+ <nexusUrl>https://oss.sonatype.org/</nexusUrl>
300
+ <autoReleaseAfterClose>true</autoReleaseAfterClose>
301
+ </configuration>
302
+ </plugin>
303
+ </plugins>
304
+ </build>
305
+ TEMPLATE
306
+
307
+ @template_blufin_parent = <<TEMPLATE
308
+ <?xml version="1.0" encoding="UTF-8"?>
309
+ <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
310
+
311
+ <modelVersion>4.0.0</modelVersion>
312
+
313
+ <parent>
314
+ <groupId>org.springframework.boot</groupId>
315
+ <artifactId>spring-boot-starter-parent</artifactId>
316
+ <version>2.1.4.RELEASE</version>
317
+ <relativePath/>
318
+ </parent>
319
+
320
+ <groupId>org.blufin</groupId>
321
+ <artifactId>blufin</artifactId>
322
+ <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
323
+ <packaging>pom</packaging>
324
+
325
+ <name>Blufin Parent</name>
326
+
327
+ <properties>
328
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
329
+ </properties>
330
+
331
+ <modules>
332
+ #{PLACEHOLDER_MODULES}
333
+ </modules>#{PLACEHOLDER_DISTRIBUTION}
334
+ </project>
335
+ TEMPLATE
336
+
337
+ @template_blufin_parent_nested = <<TEMPLATE
338
+ <?xml version="1.0" encoding="UTF-8"?>
339
+ <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
340
+
341
+ <modelVersion>4.0.0</modelVersion>
342
+
343
+ <parent>
344
+ <groupId>org.blufin</groupId>
345
+ <artifactId>blufin</artifactId>
346
+ <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
347
+ </parent>
348
+
349
+ <groupId>#{PLACEHOLDER_GROUP}</groupId>
350
+ <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
351
+ <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
352
+ <packaging>pom</packaging>
353
+
354
+ <name>#{PLACEHOLDER_MODULE_TITLE}</name>
355
+
356
+ <modules>
357
+ #{PLACEHOLDER_MODULES}
358
+ </modules>
359
+
360
+ </project>
361
+ TEMPLATE
362
+
363
+ @template_blufin_children = <<TEMPLATE
364
+ <?xml version="1.0" encoding="UTF-8"?>
365
+ <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
366
+
367
+ <modelVersion>4.0.0</modelVersion>
368
+
369
+ <parent>
370
+ <groupId>#{PLACEHOLDER_GROUP}</groupId>
371
+ <artifactId>#{PLACEHOLDER_PARENT}</artifactId>
372
+ <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
373
+ </parent>
374
+
375
+ <groupId>#{PLACEHOLDER_GROUP}</groupId>
376
+ <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
377
+ <version>#{PLACEHOLDER_BLUFIN_VERSION}</version>
378
+
379
+ <properties>
380
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
381
+ </properties>
382
+
383
+ <name>#{PLACEHOLDER_MODULE_TITLE}</name>#{PLACEHOLDER_DEPENDENCIES_MANAGED}
384
+
385
+ <dependencies>
386
+ #{PLACEHOLDER_DEPENDENCIES}#{@template_tests} </dependencies>
387
+
388
+ #{@template_build}
389
+ </project>
390
+ TEMPLATE
391
+
392
+ @template_app_parent = <<TEMPLATE
393
+ <?xml version="1.0" encoding="UTF-8"?>
394
+ <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
395
+
396
+ <modelVersion>4.0.0</modelVersion>
397
+
398
+ <parent>
399
+ <groupId>org.springframework.boot</groupId>
400
+ <artifactId>spring-boot-starter-parent</artifactId>
401
+ <version>2.1.4.RELEASE</version>
402
+ <relativePath/>
403
+ </parent>
404
+
405
+ <groupId>#{PLACEHOLDER_GROUP}</groupId>
406
+ <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
407
+ <version>#{PLACEHOLDER_APP_VERSION}</version>
408
+ <packaging>pom</packaging>
409
+
410
+ <name>#{PLACEHOLDER_TITLE} Infrastructure</name>
411
+
412
+ <properties>
413
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
414
+ </properties>
415
+
416
+ <modules>
417
+ #{PLACEHOLDER_MODULES}
418
+ </modules>
419
+
420
+ </project>
421
+ TEMPLATE
422
+
423
+ @template_app_parent_nested = <<TEMPLATE
424
+ <?xml version="1.0" encoding="UTF-8"?>
425
+ <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
426
+
427
+ <modelVersion>4.0.0</modelVersion>
428
+
429
+ <parent>
430
+ <groupId>#{PLACEHOLDER_GROUP_PARENT}</groupId>
431
+ <artifactId>#{PLACEHOLDER_ARTIFACT_PARENT}</artifactId>
432
+ <version>#{PLACEHOLDER_APP_VERSION}</version>
433
+ </parent>
434
+
435
+ <groupId>#{PLACEHOLDER_GROUP}</groupId>
436
+ <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
437
+ <version>#{PLACEHOLDER_APP_VERSION}</version>
438
+ <packaging>pom</packaging>
439
+
440
+ <name>#{PLACEHOLDER_MODULE_TITLE}</name>
441
+
442
+ <modules>
443
+ #{PLACEHOLDER_MODULES}
444
+ </modules>
445
+
446
+ </project>
447
+ TEMPLATE
448
+
449
+ @template_app_children = <<TEMPLATE
450
+ <?xml version="1.0" encoding="UTF-8"?>
451
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
452
+
453
+ <modelVersion>4.0.0</modelVersion>
454
+
455
+ <parent>
456
+ <groupId>#{PLACEHOLDER_GROUP}</groupId>
457
+ <artifactId>#{PLACEHOLDER_ARTIFACT_PARENT}</artifactId>
458
+ <version>#{PLACEHOLDER_APP_VERSION}</version>
459
+ </parent>
460
+
461
+ <groupId>#{PLACEHOLDER_GROUP}</groupId>
462
+ <artifactId>#{PLACEHOLDER_ARTIFACT}</artifactId>
463
+ <version>#{PLACEHOLDER_APP_VERSION}</version>
464
+
465
+ <properties>
466
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
467
+ </properties>
468
+
469
+ <name>#{PLACEHOLDER_TITLE}</name>#{PLACEHOLDER_DEPENDENCIES_MANAGED}
470
+
471
+ <dependencies>
472
+ #{PLACEHOLDER_DEPENDENCIES}#{@template_tests} </dependencies>
473
+
474
+ #{PLACEHOLDER_BUILD}
475
+ </project>
476
+ TEMPLATE
477
+
478
+ @template_app_build_service = <<TEMPLATE
479
+ <build>
480
+ <resources>
481
+ <resource>
482
+ <directory>src/main/resources</directory>
483
+ </resource>
484
+ </resources>
485
+ <plugins>
486
+ <plugin>
487
+ <groupId>org.springframework.boot</groupId>
488
+ <artifactId>spring-boot-maven-plugin</artifactId>
489
+ </plugin>
490
+ <plugin>
491
+ <groupId>org.apache.maven.plugins</groupId>
492
+ <artifactId>maven-enforcer-plugin</artifactId>
493
+ <version>3.0.0-M2</version>
494
+ <executions>
495
+ <execution>
496
+ <id>enforce</id>
497
+ <phase>package</phase>
498
+ <goals>
499
+ <goal>enforce</goal>
500
+ </goals>
501
+ <configuration>
502
+ <rules>
503
+ <DependencyConvergence />
504
+ <requireMavenVersion>
505
+ <version>3.6.0</version>
506
+ </requireMavenVersion>
507
+ </rules>
508
+ <fail>true</fail>
509
+ </configuration>
510
+ </execution>
511
+ </executions>
512
+ </plugin>
513
+ <plugin>
514
+ <groupId>org.codehaus.mojo</groupId>
515
+ <artifactId>findbugs-maven-plugin</artifactId>
516
+ <version>3.0.4</version>
517
+ <configuration>
518
+ <effort>Max</effort>
519
+ <threshold>Default</threshold>
520
+ <xmlOutput>false</xmlOutput>
521
+ <excludeFilterFile>${basedir}/../findbugs-exclude.xml</excludeFilterFile>
522
+ </configuration>
523
+ <executions>
524
+ <execution>
525
+ <goals>
526
+ <goal>check</goal>
527
+ </goals>
528
+ </execution>
529
+ </executions>
530
+ </plugin>
531
+ <plugin>
532
+ <groupId>org.apache.maven.plugins</groupId>
533
+ <artifactId>maven-surefire-plugin</artifactId>
534
+ <version>2.19.1</version>
535
+ <configuration>
536
+ <argLine>-Duser.language=en -Duser.region=US</argLine>
537
+ <parallel>classes</parallel>
538
+ <threadCount>8</threadCount>
539
+ <perCoreThreadCount>true</perCoreThreadCount>
540
+ </configuration>
541
+ </plugin>
542
+ </plugins>
543
+ </build>
544
+ TEMPLATE
545
+
546
+ @template_app_build_lib = <<TEMPLATE
547
+ <build>
548
+ <plugins>
549
+ <!-- This Plugin is used to compile the sources of your project. -->
550
+ <plugin>
551
+ <groupId>org.apache.maven.plugins</groupId>
552
+ <artifactId>maven-compiler-plugin</artifactId>
553
+ <version>3.6.1</version>
554
+ <configuration>
555
+ <source>1.8</source>
556
+ <target>1.8</target>
557
+ </configuration>
558
+ </plugin>
559
+ <plugin>
560
+ <groupId>org.apache.maven.plugins</groupId>
561
+ <artifactId>maven-enforcer-plugin</artifactId>
562
+ <version>3.0.0-M2</version>
563
+ <executions>
564
+ <execution>
565
+ <id>enforce</id>
566
+ <phase>package</phase>
567
+ <goals>
568
+ <goal>enforce</goal>
569
+ </goals>
570
+ <configuration>
571
+ <rules>
572
+ <DependencyConvergence />
573
+ <requireMavenVersion>
574
+ <version>3.6.0</version>
575
+ </requireMavenVersion>
576
+ </rules>
577
+ <fail>true</fail>
578
+ </configuration>
579
+ </execution>
580
+ </executions>
581
+ </plugin>
582
+ <plugin>
583
+ <groupId>org.codehaus.mojo</groupId>
584
+ <artifactId>findbugs-maven-plugin</artifactId>
585
+ <version>3.0.4</version>
586
+ <configuration>
587
+ <effort>Max</effort>
588
+ <threshold>Default</threshold>
589
+ <xmlOutput>false</xmlOutput>
590
+ <excludeFilterFile>${basedir}/../findbugs-exclude.xml</excludeFilterFile>
591
+ </configuration>
592
+ <executions>
593
+ <execution>
594
+ <goals>
595
+ <goal>check</goal>
596
+ </goals>
597
+ </execution>
598
+ </executions>
599
+ </plugin>
600
+ <!-- This Plugin builds byte-code/binary '.jar' files. -->
601
+ <plugin>
602
+ <groupId>org.apache.maven.plugins</groupId>
603
+ <artifactId>maven-jar-plugin</artifactId>
604
+ <version>3.1.1</version>
605
+ <configuration>
606
+ <archive>
607
+ <manifest>
608
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
609
+ </manifest>
610
+ </archive>
611
+ </configuration>
612
+ </plugin>
613
+ <plugin>
614
+ <groupId>org.apache.maven.plugins</groupId>
615
+ <artifactId>maven-surefire-plugin</artifactId>
616
+ <version>2.19.1</version>
617
+ <configuration>
618
+ <argLine>-Duser.language=en -Duser.region=US</argLine>
619
+ <parallel>classes</parallel>
620
+ <threadCount>8</threadCount>
621
+ <perCoreThreadCount>true</perCoreThreadCount>
622
+ </configuration>
623
+ </plugin>
624
+ </plugins>
625
+ </build>
626
+ TEMPLATE
627
+
628
+ end
629
+
630
+ # Write the POMs in for the blufin libs.
631
+ # @return void
632
+ def write_poms_blufin(path_framework = nil)
633
+ raise RuntimeError, '@maven_data_blufin cannot be nil.' if @maven_data_blufin.nil?
634
+ @root_path = path_framework.nil? ? Blufin::Config::get_path('Paths', 'BlufinJava') : path_framework
635
+ @config_file_blufin = "#{@root_path}/pom.xml"
636
+ @blufin_public_modules = nil
637
+
638
+ # Get the path(s) to ignore when copying to Framework.
639
+ # At this point all the files should've been copied over and we know what path(s) exist.
640
+ if path_framework
641
+ @blufin_public_modules = []
642
+ Blufin::Files::get_dirs_in_dir(path_framework).each { |path| @blufin_public_modules << path.split('/')[path.split('/').length - 1] }
643
+ end
644
+
645
+ write_poms_blufin_parent(path_framework)
646
+ write_poms_blufin_parent_nested(path_framework)
647
+ write_poms_blufin_children(path_framework)
648
+ end
649
+
650
+ # Write the POMs in for the individual application(s).
651
+ # @return void
652
+ def write_poms_app
653
+ raise RuntimeError, '@maven_data_app cannot be nil.' if @maven_data_app.nil?
654
+ write_poms_app_parent
655
+ write_poms_app_parent_nested
656
+ write_poms_app_children
657
+ end
658
+
659
+ private
660
+
661
+ # Writes the BLUFIN parent POM.
662
+ # @return void
663
+ def write_poms_blufin_parent(path_framework = nil)
664
+ blufin_modules = []
665
+ blufin_modules_string = ''
666
+ @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN].keys.each do |blufin_module|
667
+
668
+ # If generating framework and module path does not exist (IE: blufin-blank), then skip.
669
+ next unless @blufin_public_modules.nil? || @blufin_public_modules.include?(blufin_module)
670
+
671
+ fm = nil
672
+ @blufin_core_libs_with_children.each do |core_lib_with_child|
673
+ if blufin_module =~ /\A#{core_lib_with_child}-/
674
+ fm = true
675
+ blufin_modules << "<module>#{core_lib_with_child}</module>"
676
+ break
677
+ end
678
+ end
679
+ blufin_modules << "<module>#{blufin_module}</module>" if fm.nil?
680
+ end
681
+ blufin_modules.uniq!
682
+ blufin_modules.each { |nm| blufin_modules_string += " #{nm}\n" }
683
+ contents = @template_blufin_parent
684
+ contents = contents.gsub(PLACEHOLDER_BLUFIN_VERSION, get_blufin_version)
685
+ contents = contents.gsub(PLACEHOLDER_MODULES, blufin_modules_string.gsub(/\n\z/, ''))
686
+ contents = contents.gsub(PLACEHOLDER_DISTRIBUTION, path_framework.nil? ? "\n" : @template_distribution_management)
687
+ Blufin::Files.write_file(@config_file_blufin, Blufin::YmlCommon::convert_string_to_line_array(contents))
688
+ end
689
+
690
+ # Writes the BLUFIN nested parent POM(s).
691
+ # @return void
692
+ def write_poms_blufin_parent_nested(path_framework = nil)
693
+ @blufin_core_libs_with_children.each do |core_lib_with_child|
694
+ group_suffix = core_lib_with_child.gsub(/\Ablufin-/, '')
695
+ nested_modules_string = ''
696
+ @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN].each do |blufin_module, module_data|
697
+ if module_data.has_key?(Blufin::YmlMavenValidator::BLUFIN_PARENT) && module_data[Blufin::YmlMavenValidator::BLUFIN_PARENT] == core_lib_with_child
698
+ nested_modules_string += " <module>#{blufin_module}</module>\n"
699
+ next
700
+ end
701
+ end
702
+ contents = @template_blufin_parent_nested
703
+ contents = contents.gsub(PLACEHOLDER_BLUFIN_VERSION, get_blufin_version)
704
+ contents = contents.gsub(PLACEHOLDER_GROUP, "org.blufin.#{group_suffix.gsub('-', '.')}")
705
+ contents = contents.gsub(PLACEHOLDER_ARTIFACT, "blufin-#{group_suffix}")
706
+ contents = contents.gsub(PLACEHOLDER_MODULES, nested_modules_string.gsub(/\n\z/, ''))
707
+ contents = contents.gsub(PLACEHOLDER_MODULE_TITLE, @maven_data_blufin[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS_PARENTS]["blufin-#{group_suffix}"][:title])
708
+ Blufin::Files.write_file("#{@root_path}/#{core_lib_with_child}/pom.xml", Blufin::YmlCommon::convert_string_to_line_array(contents))
709
+ end
710
+ end
711
+
712
+ # Writes the BLUFIN child POMs.
713
+ # @return void
714
+ def write_poms_blufin_children(path_framework = nil)
715
+ module_data = {}
716
+ @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN].keys.each do |blufin_module|
717
+
718
+ # If generating framework and module path does not exist (IE: blufin-blank), then skip.
719
+ next unless @blufin_public_modules.nil? || @blufin_public_modules.include?(blufin_module)
720
+
721
+ data = {}
722
+ fm = nil
723
+ @blufin_core_libs_with_children.each do |core_lib_with_child|
724
+ if blufin_module =~ /\A#{core_lib_with_child}-/
725
+ group_suffix = core_lib_with_child.gsub(/\Ablufin-/, '')
726
+ fm = true
727
+ data[:pom] = "#{@root_path}/#{core_lib_with_child}/#{blufin_module}/pom.xml"
728
+ data[:name] = blufin_module
729
+ data[:group] = "org.blufin.#{group_suffix.gsub('-', '.')}"
730
+ data[:parent] = "blufin-#{group_suffix}"
731
+ break
732
+ end
733
+ end
734
+ if fm.nil?
735
+ data[:pom] = "#{@root_path}/#{blufin_module}/pom.xml"
736
+ data[:name] = blufin_module
737
+ data[:group] = 'org.blufin'
738
+ data[:parent] = 'blufin'
739
+ end
740
+ data[:title] = @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN][blufin_module][Blufin::YmlMavenValidator::BLUFIN_TITLE]
741
+ data[:deps_internal] = @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN][blufin_module][Blufin::YmlMavenValidator::DEPENDENCIES_BLUFIN]
742
+ data[:deps_mvn] = @maven_data_blufin[Blufin::YmlMavenValidator::BLUFIN][blufin_module][Blufin::YmlMavenValidator::DEPENDENCIES_MVN]
743
+ module_data[blufin_module] = data
744
+ dep_string = ''
745
+ dep_string = add_dependencies(dep_string, data[:deps_internal], INTERNAL) if !data[:deps_internal].nil? && data[:deps_internal].length > 0
746
+ dep_string = add_dependencies(dep_string, data[:deps_mvn], MVN) if !data[:deps_mvn].nil? && data[:deps_mvn].length > 0
747
+ contents = @template_blufin_children
748
+ contents = contents.gsub(PLACEHOLDER_BLUFIN_VERSION, get_blufin_version)
749
+ contents = contents.gsub(PLACEHOLDER_GROUP, data[:group])
750
+ contents = contents.gsub(PLACEHOLDER_PARENT, data[:parent])
751
+ contents = contents.gsub(PLACEHOLDER_ARTIFACT, data[:name])
752
+ contents = contents.gsub(PLACEHOLDER_MODULE_TITLE, data[:title])
753
+ contents = contents.gsub(PLACEHOLDER_DEPENDENCIES, dep_string)
754
+ contents = contents.gsub(PLACEHOLDER_DEPENDENCIES_MANAGED, "\n\n <dependencyManagement>\n <dependencies>\n#{add_dependencies('', nil, MANAGED)} </dependencies>\n </dependencyManagement>")
755
+ contents = contents.gsub(PLACEHOLDER_BUILD_TYPE, path_framework.nil? ? @template_build_private : @template_build_public)
756
+ Blufin::Files::write_file(data[:pom], Blufin::YmlCommon::convert_string_to_line_array(contents))
757
+ end
758
+
759
+ @used_modules_sourced.sort!.uniq!
760
+ @used_modules_mvn.sort!.uniq!
761
+
762
+ @maven_data_blufin[Blufin::YmlMavenValidator::DEPENDENCIES_MVN].each do |dependency|
763
+ # TODO - 03/10/19 - Turns out the unused dependencies are needed otherwise we get dependency convergence error(s) during the maven builds... Possibly add flag -> ignore-unused: true ?
764
+ # dep_extracted = Blufin::YmlCommon::extract_group_artifact_version_from_array(dependency)
765
+ # dep_module = "#{dep_extracted[Blufin::YmlMavenValidator::DEPENDENCIES_GROUP_ID]}:#{dep_extracted[Blufin::YmlMavenValidator::DEPENDENCIES_ARTIFACT_ID]}"
766
+ # Blufin::Terminal::output("Found unused #{ Blufin::Terminal::format_action('mvn')} dependency \xe2\x86\x92 #{Blufin::Terminal::format_highlight(dep_module)}", Blufin::Terminal::MSG_WARNING) unless @used_modules_mvn.include?(dep_module)
767
+ end
768
+
769
+ end
770
+
771
+ # Writes the APP parent POM.
772
+ # @return void
773
+ def write_poms_app_parent
774
+ app_modules = []
775
+ app_modules_string = ''
776
+ @maven_data_app[@site_name].keys.each do |app_module|
777
+ fm = nil
778
+ @app_core_libs_with_children.each do |core_lib_with_child|
779
+ if app_module =~ /\A#{core_lib_with_child}-/
780
+ fm = true
781
+ app_modules << "<module>#{core_lib_with_child}</module>"
782
+ break
783
+ end
784
+ end
785
+ app_modules << "<module>#{app_module}</module>" if fm.nil?
786
+ end
787
+ app_modules.uniq!
788
+ app_modules.each { |nm| app_modules_string += " #{nm}\n" }
789
+ site_name_with_dots = @site_name.gsub('-', '.')
790
+ contents = @template_app_parent
791
+ contents = contents.gsub(PLACEHOLDER_GROUP, "#{@site_domain}.#{site_name_with_dots}".gsub(/^\./, ''))
792
+ contents = contents.gsub(PLACEHOLDER_ARTIFACT, "#{@site_name}")
793
+ contents = contents.gsub(PLACEHOLDER_APP_VERSION, get_app_version)
794
+ contents = contents.gsub(PLACEHOLDER_BLUFIN_VERSION, get_blufin_version)
795
+ contents = contents.gsub(PLACEHOLDER_TITLE, @site_title)
796
+ contents = contents.gsub(PLACEHOLDER_MODULES, app_modules_string.gsub(/\n\z/, ''))
797
+ Blufin::Files.write_file("#{@site_location}/#{Blufin::YmlMavenValidator::APP_INFRASTRUCTURE}/pom.xml", Blufin::YmlCommon::convert_string_to_line_array(contents))
798
+ end
799
+
800
+ # Writes the APP nested parent POM(s).
801
+ # @return void
802
+ def write_poms_app_parent_nested
803
+ @app_core_libs_with_children.each do |core_lib_with_child|
804
+ group_suffix = core_lib_with_child.gsub(/\A#{@site_name}-/, '')
805
+ nested_path = "#{@site_name}-#{group_suffix}"
806
+ nested_modules_string = ''
807
+ @maven_data_app[@site_name].each do |app_module, module_data|
808
+ if module_data.has_key?(Blufin::YmlMavenValidator::BLUFIN_PARENT) && module_data[Blufin::YmlMavenValidator::BLUFIN_PARENT] == core_lib_with_child
809
+ nested_modules_string += " <module>#{app_module}</module>\n"
810
+ next
811
+ end
812
+ end
813
+ site_name_with_dots = @site_name.gsub('-', '.')
814
+ contents = @template_app_parent_nested
815
+ contents = contents.gsub(PLACEHOLDER_GROUP, "#{@site_domain}.#{site_name_with_dots}.#{group_suffix}".gsub(/^\./, ''))
816
+ contents = contents.gsub(PLACEHOLDER_GROUP_PARENT, "#{@site_domain}.#{site_name_with_dots}".gsub(/^\./, ''))
817
+ contents = contents.gsub(PLACEHOLDER_ARTIFACT, "#{@site_name}-#{group_suffix}")
818
+ contents = contents.gsub(PLACEHOLDER_ARTIFACT_PARENT, "#{@site_name}")
819
+ contents = contents.gsub(PLACEHOLDER_APP_VERSION, get_app_version)
820
+ contents = contents.gsub(PLACEHOLDER_MODULES, nested_modules_string.gsub(/\n\z/, ''))
821
+ contents = contents.gsub(PLACEHOLDER_MODULE_TITLE, @maven_data_app[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_CORE_LIBS_PARENTS][nested_path][:title])
822
+ Blufin::Files.write_file("#{@site_location}/#{Blufin::YmlMavenValidator::APP_INFRASTRUCTURE}/#{nested_path}/pom.xml", Blufin::YmlCommon::convert_string_to_line_array(contents))
823
+ end
824
+ end
825
+
826
+ # Writes the APP child POMs.
827
+ # @return void
828
+ def write_poms_app_children
829
+ module_data = {}
830
+ @maven_data_app[@site_name].keys.each do |app_module|
831
+ data = {}
832
+ fm = nil
833
+ group = "#{@site_domain}.#{@site_name.gsub('-', '.')}".gsub(/^\./, '')
834
+ location = "#{@site_location}/#{Blufin::YmlMavenValidator::APP_INFRASTRUCTURE}".gsub('//', '/')
835
+ @app_core_libs_with_children.each do |core_lib_with_child|
836
+ if app_module =~ /\A#{core_lib_with_child}-/
837
+ group_suffix = core_lib_with_child.gsub(/\A#{@site_name}-/, '')
838
+ fm = true
839
+ data[:pom] = "#{location}/#{core_lib_with_child}/#{app_module}/pom.xml"
840
+ data[:name] = app_module
841
+ data[:group] = "#{group}.#{group_suffix}"
842
+ data[:parent] = "#{@site_name}-#{group_suffix}"
843
+ break
844
+ end
845
+ end
846
+ if fm.nil?
847
+ data[:pom] = "#{location}/#{app_module}/pom.xml"
848
+ data[:name] = app_module
849
+ data[:group] = group
850
+ data[:parent] = "#{@site_name}"
851
+ end
852
+ type_split = data[:name].split('-')
853
+ type = type_split[type_split.length - 1]
854
+ data[:title] = @maven_data_app[@site_name][app_module][Blufin::YmlMavenValidator::BLUFIN_TITLE]
855
+ data[:deps_app] = @maven_data_app[@site_name][app_module][Blufin::YmlMavenValidator::DEPENDENCIES_APP]
856
+ data[:deps_internal] = @maven_data_app[@site_name][app_module][Blufin::YmlMavenValidator::DEPENDENCIES_BLUFIN]
857
+ data[:deps_mvn] = @maven_data_app[@site_name][app_module][Blufin::YmlMavenValidator::DEPENDENCIES_MVN]
858
+ module_data[app_module] = data
859
+ dep_string = ''
860
+ dep_string = add_dependencies(dep_string, data[:deps_app], APP, @maven_data_app) if !data[:deps_app].nil? && data[:deps_app].length > 0
861
+ dep_string = add_dependencies(dep_string, data[:deps_internal], INTERNAL, @maven_data_app) if !data[:deps_internal].nil? && data[:deps_internal].length > 0
862
+ dep_string = add_dependencies(dep_string, data[:deps_mvn], MVN, @maven_data_app) if !data[:deps_mvn].nil? && data[:deps_mvn].length > 0
863
+ contents = @template_app_children
864
+ contents = contents.gsub(PLACEHOLDER_GROUP, data[:group])
865
+ contents = contents.gsub(PLACEHOLDER_ARTIFACT, data[:name])
866
+ contents = contents.gsub(PLACEHOLDER_ARTIFACT_PARENT, data[:parent])
867
+ contents = contents.gsub(PLACEHOLDER_APP_VERSION, get_app_version)
868
+ contents = contents.gsub(PLACEHOLDER_TITLE, data[:title])
869
+ contents = contents.gsub(PLACEHOLDER_DEPENDENCIES, dep_string)
870
+ contents = contents.gsub(PLACEHOLDER_DEPENDENCIES_MANAGED, "\n\n <dependencyManagement>\n <dependencies>\n#{add_dependencies('', nil, MANAGED, @maven_data_app)} </dependencies>\n </dependencyManagement>")
871
+ if [
872
+ Blufin::YmlMavenValidator::APP_INFRASTRUCTURE_API,
873
+ Blufin::YmlMavenValidator::APP_INFRASTRUCTURE_CRON,
874
+ Blufin::YmlMavenValidator::APP_INFRASTRUCTURE_WORKER,
875
+ ].include?(type)
876
+ build_string = @template_app_build_service
877
+ build_string = build_string.gsub(PLACEHOLDER_MODULE, type.downcase)
878
+ build_string = build_string.gsub(PLACEHOLDER_BUILD_CLASS, "#{@site_name_camel_cased}#{type.capitalize}")
879
+ contents = contents.gsub(PLACEHOLDER_BUILD, build_string)
880
+ else
881
+ contents = contents.gsub(PLACEHOLDER_BUILD, @template_app_build_lib)
882
+ end
883
+ Blufin::Files::write_file(data[:pom], Blufin::YmlCommon::convert_string_to_line_array(contents))
884
+ end
885
+ end
886
+
887
+ # Adds Dependencies to string.
888
+ # @return string
889
+ def add_dependencies(dep_string, deps, type, maven_data = nil)
890
+ maven_data = @maven_data_blufin if maven_data.nil?
891
+ case type
892
+ when MANAGED
893
+ output = ''
894
+ maven_data[Blufin::YmlMavenValidator::DEPENDENCIES_MVN].each do |dependency_version|
895
+ output += <<TEMPLATE
896
+ <dependency>
897
+ <groupId>#{dependency_version[0][Blufin::YmlMavenValidator::DEPENDENCIES_GROUP_ID]}</groupId>
898
+ <artifactId>#{dependency_version[1][Blufin::YmlMavenValidator::DEPENDENCIES_ARTIFACT_ID]}</artifactId>
899
+ <version>#{dependency_version[2][Blufin::YmlMavenValidator::DEPENDENCIES_VERSION]}</version>
900
+ </dependency>
901
+ TEMPLATE
902
+ end
903
+ return output
904
+ when APP
905
+ dep_string += " <!-- #{@site_name.upcase} -->\n"
906
+ when INTERNAL
907
+ dep_string += " <!-- INTERNAL -->\n"
908
+ when MVN
909
+ dep_string += " <!-- MVN -->\n"
910
+ else
911
+ raise RuntimeError, "Unrecognized type: #{type}"
912
+ end
913
+ deps.each do |dep|
914
+ module_name = nil
915
+ exclude = nil
916
+ test_scope = nil
917
+ test_jar = nil
918
+ dep.each do |dep_inner|
919
+ dep_inner.each do |key, data|
920
+ case key
921
+ when Blufin::YmlMavenValidator::DEPENDENCIES_USE
922
+ module_name = data
923
+ when Blufin::YmlMavenValidator::DEPENDENCIES_EXCLUDE
924
+ exclude = data
925
+ when Blufin::YmlMavenValidator::DEPENDENCIES_TEST_SCOPE
926
+ test_scope = data
927
+ when Blufin::YmlMavenValidator::DEPENDENCIES_TEST_JAR
928
+ test_jar = data
929
+ else
930
+ raise RuntimeError, "Unrecognized key: #{key}"
931
+ end
932
+ end
933
+ end
934
+ raise RuntimeError, ":use should never be nil but was for: #{deps.inspect}" if module_name.nil?
935
+ case type
936
+ when APP
937
+ fm = nil
938
+ group = nil
939
+ artifact = nil
940
+ @app_core_libs_with_children.each do |core_lib_with_child|
941
+ if module_name =~ /\A#{core_lib_with_child}-/
942
+ group_suffix = core_lib_with_child.gsub(/\A#{@site_name}-/, '')
943
+ fm = true
944
+ artifact = module_name
945
+ group = "#{@site_domain}.#{@site_name.gsub('-', '.')}.#{group_suffix}".gsub(/^\./, '')
946
+ end
947
+ end
948
+ if fm.nil?
949
+ group = "#{@site_domain}.#{@site_name.gsub('-', '.')}".gsub(/^\./, '')
950
+ artifact = module_name
951
+ end
952
+ version = get_app_version
953
+ when INTERNAL
954
+ fm = nil
955
+ group = nil
956
+ artifact = nil
957
+ @blufin_core_libs_with_children.each do |core_lib_with_child|
958
+ if module_name =~ /\A#{core_lib_with_child}-/
959
+ group_suffix = core_lib_with_child.gsub(/\Ablufin-/, '')
960
+ fm = true
961
+ artifact = module_name
962
+ group = "org.blufin.#{group_suffix.gsub('-', '.')}"
963
+ end
964
+ end
965
+ if fm.nil?
966
+ group = 'org.blufin'
967
+ artifact = module_name
968
+ end
969
+ version = get_blufin_version
970
+ when MVN
971
+ @used_modules_mvn << module_name
972
+ data = maven_data[Blufin::YmlMavenValidator::EXTRA_DATA][Blufin::YmlMavenValidator::EXTRA_DATA_MVN_CACHE][module_name]
973
+ group = data[:group]
974
+ artifact = data[:artifact]
975
+ version = data[:version]
976
+ else
977
+ raise RuntimeError, "Unrecognized type: #{type}"
978
+ end
979
+ raise RuntimeError, 'group should never be nil!' if group.nil?
980
+ raise RuntimeError, 'artifact should never be nil!' if artifact.nil?
981
+ raise RuntimeError, 'version should never be nil!' if version.nil?
982
+ dep_string += <<TEMPLATE
983
+ <dependency>
984
+ <groupId>#{group}</groupId>
985
+ <artifactId>#{artifact}</artifactId>
986
+ <version>#{version}</version>
987
+ TEMPLATE
988
+
989
+ unless test_jar.nil?
990
+ dep_string += <<TEMPLATE
991
+ <type>test-jar</type>
992
+ TEMPLATE
993
+ end
994
+
995
+ unless test_scope.nil?
996
+ dep_string += <<TEMPLATE
997
+ <scope>test</scope>
998
+ TEMPLATE
999
+ end
1000
+
1001
+ # Add Exclusions (if any).
1002
+ unless exclude.nil?
1003
+ if exclude.is_a?(Array) && exclude.length > 0
1004
+ dep_string += " <exclusions>\n"
1005
+ exclude.each do |ex|
1006
+ ex_split = ex.split(':')
1007
+ raise RuntimeError, "#{ex} is wrong format, should have exactly one colon [:]. We must write validation for this." unless ex_split.length == 2
1008
+ dep_string += <<TEMPLATE
1009
+ <exclusion>
1010
+ <groupId>#{ex_split[0]}</groupId>
1011
+ <artifactId>#{ex_split[1]}</artifactId>
1012
+ </exclusion>
1013
+ TEMPLATE
1014
+ end
1015
+ dep_string += " </exclusions>\n"
1016
+ end
1017
+ end
1018
+ dep_string += <<TEMPLATE
1019
+ </dependency>
1020
+ TEMPLATE
1021
+ end
1022
+ dep_string
1023
+ end
1024
+
1025
+ # Returns BLUFIN version.
1026
+ # @return String
1027
+ def get_blufin_version
1028
+ begin
1029
+ v = @maven_data_blufin[Blufin::YmlMavenValidator::CONFIG][Blufin::YmlMavenValidator::CONFIG_BLUFIN][Blufin::YmlMavenValidator::CONFIG_BLUFIN_VERSION]
1030
+ raise RuntimeError if v.nil? || v.to_s.length <= 0
1031
+ return v
1032
+ rescue
1033
+ raise RuntimeError, 'Could not determine Blufin version.'
1034
+ end
1035
+ end
1036
+
1037
+ # Returns APP version.
1038
+ # @return String
1039
+ def get_app_version
1040
+ begin
1041
+ v = @maven_data_app[Blufin::YmlMavenValidator::CONFIG][@site_name][Blufin::YmlMavenValidator::CONFIG_APP_VERSION]
1042
+ raise RuntimeError if v.nil? || v.to_s.length <= 0
1043
+ return v
1044
+ rescue
1045
+ raise RuntimeError, "Could not determine #{@site_title} version."
1046
+ end
1047
+ end
1048
+ end
1049
+
1050
+ end