|
3 | 3 | import org.utplsql.api.CustomTypes;
|
4 | 4 |
|
5 | 5 | import java.io.IOException;
|
| 6 | +import java.io.InputStream; |
6 | 7 | import java.nio.file.Files;
|
7 | 8 | import java.nio.file.Path;
|
8 | 9 | import java.nio.file.Paths;
|
@@ -63,9 +64,55 @@ public void writeSQL(SQLOutput stream) throws SQLException {
|
63 | 64 | stream.writeString(getAssetsPath());
|
64 | 65 | }
|
65 | 66 |
|
| 67 | + private static void copyFileFromClasspath( Path assetPath, Path targetDirectory ) throws IOException { |
| 68 | + Files.createDirectories(targetDirectory.resolve(assetPath).getParent()); |
| 69 | + |
| 70 | + try (InputStream is = CoverageHTMLReporter.class.getClassLoader() |
| 71 | + .getResourceAsStream( |
| 72 | + Paths.get("CoverageHTMLReporter").resolve(assetPath).toString() |
| 73 | + ) |
| 74 | + ) { |
| 75 | + Files.copy( is, targetDirectory.resolve(assetPath) ); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + /** Write the bundled assets necessary for the HTML Coverage report to a given targetPath |
| 80 | + * |
| 81 | + * @param targetDirectory Directory where the assets should be stored |
| 82 | + * @throws IOException |
| 83 | + */ |
66 | 84 | public static void writeReportAssetsTo(Path targetDirectory) throws IOException {
|
67 | 85 |
|
68 | 86 | Files.createDirectories(targetDirectory);
|
69 | 87 |
|
| 88 | + // Simplest approach to start with |
| 89 | + copyFileFromClasspath(Paths.get("application.css"), targetDirectory); |
| 90 | + copyFileFromClasspath(Paths.get("application.js"), targetDirectory); |
| 91 | + copyFileFromClasspath(Paths.get("favicon_green.png"), targetDirectory); |
| 92 | + copyFileFromClasspath(Paths.get("favicon_red.png"), targetDirectory); |
| 93 | + copyFileFromClasspath(Paths.get("favicon_yellow.png"), targetDirectory); |
| 94 | + copyFileFromClasspath(Paths.get("loading.gif"), targetDirectory); |
| 95 | + copyFileFromClasspath(Paths.get("magnify.png"), targetDirectory); |
| 96 | + |
| 97 | + copyFileFromClasspath(Paths.get("colorbox", "border.png"), targetDirectory); |
| 98 | + copyFileFromClasspath(Paths.get("colorbox", "controls.png"), targetDirectory); |
| 99 | + copyFileFromClasspath(Paths.get("colorbox", "loading.gif"), targetDirectory); |
| 100 | + copyFileFromClasspath(Paths.get("colorbox", "loading_background.png"), targetDirectory); |
| 101 | + |
| 102 | + copyFileFromClasspath(Paths.get("images", "ui-bg_flat_0_aaaaaa_40x100.png"), targetDirectory); |
| 103 | + copyFileFromClasspath(Paths.get("images", "ui-bg_flat_75_ffffff_40x100.png"), targetDirectory); |
| 104 | + copyFileFromClasspath(Paths.get("images", "ui-bg_glass_55_fbf9ee_1x400.png"), targetDirectory); |
| 105 | + copyFileFromClasspath(Paths.get("images", "ui-bg_glass_65_ffffff_1x400.png"), targetDirectory); |
| 106 | + copyFileFromClasspath(Paths.get("images", "ui-bg_glass_75_dadada_1x400.png"), targetDirectory); |
| 107 | + copyFileFromClasspath(Paths.get("images", "ui-bg_glass_75_e6e6e6_1x400.png"), targetDirectory); |
| 108 | + copyFileFromClasspath(Paths.get("images", "ui-bg_glass_95_fef1ec_1x400.png"), targetDirectory); |
| 109 | + copyFileFromClasspath(Paths.get("images", "ui-bg_highlight-soft_75_cccccc_1x100.png"), targetDirectory); |
| 110 | + copyFileFromClasspath(Paths.get("images", "ui-icons_2e83ff_256x240.png"), targetDirectory); |
| 111 | + copyFileFromClasspath(Paths.get("images", "ui-icons_222222_256x240.png"), targetDirectory); |
| 112 | + copyFileFromClasspath(Paths.get("images", "ui-icons_454545_256x240.png"), targetDirectory); |
| 113 | + copyFileFromClasspath(Paths.get("images", "ui-icons_888888_256x240.png"), targetDirectory); |
| 114 | + copyFileFromClasspath(Paths.get("images", "ui-icons_cd0a0a_256x240.png"), targetDirectory); |
| 115 | + |
| 116 | + |
70 | 117 | }
|
71 | 118 | }
|
0 commit comments