com.github.webdriverextensions.DriverVersionHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webdriverextensions-maven-plugin Show documentation
Show all versions of webdriverextensions-maven-plugin Show documentation
Use this plugin to manage, download and install WebDriver drivers directly from your pom.
The newest version!
package com.github.webdriverextensions;
import java.io.File;
import java.io.IOException;
import org.apache.maven.plugin.MojoExecutionException;
class DriverVersionHandler {
private final File installationDirectory;
public DriverVersionHandler(File installationDirectory) {
this.installationDirectory = installationDirectory;
}
void writeVersionFile(Driver driver) throws MojoExecutionException {
File file = getVersionFile(driver);
String versionString = createVersionString(driver);
try {
org.apache.commons.io.FileUtils.writeStringToFile(file, versionString);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
private String createVersionString(Driver driver) {
return driver.toString();
}
private File getVersionFile(Driver driver) {
return new File(installationDirectory + "/" + driver.getId() + ".version");
}
public boolean isSameVersion(Driver driver) throws MojoExecutionException {
try {
File versionFile = getVersionFile(driver);
if (!versionFile.exists()) {
return false;
}
String savedVersion = org.apache.commons.io.FileUtils.readFileToString(versionFile);
String currentVersion = createVersionString(driver);
return savedVersion.equals(currentVersion);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy