Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 780141c

Browse files
author
Jacek Gębal
committed
Add back HTML coverage resources.
The HTML coverage resources were missing since version 3.1.9 of the utplsql-java-api. They are now again included in the JAR so that the utplsql-maven-plugin and utPLSQL-cli can use it.
1 parent 5697135 commit 780141c

4 files changed

Lines changed: 54 additions & 8 deletions

File tree

pom.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
<sonar.organization>utplsql</sonar.organization>
2121
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
22+
23+
<coverage.html.version>1.0.1</coverage.html.version>
24+
<coverage.html.download.dir>${project.build.directory}/coverage-html-download</coverage.html.download.dir>
2225
</properties>
2326

2427
<licenses>
@@ -117,6 +120,49 @@
117120
</resource>
118121
</resources>
119122
<plugins>
123+
<plugin>
124+
<groupId>com.googlecode.maven-download-plugin</groupId>
125+
<artifactId>download-maven-plugin</artifactId>
126+
<version>1.8.1</version>
127+
<executions>
128+
<execution>
129+
<id>download-coverage-html-assets</id>
130+
<phase>generate-resources</phase>
131+
<goals>
132+
<goal>wget</goal>
133+
</goals>
134+
<configuration>
135+
<url>https://github.com/utPLSQL/utPLSQL-coverage-html/archive/refs/tags/${coverage.html.version}.zip</url>
136+
<outputDirectory>${coverage.html.download.dir}</outputDirectory>
137+
<outputFileName>coverage-html.zip</outputFileName>
138+
<unpack>true</unpack>
139+
</configuration>
140+
</execution>
141+
</executions>
142+
</plugin>
143+
<plugin>
144+
<groupId>org.apache.maven.plugins</groupId>
145+
<artifactId>maven-resources-plugin</artifactId>
146+
<version>3.3.1</version>
147+
<executions>
148+
<execution>
149+
<id>copy-coverage-html-assets</id>
150+
<phase>process-resources</phase>
151+
<goals>
152+
<goal>copy-resources</goal>
153+
</goals>
154+
<configuration>
155+
<outputDirectory>${project.build.outputDirectory}/CoverageHTMLReporter</outputDirectory>
156+
<resources>
157+
<resource>
158+
<directory>${coverage.html.download.dir}/utPLSQL-coverage-html-${coverage.html.version}/assets</directory>
159+
<filtering>false</filtering>
160+
</resource>
161+
</resources>
162+
</configuration>
163+
</execution>
164+
</executions>
165+
</plugin>
120166
<plugin>
121167
<groupId>org.apache.maven.plugins</groupId>
122168
<artifactId>maven-compiler-plugin</artifactId>

src/main/java/org/utplsql/api/ResourceUtil.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.net.URI;
55
import java.net.URISyntaxException;
6+
import java.net.URL;
67
import java.nio.file.*;
78
import java.nio.file.attribute.BasicFileAttributes;
89
import java.util.Collections;
@@ -27,7 +28,12 @@ public static void copyResources(Path resourceAsPath, Path targetDirectory) {
2728
try {
2829
String resourceName = "/" + resourceAsPath;
2930
Files.createDirectories(targetDirectory);
30-
URI uri = ResourceUtil.class.getResource(resourceName).toURI();
31+
URL resourceUrl = ResourceUtil.class.getResource(resourceName);
32+
if (resourceUrl == null) {
33+
throw new IOException("Coverage HTML assets not found in classpath: " + resourceName
34+
+ ". The JAR was built without bundled coverage HTML reporter assets.");
35+
}
36+
URI uri = resourceUrl.toURI();
3137
Path myPath;
3238
if (uri.getScheme().equalsIgnoreCase("jar")) {
3339
try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap())) {
@@ -44,7 +50,7 @@ public static void copyResources(Path resourceAsPath, Path targetDirectory) {
4450
}
4551

4652
private static void copyRecursive(Path from, Path targetDirectory) throws IOException {
47-
Files.walkFileTree(from, new SimpleFileVisitor<Path>() {
53+
Files.walkFileTree(from, new SimpleFileVisitor<>() {
4854

4955
@Override
5056
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {

src/test/java/org/utplsql/api/TestRunnerIT.java

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

3-
import org.junit.jupiter.api.Disabled;
43
import org.junit.jupiter.api.Test;
54
import org.junit.jupiter.api.function.Executable;
65
import org.utplsql.api.compatibility.CompatibilityProxy;
@@ -65,7 +64,6 @@ void runWithManyReporters() throws SQLException {
6564
/**
6665
* This can only be tested on frameworks >= 3.0.3
6766
*/
68-
@Disabled
6967
@Test
7068
void failOnErrors() throws SQLException, InvalidVersionException {
7169
Connection conn = getConnection();
@@ -82,8 +80,6 @@ void failOnErrors() throws SQLException, InvalidVersionException {
8280

8381
@Test
8482
void runWithRandomExecutionOrder() throws SQLException {
85-
CompatibilityProxy proxy = new CompatibilityProxy(getConnection());
86-
8783
new TestRunner()
8884
.randomTestOrder(true)
8985
.randomTestOrderSeed(123)

src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.utplsql.api.reporter;
22

3-
import org.junit.jupiter.api.Disabled;
43
import org.junit.jupiter.api.Tag;
54
import org.junit.jupiter.api.Test;
65
import org.junit.jupiter.api.io.TempDir;
@@ -25,7 +24,6 @@ private void testFileExists(Path filePath) {
2524
assertTrue(f.exists(), () -> "File " + f + " does not exist");
2625
}
2726

28-
@Disabled("No idea why this ever worked")
2927
@Test
3028
void writeReporterAssetsTo() throws RuntimeException {
3129

0 commit comments

Comments
 (0)