@@ -61,17 +61,49 @@ public class UtPLSQLMojo extends AbstractMojo
6161 @ Parameter (defaultValue = "" )
6262 protected List <String > paths ;
6363
64+ // Sources Configuration
6465 @ Parameter
6566 protected List <Resource > sources = new ArrayList <>();
67+
68+ @ Parameter
69+ private String sourcesRegexExpression ;
70+
71+ @ Parameter
72+ private Integer sourcesOwnerSubexpression ;
73+
74+ @ Parameter
75+ private Integer sourcesNameSubexpression ;
76+
77+ @ Parameter
78+ private Integer sourcesTypeSubexpression ;
6679
80+
81+ // Tests Configuration
82+
6783 @ Parameter
6884 protected List <Resource > tests = new ArrayList <>();
85+
86+ @ Parameter
87+ private String testsRegexExpression ;
88+
89+ @ Parameter
90+ private Integer testsOwnerSubexpression ;
91+
92+ @ Parameter
93+ private Integer testsNameSubexpression ;
94+
95+ @ Parameter
96+ private Integer testsTypeSubexpression ;
97+
6998
7099 @ Parameter (defaultValue = "${project.build.directory}" , readonly = true )
71100 protected String targetDir ;
72101
73102 @ Parameter (defaultValue = "${maven.test.failure.ignore}" )
74103 protected boolean ignoreFailure ;
104+
105+
106+
75107
76108
77109 // Color in the console, loaded by environment variables
@@ -93,8 +125,8 @@ public void execute() throws MojoExecutionException
93125 Connection connection = null ;
94126 try
95127 {
96- FileMapperOptions sourceMappingOptions = buildOptions ( sources , PluginDefault . buildDefaultSource (), "sources" );
97- FileMapperOptions testMappingOptions = buildOptions ( tests , PluginDefault . buildDefaultTest (), "test" );
128+ FileMapperOptions sourceMappingOptions = buildSourcesOptions ( );
129+ FileMapperOptions testMappingOptions = buildTestsOptions ( );
98130
99131 // Create the Connection to the Database
100132 connection = DriverManager .getConnection (url , user , password );
@@ -173,26 +205,98 @@ private void loadDefaultCredentials ()
173205 * @return
174206 * @throws MojoExecutionException
175207 */
176- private FileMapperOptions buildOptions ( List < Resource > resources , Resource defaultResource , String msg ) throws MojoExecutionException
208+ private FileMapperOptions buildSourcesOptions ( ) throws MojoExecutionException
177209 {
178210 try
179211 {
180212 // Check if this element is empty
181- if (resources .isEmpty ())
213+ if (sources .isEmpty ())
182214 {
183- resources .add (defaultResource );
215+ sources .add (PluginDefault . buildDefaultSource () );
184216 }
185217
186- List <String > scripts = SQLScannerHelper .findSQLs (resources );
187- return new FileMapperOptions (scripts );
218+ List <String > scripts = SQLScannerHelper .findSQLs (sources );
219+ FileMapperOptions fileMapperOptions = new FileMapperOptions (scripts );
220+
221+ if (StringUtils .isNotEmpty (sourcesRegexExpression ))
222+ {
223+ fileMapperOptions .setRegexPattern (sourcesRegexExpression );
224+ }
225+
226+ if (sourcesOwnerSubexpression != null )
227+ {
228+ fileMapperOptions .setOwnerSubExpression (sourcesOwnerSubexpression );
229+ }
230+
231+ if (sourcesNameSubexpression != null )
232+ {
233+ fileMapperOptions .setNameSubExpression (sourcesNameSubexpression );
234+ }
235+
236+ if (sourcesTypeSubexpression != null )
237+ {
238+ fileMapperOptions .setTypeSubExpression (sourcesTypeSubexpression );
239+ }
240+
241+ return fileMapperOptions ;
188242
189243 }
190244 catch (Exception e )
191245 {
192- throw new MojoExecutionException (format ( "Invalid <%s > in your pom.xml: %s" , msg , e .getMessage () ));
246+ throw new MojoExecutionException ("Invalid <SOURCES > in your pom.xml: " + e .getMessage ());
193247 }
248+
194249 }
250+
251+
252+ /**
253+ *
254+ * @param resources
255+ * @return
256+ * @throws MojoExecutionException
257+ */
258+ private FileMapperOptions buildTestsOptions () throws MojoExecutionException
259+ {
260+ try
261+ {
262+ // Check if this element is empty
263+ if (tests .isEmpty ())
264+ {
265+ tests .add (PluginDefault .buildDefaultTest ());
266+ }
195267
268+ List <String > scripts = SQLScannerHelper .findSQLs (tests );
269+ FileMapperOptions fileMapperOptions = new FileMapperOptions (scripts );
270+
271+ if (StringUtils .isNotEmpty (testsRegexExpression ))
272+ {
273+ fileMapperOptions .setRegexPattern (testsRegexExpression );
274+ }
275+
276+ if (testsOwnerSubexpression != null )
277+ {
278+ fileMapperOptions .setOwnerSubExpression (testsOwnerSubexpression );
279+ }
280+
281+ if (testsNameSubexpression != null )
282+ {
283+ fileMapperOptions .setNameSubExpression (testsNameSubexpression );
284+ }
285+
286+ if (testsTypeSubexpression != null )
287+ {
288+ fileMapperOptions .setTypeSubExpression (testsTypeSubexpression );
289+ }
290+
291+ return fileMapperOptions ;
292+
293+ }
294+ catch (Exception e )
295+ {
296+ throw new MojoExecutionException ("Invalid <TESTS> in your pom.xml: " + e .getMessage ());
297+ }
298+
299+ }
196300 /**
197301 * Init all the reporters
198302 *
0 commit comments