1818import org .apache .maven .plugins .annotations .Parameter ;
1919import org .utplsql .api .FileMapperOptions ;
2020import org .utplsql .api .TestRunner ;
21+ import org .utplsql .api .Version ;
2122import org .utplsql .api .exception .SomeTestsFailedException ;
2223import org .utplsql .api .reporter .Reporter ;
2324import org .utplsql .api .reporter .ReporterFactory ;
@@ -43,6 +44,9 @@ public class UtPLSQLMojo extends AbstractMojo
4344
4445 @ Parameter (defaultValue = "${dbPass}" )
4546 private String password ;
47+
48+ @ Parameter (defaultValue = "3.1.0" )
49+ private String version ;
4650
4751 @ Parameter
4852 private String includeObject ;
@@ -86,13 +90,14 @@ public class UtPLSQLMojo extends AbstractMojo
8690 public void execute () throws MojoExecutionException
8791 {
8892 Connection connection = null ;
89- try
93+ try
9094 {
9195 FileMapperOptions sourceMappingOptions = buildOptions (sources , PluginDefault .buildDefaultSource (), "sources" );
9296 FileMapperOptions testMappingOptions = buildOptions (tests , PluginDefault .buildDefaultTest (), "test" );
93-
97+
9498 // Create the Connection to the Database
9599 connection = DriverManager .getConnection (url , user , password );
100+
96101 List <Reporter > reporterList = initReporters (connection );
97102
98103 logParameters (sourceMappingOptions , testMappingOptions , reporterList );
@@ -117,7 +122,7 @@ public void execute() throws MojoExecutionException
117122 }
118123
119124 runner .run (connection );
120-
125+
121126 }
122127 catch (SomeTestsFailedException e )
123128 {
@@ -135,11 +140,6 @@ public void execute() throws MojoExecutionException
135140 {
136141 // Write Reporters
137142 reporterWriter .writeReporters (connection );
138-
139- if (connection != null )
140- {
141- connection .close ();
142- }
143143 }
144144 catch (Exception e )
145145 {
@@ -184,13 +184,17 @@ private FileMapperOptions buildOptions(List<Resource> resources, Resource defaul
184184 private List <Reporter > initReporters (Connection connection ) throws SQLException
185185 {
186186 List <Reporter > reporterList = new ArrayList <>();
187+
188+ Version utlVersion = new Version (version );
187189
188- // Initializate Reporters
189- reporterWriter = new ReporterWriter (targetDir );
190+ // Initialized Reporters
191+ reporterWriter = new ReporterWriter (targetDir , utlVersion );
192+
193+ ReporterFactory reporterFactory = ReporterFactory .createEmpty ();
190194
191195 for (ReporterParameter reporterParameter : reporters )
192196 {
193- Reporter reporter = ReporterFactory .createReporter (reporterParameter .getName ());
197+ Reporter reporter = reporterFactory .createReporter (reporterParameter .getName ());
194198 reporter .init (connection );
195199 reporterList .add (reporter );
196200
@@ -224,7 +228,7 @@ private void logParameters(FileMapperOptions sourceMappingOptions, FileMapperOpt
224228
225229 log .debug ("Invoking TestRunner with: " );
226230 log .debug ("reporters=" );
227- reporterList .forEach ((Reporter r ) -> log .debug (r .getSelfType ()));
231+ reporterList .forEach ((Reporter r ) -> log .debug (r .getTypeName ()));
228232 log .debug ("sources=" );
229233 sourceMappingOptions .getFilePaths ().forEach (log ::debug );
230234 log .debug ("tests=" );
0 commit comments