generated from keploy/template
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: bumping jacoc to 0.8.12 (#172)
* refactor:path name * refactor: remove debug logs Signed-off-by: shivamsouravjha <[email protected]> * refactor: bumping jacoc to 0.8.12 Signed-off-by: shivamsouravjha <[email protected]> * refactor: moving jacoco download to url * refactor: add logs * refactor:logs * remove:logs Signed-off-by: shivamsouravjha <[email protected]> --------- Signed-off-by: shivamsouravjha <[email protected]>
- Loading branch information
1 parent
4219528
commit bfa899b
Showing
5 changed files
with
109 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.keploy; | ||
|
||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.StandardCopyOption; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipInputStream; | ||
|
||
public class JaCoCoUtil { | ||
|
||
public static void downloadAndExtractJaCoCoBinaries(String version, String resourceDir) throws Exception { | ||
Path cliPath = Paths.get(resourceDir, "jacococli.jar"); | ||
Path agentPath = Paths.get(resourceDir, "jacocoagent.jar"); | ||
Files.createDirectories(cliPath.getParent()); | ||
Files.createDirectories(agentPath.getParent()); | ||
|
||
if (Files.exists(cliPath) && Files.exists(agentPath)) { | ||
return; | ||
} | ||
|
||
String downloadUrl = "https://github.com/jacoco/jacoco/releases/download/v" + version + "/jacoco-" + version + ".zip"; | ||
|
||
try (InputStream inputStream = new URL(downloadUrl).openStream(); | ||
ZipInputStream zipInputStream = new ZipInputStream(inputStream)) { | ||
|
||
ZipEntry entry; | ||
while ((entry = zipInputStream.getNextEntry()) != null) { | ||
if (entry.getName().endsWith("jacococli.jar")) { | ||
|
||
Files.copy(zipInputStream, cliPath, StandardCopyOption.REPLACE_EXISTING); | ||
|
||
} else if (entry.getName().endsWith("jacocoagent.jar")) { | ||
|
||
Files.copy(zipInputStream, agentPath, StandardCopyOption.REPLACE_EXISTING); | ||
|
||
} | ||
|
||
if (Files.exists(cliPath) && Files.exists(agentPath)) { | ||
|
||
break; // Both binaries extracted, no need to continue | ||
} | ||
} | ||
} | ||
|
||
if (!Files.exists(cliPath) || !Files.exists(agentPath)) { | ||
throw new IllegalStateException("Failed to find JaCoCo binaries in the distribution."); | ||
} | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
if (args.length != 2) { | ||
throw new IllegalArgumentException("Expected two arguments: version and resourceDir"); | ||
} | ||
String version = args[0]; | ||
String resourceDir = args[1]; | ||
try { | ||
downloadAndExtractJaCoCoBinaries(version, resourceDir); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
System.exit(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.