@@ -67,14 +67,14 @@ public class UtPLSQLMojo extends AbstractMojo {
6767 protected boolean skipCompatibilityCheck ;
6868
6969 @ Parameter
70- protected List <ReporterParameter > reporters = new ArrayList <>();
70+ protected final List <ReporterParameter > reporters = new ArrayList <>();
7171
7272 @ Parameter
73- protected List <String > paths = new ArrayList <>();
73+ protected final List <String > paths = new ArrayList <>();
7474
7575 // Sources Configuration
7676 @ Parameter
77- protected List <Resource > sources = new ArrayList <>();
77+ protected final List <Resource > sources = new ArrayList <>();
7878
7979 @ Parameter
8080 private String sourcesOwner ;
@@ -96,7 +96,7 @@ public class UtPLSQLMojo extends AbstractMojo {
9696
9797 // Tests Configuration
9898 @ Parameter
99- protected List <Resource > tests = new ArrayList <>();
99+ protected final List <Resource > tests = new ArrayList <>();
100100
101101 @ Parameter
102102 private String testsOwner ;
@@ -244,37 +244,7 @@ private FileMapperOptions buildSourcesOptions() throws MojoExecutionException {
244244
245245 List <String > scripts = SQLScannerHelper .findSQLs (project .getBasedir (), sources ,
246246 PluginDefault .SOURCE_DIRECTORY , PluginDefault .SOURCE_FILE_PATTERN );
247- FileMapperOptions fileMapperOptions = new FileMapperOptions (scripts );
248-
249- if (StringUtils .isNotEmpty (sourcesOwner )) {
250- fileMapperOptions .setObjectOwner (sourcesOwner );
251- }
252-
253- if (StringUtils .isNotEmpty (sourcesRegexExpression )) {
254- fileMapperOptions .setRegexPattern (sourcesRegexExpression );
255- }
256-
257- if (sourcesOwnerSubexpression != null ) {
258- fileMapperOptions .setOwnerSubExpression (sourcesOwnerSubexpression );
259- }
260-
261- if (sourcesNameSubexpression != null ) {
262- fileMapperOptions .setNameSubExpression (sourcesNameSubexpression );
263- }
264-
265- if (sourcesTypeSubexpression != null ) {
266- fileMapperOptions .setTypeSubExpression (sourcesTypeSubexpression );
267- }
268-
269- if (sourcesCustomTypeMapping != null && !sourcesCustomTypeMapping .isEmpty ()) {
270- fileMapperOptions .setTypeMappings (new ArrayList <>());
271- for (CustomTypeMapping typeMapping : sourcesCustomTypeMapping ) {
272- fileMapperOptions .getTypeMappings ()
273- .add (new KeyValuePair (typeMapping .getCustomMapping (), typeMapping .getType ()));
274- }
275- }
276-
277- return fileMapperOptions ;
247+ return createFileMapperOptions (scripts , sourcesOwner , sourcesRegexExpression , sourcesOwnerSubexpression , sourcesNameSubexpression , sourcesTypeSubexpression , sourcesCustomTypeMapping );
278248
279249 } catch (Exception e ) {
280250 throw new MojoExecutionException ("Invalid <SOURCES> in your pom.xml" , e );
@@ -295,42 +265,49 @@ private FileMapperOptions buildTestsOptions() throws MojoExecutionException {
295265
296266 List <String > scripts = SQLScannerHelper .findSQLs (project .getBasedir (), tests , PluginDefault .TEST_DIRECTORY ,
297267 PluginDefault .TEST_FILE_PATTERN );
298- FileMapperOptions fileMapperOptions = new FileMapperOptions (scripts );
268+ return createFileMapperOptions (scripts , testsOwner , testsRegexExpression , testsOwnerSubexpression ,
269+ testsNameSubexpression , testsTypeSubexpression , testsCustomTypeMapping );
299270
300- if ( StringUtils . isNotEmpty ( testsOwner ) ) {
301- fileMapperOptions . setObjectOwner ( testsOwner );
302- }
271+ } catch ( Exception e ) {
272+ throw new MojoExecutionException ( "Invalid <TESTS> in your pom.xml: " + e . getMessage () );
273+ }
303274
304- if (StringUtils .isNotEmpty (testsRegexExpression )) {
305- fileMapperOptions .setRegexPattern (testsRegexExpression );
306- }
275+ }
307276
308- if (testsOwnerSubexpression != null ) {
309- fileMapperOptions .setOwnerSubExpression (testsOwnerSubexpression );
310- }
277+ private FileMapperOptions createFileMapperOptions (List <String > scripts , String objectOwner , String regexPattern ,
278+ Integer ownerSubExpression , Integer nameSubExpression ,
279+ Integer typeSubExpression , List <CustomTypeMapping > typeMappings ) {
280+ FileMapperOptions fileMapperOptions = new FileMapperOptions (scripts );
311281
312- if (testsNameSubexpression != null ) {
313- fileMapperOptions .setNameSubExpression ( testsNameSubexpression );
314- }
282+ if (StringUtils . isNotEmpty ( objectOwner ) ) {
283+ fileMapperOptions .setObjectOwner ( objectOwner );
284+ }
315285
316- if (testsTypeSubexpression != null ) {
317- fileMapperOptions .setTypeSubExpression ( testsTypeSubexpression );
318- }
286+ if (StringUtils . isNotEmpty ( regexPattern ) ) {
287+ fileMapperOptions .setRegexPattern ( regexPattern );
288+ }
319289
320- if (testsCustomTypeMapping != null && !testsCustomTypeMapping .isEmpty ()) {
321- fileMapperOptions .setTypeMappings (new ArrayList <>());
322- for (CustomTypeMapping typeMapping : testsCustomTypeMapping ) {
323- fileMapperOptions .getTypeMappings ()
324- .add (new KeyValuePair (typeMapping .getCustomMapping (), typeMapping .getType ()));
325- }
326- }
290+ if (ownerSubExpression != null ) {
291+ fileMapperOptions .setOwnerSubExpression (ownerSubExpression );
292+ }
327293
328- return fileMapperOptions ;
294+ if (nameSubExpression != null ) {
295+ fileMapperOptions .setNameSubExpression (nameSubExpression );
296+ }
329297
330- } catch (Exception e ) {
331- throw new MojoExecutionException ("Invalid <TESTS> in your pom.xml: " + e .getMessage ());
298+ if (typeSubExpression != null ) {
299+ fileMapperOptions .setTypeSubExpression (typeSubExpression );
300+ }
301+
302+ if (typeMappings != null && !typeMappings .isEmpty ()) {
303+ fileMapperOptions .setTypeMappings (new ArrayList <>());
304+ for (CustomTypeMapping typeMapping : typeMappings ) {
305+ fileMapperOptions .getTypeMappings ()
306+ .add (new KeyValuePair (typeMapping .getCustomMapping (), typeMapping .getType ()));
307+ }
332308 }
333309
310+ return fileMapperOptions ;
334311 }
335312
336313 private List <Reporter > initReporters (Connection connection , Version utlVersion , ReporterFactory reporterFactory )
0 commit comments