Reputation: 613
At the moment for a project I'm working on I'm using a Maven style project.
I'm using Maven for all my dependencies.
One of my dependencies is a jar
file (ExtentReports).
I want to edit an XML file within this jar
file. How can I achieve this?
I've seen online about using a ZIP tool, but would it not be overwritten once the program is re-run as I'm using Maven? Or is my concept of Maven wrong?
Thanks in advance.
EDIT:
<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>standard</theme>
I want to change the above to
<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>dark</theme>
Upvotes: 0
Views: 199
Reputation: 725
That is not the correct approach as the settings part of the ExtentReports.jar are default and any other settings that you load during runtime overwrite default ones.
See here: http://extentreports.relevantcodes.com/java/#configuration
Copy the entire configuration block from the above link, place it inside an XML file and put it in your source. After that, simply use one of the methods below to load the XML when your project starts:
// file location: "C:\HelloWorld\extent-config.xml"
loadConfig(new File("C:\HelloWorld\extent-config.xml"));
// loadConfig(Class clazz, String fileName);
// clazz: com.relevantcodes.extentreports.ExtentReports
// packagePath of clazz: com/relevantcodes/extentreports
// final path: com/relevantcodes/extentreports/extent-config.xml
loadConfig(ExtentReports.class, "extent-config.xml");
// loadConfig(Class clazz, String basePackagePath, String fileName;
// clazz: com.relevantcodes.extentreports.ExtentReports
// packagePath of clazz: com/relevantcodes/extentreports
// basePackagePath: "resources"
// final path: com/relevantcodes/extentreports/resources/extent-config.xml
loadConfig(ExtentReports.class, "resources", "extent-config.xml");
Upvotes: 1