44import java .sql .DriverManager ;
55import java .sql .SQLException ;
66import java .util .ArrayList ;
7- import java .util .Arrays ;
87import java .util .List ;
8+ import java .util .function .Consumer ;
99
1010import org .apache .maven .model .Resource ;
1111import org .apache .maven .plugin .AbstractMojo ;
1414import org .apache .maven .plugins .annotations .Mojo ;
1515import org .apache .maven .plugins .annotations .Parameter ;
1616import org .utplsql .api .FileMapperOptions ;
17+ import org .utplsql .api .OutputBuffer ;
1718import org .utplsql .api .TestRunner ;
1819import org .utplsql .api .reporter .Reporter ;
1920import org .utplsql .api .reporter .ReporterFactory ;
@@ -45,10 +46,13 @@ public class UtPLSQLMojo extends AbstractMojo
4546 // Configuration of Sources, Testing
4647
4748 @ Parameter
48- private List <Resource > sources = new ArrayList <Resource >();
49+ private List <Resource > sources = new ArrayList <>();
4950
5051 @ Parameter
51- private List <Resource > tests = new ArrayList <Resource >();
52+ private List <Resource > tests = new ArrayList <>();
53+
54+ @ Parameter
55+ private List <String > reports = new ArrayList <>();
5256
5357 /**
5458 *
@@ -58,10 +62,11 @@ public class UtPLSQLMojo extends AbstractMojo
5862 @ Override
5963 public void execute () throws MojoExecutionException
6064 {
61- List <String > testPaths = Arrays .asList (new String [] { "tests" });
65+ // List<String> testPaths = Arrays.asList(new String[] { "tests" });
6266
63- FileMapperOptions sourceMappingOptions = buildOptions (sources , PluginDefault .buildDefaultSource ());
64- FileMapperOptions testMappingOptions = buildOptions (tests , PluginDefault .buildDefaultTest ());
67+ FileMapperOptions sourceMappingOptions = buildOptions (sources ,
68+ PluginDefault .buildDefaultSource ());
69+ FileMapperOptions testMappingOptions = buildOptions (tests , PluginDefault .buildDefaultTest ());
6570
6671 Connection connection = null ;
6772 List <Reporter > reporterList = null ;
@@ -72,10 +77,44 @@ public void execute() throws MojoExecutionException
7277
7378 // Init Reporters
7479 reporterList = initReporters (connection );
80+ if (getLog ().isDebugEnabled ()) {
81+ StringBuilder msg = new StringBuilder ();
82+ msg .append ("Invoking TestRunner with: " ).append ('\n' );
83+ msg .append ("reporters=" );
84+ reporterList .forEach (new Consumer <Reporter >() {
85+ @ Override
86+ public void accept (Reporter t ) {
87+ try {
88+ msg .append (t .getSQLTypeName ()).append (", " );
89+ } catch (Exception e ) {
90+ // NA
91+ }
92+ }
93+
94+ });
95+ msg .append ('\n' );
96+ msg .append ("sources=" );
97+ sourceMappingOptions .getFilePaths ().forEach (new Consumer <String >() {
98+ @ Override
99+ public void accept (String t ) {
100+ msg .append (t ).append (", " );
101+ }
102+ });
103+ msg .append ('\n' );
104+ msg .append ("tests=" );
105+ testMappingOptions .getFilePaths ().forEach (new Consumer <String >() {
106+ @ Override
107+ public void accept (String t ) {
108+ msg .append (t ).append (", " );
109+ }
110+ });
111+ msg .append ('\n' );
112+ getLog ().debug (msg .toString ());
113+ }
75114
76115 TestRunner runner = new TestRunner ()
77- .addPathList (testPaths )
78- .addReporterList (reporterList )
116+ // .addPathList(testPaths)
117+ .addReporterList (reporterList )
79118 .sourceMappingOptions (sourceMappingOptions )
80119 .testMappingOptions (testMappingOptions )
81120 .colorConsole (colorConsole )
@@ -92,11 +131,15 @@ public void execute() throws MojoExecutionException
92131 finally
93132 {
94133 try
95- {
96- if (connection != null )
134+ {
135+ for (Reporter reporter : reporterList ) {
136+ new OutputBuffer (reporter ).printAvailable (connection , reporter .outputFile ());
137+ }
138+ if (connection != null ) {
97139 connection .close ();
140+ }
98141 }
99- catch (SQLException e )
142+ catch (Exception e )
100143 {
101144 getLog ().error ("Error" , e );
102145 }
@@ -108,7 +151,7 @@ public void execute() throws MojoExecutionException
108151 * @param resources
109152 * @return
110153 */
111- private FileMapperOptions buildOptions (List <Resource > resources , Resource defaultResource )
154+ private FileMapperOptions buildOptions (List <Resource > resources , Resource defaultResource )
112155 {
113156 // Check if this element is empty
114157 if (resources .isEmpty ())
@@ -129,7 +172,7 @@ private FileMapperOptions buildOptions(List<Resource> resources, Resource defaul
129172 */
130173 private List <Reporter > initReporters (Connection connection ) throws SQLException
131174 {
132- List <Reporter > reporterList = new ArrayList <Reporter >();
175+ List <Reporter > reporterList = new ArrayList <>();
133176
134177 for (String reporterId : reporters )
135178 {
0 commit comments