Skip to content

Commit 992e53a

Browse files
committed
Reduced dependencies
1 parent f5defe9 commit 992e53a

File tree

6 files changed

+87
-59
lines changed

6 files changed

+87
-59
lines changed

pom.xml

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5656

5757
<maven.version>3.5.2</maven.version>
58-
<jaxb.version>2.3.1</jaxb.version>
5958
<itf.version>0.11.0</itf.version>
6059

6160
<sonar.organization>utplsql</sonar.organization>
@@ -76,25 +75,21 @@
7675

7776
<dependencies>
7877
<dependency>
79-
<groupId>com.sun.xml.bind</groupId>
80-
<artifactId>jaxb-core</artifactId>
81-
<version>3.0.1</version>
78+
<groupId>org.apache.maven</groupId>
79+
<artifactId>maven-core</artifactId>
80+
<version>${maven.version}</version>
81+
<scope>provided</scope>
8282
</dependency>
8383
<dependency>
84-
<groupId>javax.xml.bind</groupId>
85-
<artifactId>jaxb-api</artifactId>
86-
<version>${jaxb.version}</version>
84+
<groupId>org.apache.maven.plugin-tools</groupId>
85+
<artifactId>maven-plugin-annotations</artifactId>
86+
<version>${maven.version}</version>
87+
<scope>provided</scope>
8788
</dependency>
8889
<dependency>
89-
<groupId>com.sun.xml.bind</groupId>
90-
<artifactId>jaxb-impl</artifactId>
91-
<version>${jaxb.version}</version>
92-
</dependency>
93-
94-
<dependency>
95-
<groupId>com.oracle.database.jdbc</groupId>
96-
<artifactId>ojdbc8</artifactId>
97-
<version>21.3.0.0</version>
90+
<groupId>org.apache.maven.shared</groupId>
91+
<artifactId>maven-shared-utils</artifactId>
92+
<version>3.1.0</version>
9893
</dependency>
9994

10095
<dependency>
@@ -104,31 +99,15 @@
10499
</dependency>
105100

106101
<dependency>
107-
<groupId>org.apache.maven</groupId>
108-
<artifactId>maven-core</artifactId>
109-
<version>${maven.version}</version>
110-
</dependency>
111-
<dependency>
112-
<groupId>org.apache.maven</groupId>
113-
<artifactId>maven-model</artifactId>
114-
<version>${maven.version}</version>
115-
</dependency>
116-
<dependency>
117-
<groupId>org.apache.maven</groupId>
118-
<artifactId>maven-plugin-api</artifactId>
119-
<version>${maven.version}</version>
120-
</dependency>
121-
<dependency>
122-
<groupId>org.apache.maven.plugin-tools</groupId>
123-
<artifactId>maven-plugin-annotations</artifactId>
124-
<version>${maven.version}</version>
125-
<scope>provided</scope>
102+
<groupId>com.oracle.database.jdbc</groupId>
103+
<artifactId>ojdbc8</artifactId>
104+
<version>21.3.0.0</version>
126105
</dependency>
127106

128107
<dependency>
129108
<groupId>org.codehaus.plexus</groupId>
130109
<artifactId>plexus-utils</artifactId>
131-
<version>3.4.1</version>
110+
<version>3.1.0</version>
132111
</dependency>
133112

134113
<!-- Test Dependencies -->
@@ -168,12 +147,6 @@
168147
<scope>test</scope>
169148
</dependency>
170149

171-
<dependency>
172-
<groupId>commons-io</groupId>
173-
<artifactId>commons-io</artifactId>
174-
<version>2.6</version>
175-
<scope>test</scope>
176-
</dependency>
177150
<dependency>
178151
<groupId>org.slf4j</groupId>
179152
<artifactId>slf4j-simple</artifactId>

src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.utplsql.maven.plugin;
22

33
import oracle.jdbc.pool.OracleDataSource;
4-
import org.apache.commons.lang3.StringUtils;
54
import org.apache.maven.model.Resource;
65
import org.apache.maven.plugin.AbstractMojo;
76
import org.apache.maven.plugin.MojoExecutionException;
@@ -37,6 +36,10 @@
3736
import java.util.Set;
3837
import java.util.stream.Collectors;
3938

39+
import static org.utplsql.maven.plugin.util.StringUtil.isEmpty;
40+
import static org.utplsql.maven.plugin.util.StringUtil.isNotBlank;
41+
import static org.utplsql.maven.plugin.util.StringUtil.isNotEmpty;
42+
4043
/**
4144
* This class expose the {@link TestRunner} interface to Maven.
4245
*
@@ -158,10 +161,10 @@ public void execute() throws MojoExecutionException {
158161
.randomTestOrderSeed(randomTestOrderSeed)
159162
.failOnErrors(!ignoreFailure);
160163

161-
if (StringUtils.isNotBlank(excludeObject)) {
164+
if (isNotBlank(excludeObject)) {
162165
runner.excludeObject(excludeObject);
163166
}
164-
if (StringUtils.isNotBlank(includeObject)) {
167+
if (isNotBlank(includeObject)) {
165168
runner.includeObject(includeObject);
166169
}
167170

@@ -189,15 +192,14 @@ public void execute() throws MojoExecutionException {
189192
}
190193
}
191194

192-
193195
private Connection createConnection() throws SQLException {
194-
if (StringUtils.isEmpty(url)) {
196+
if (isEmpty(url)) {
195197
url = System.getProperty("dbUrl");
196198
}
197-
if (StringUtils.isEmpty(user)) {
199+
if (isEmpty(user)) {
198200
user = System.getProperty("dbUser");
199201
}
200-
if (StringUtils.isEmpty(password)) {
202+
if (isEmpty(password)) {
201203
password = System.getProperty("dbPass");
202204
}
203205

@@ -251,10 +253,10 @@ private FileMapperOptions createFileMapperOptions(List<String> scripts, String o
251253
Integer typeSubExpression, List<CustomTypeMapping> typeMappings) {
252254
FileMapperOptions fileMapperOptions = new FileMapperOptions(scripts);
253255

254-
if (StringUtils.isNotEmpty(objectOwner)) {
256+
if (isNotEmpty(objectOwner)) {
255257
fileMapperOptions.setObjectOwner(objectOwner);
256258
}
257-
if (StringUtils.isNotEmpty(regexPattern)) {
259+
if (isNotEmpty(regexPattern)) {
258260
fileMapperOptions.setRegexPattern(regexPattern);
259261
}
260262
if (ownerSubExpression != null) {
@@ -295,7 +297,7 @@ List<Reporter> initReporters(Connection connection, ReportWriter reportWriter, R
295297
}
296298

297299
// Only added the reporter if at least one of the output is required
298-
if (StringUtils.isNotBlank(reporterParameter.getFileOutput()) || reporterParameter.isConsoleOutput()) {
300+
if (isNotBlank(reporterParameter.getFileOutput()) || reporterParameter.isConsoleOutput()) {
299301
reportWriter.addReporter(reporterParameter, reporter);
300302
}
301303
}

src/main/java/org/utplsql/maven/plugin/io/ReportWriter.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.utplsql.maven.plugin.io;
22

3-
import org.apache.commons.lang3.tuple.Pair;
43
import org.apache.maven.plugin.logging.Log;
54
import org.utplsql.api.Version;
65
import org.utplsql.api.outputBuffer.OutputBuffer;
@@ -27,7 +26,7 @@
2726
*/
2827
public class ReportWriter {
2928

30-
private final List<Pair<Reporter, ReporterParameter>> reporters;
29+
private final List<ReporterAndReporterParameter> reporters;
3130

3231
private final String outputDirectory;
3332

@@ -56,7 +55,7 @@ public ReportWriter(String outputDirectory, Version databaseVersion, Log log) {
5655
* @param reporter the {@link Reporter}
5756
*/
5857
public void addReporter(ReporterParameter parameter, Reporter reporter) {
59-
reporters.add(Pair.of(reporter, parameter));
58+
reporters.add(new ReporterAndReporterParameter(reporter, parameter));
6059
}
6160

6261
/**
@@ -67,8 +66,8 @@ public void addReporter(ReporterParameter parameter, Reporter reporter) {
6766
* @throws IOException if files can't be written
6867
*/
6968
public void writeReports(Connection connection) throws SQLException, IOException {
70-
for (Pair<Reporter, ReporterParameter> pair : reporters) {
71-
writeReports(connection, pair.getLeft(), pair.getRight());
69+
for (ReporterAndReporterParameter pair : reporters) {
70+
writeReports(connection, pair.getReporter(), pair.getReporterParameter());
7271
}
7372
}
7473

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.utplsql.maven.plugin.io;
2+
3+
import org.utplsql.api.reporter.Reporter;
4+
import org.utplsql.maven.plugin.model.ReporterParameter;
5+
6+
public class ReporterAndReporterParameter {
7+
8+
private final Reporter reporter;
9+
private final ReporterParameter reporterParameter;
10+
11+
public ReporterAndReporterParameter(Reporter reporter, ReporterParameter reporterParameter) {
12+
this.reporter = reporter;
13+
this.reporterParameter = reporterParameter;
14+
}
15+
16+
public Reporter getReporter() {
17+
return reporter;
18+
}
19+
20+
public ReporterParameter getReporterParameter() {
21+
return reporterParameter;
22+
}
23+
}

src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.utplsql.maven.plugin.model;
22

3-
import org.codehaus.plexus.util.StringUtils;
3+
import static org.utplsql.maven.plugin.util.StringUtil.isNotBlank;
44

55
/**
66
* Represents a reporter parameter in the pom file.
@@ -54,7 +54,7 @@ public String getFileOutput() {
5454
* @return true if the file output is enabled, false otherwise
5555
*/
5656
public boolean isFileOutput() {
57-
return StringUtils.isNotBlank(fileOutput);
57+
return isNotBlank(fileOutput);
5858
}
5959

6060
/**
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.utplsql.maven.plugin.util;
2+
3+
public class StringUtil {
4+
5+
private StringUtil() {
6+
}
7+
8+
public static boolean isEmpty(CharSequence cs) {
9+
return cs == null || cs.length() == 0;
10+
}
11+
12+
public static boolean isNotEmpty(CharSequence cs) {
13+
return !isEmpty(cs);
14+
}
15+
16+
public static boolean isBlank(CharSequence cs) {
17+
int strLen;
18+
if (cs != null && (strLen = cs.length()) != 0) {
19+
for (int i = 0; i < strLen; ++i) {
20+
if (!Character.isWhitespace(cs.charAt(i))) {
21+
return false;
22+
}
23+
}
24+
}
25+
return true;
26+
}
27+
28+
public static boolean isNotBlank(CharSequence cs) {
29+
return !isBlank(cs);
30+
}
31+
}

0 commit comments

Comments
 (0)