Skip to content

Commit c2dcf2f

Browse files
committed
Fix #55 relative file paths are supported again.
1 parent aa67f73 commit c2dcf2f

File tree

3 files changed

+33
-42
lines changed

3 files changed

+33
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
##Next Version (Release Date TBC) Release Notes
44

5+
##Version 1.0.14 Release Notes
6+
7+
* Fix #55 Relative file paths are now supported again.
8+
59
##Version 1.0.13 Release Notes
610

711
* Fix #47 Support to read the RepositoryMap.xml from plugin dependencies added (Thanks [Haroon Sheikh](https://github.com/haroon-sheikh))

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@
181181
<artifactId>maven-compiler-plugin</artifactId>
182182
<version>3.5.1</version>
183183
<configuration>
184-
<source>1.7</source>
185-
<target>1.7</target>
184+
<source>1.8</source>
185+
<target>1.8</target>
186186
</configuration>
187187
</plugin>
188188
<plugin>

src/main/java/com/lazerycode/selenium/SeleniumServerMojo.java

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
11
package com.lazerycode.selenium;
22

33
import com.lazerycode.selenium.download.DownloadHandler;
4-
import com.lazerycode.selenium.repository.DriverContext;
5-
import com.lazerycode.selenium.repository.DriverDetails;
6-
import com.lazerycode.selenium.repository.DriverMap;
7-
import static com.lazerycode.selenium.repository.FileRepository.buildDownloadableFileRepository;
8-
import com.lazerycode.selenium.repository.OperatingSystem;
9-
import static com.lazerycode.selenium.repository.OperatingSystem.getOperatingSystem;
10-
import com.lazerycode.selenium.repository.SystemArchitecture;
11-
import static com.lazerycode.selenium.repository.SystemArchitecture.getCurrentSystemArcitecture;
12-
import com.lazerycode.selenium.repository.XMLParser;
13-
import java.io.File;
14-
import java.io.IOException;
15-
import java.io.InputStream;
16-
import java.net.URISyntaxException;
17-
import java.net.URL;
18-
import java.util.ArrayList;
19-
import java.util.HashMap;
20-
import java.util.HashSet;
21-
import java.util.Map;
22-
import java.util.Set;
23-
import javax.xml.XMLConstants;
24-
import javax.xml.bind.JAXBException;
25-
import javax.xml.transform.Source;
26-
import javax.xml.transform.stream.StreamSource;
27-
import javax.xml.validation.Schema;
28-
import javax.xml.validation.SchemaFactory;
29-
import javax.xml.validation.Validator;
30-
import javax.xml.xpath.XPathExpressionException;
4+
import com.lazerycode.selenium.repository.*;
315
import org.apache.log4j.BasicConfigurator;
326
import org.apache.log4j.Logger;
337
import org.apache.maven.plugin.AbstractMojo;
@@ -43,6 +17,25 @@
4317
import org.codehaus.plexus.resource.loader.ResourceNotFoundException;
4418
import org.xml.sax.SAXException;
4519

20+
import javax.xml.XMLConstants;
21+
import javax.xml.bind.JAXBException;
22+
import javax.xml.transform.Source;
23+
import javax.xml.transform.stream.StreamSource;
24+
import javax.xml.validation.Schema;
25+
import javax.xml.validation.SchemaFactory;
26+
import javax.xml.validation.Validator;
27+
import javax.xml.xpath.XPathExpressionException;
28+
import java.io.File;
29+
import java.io.IOException;
30+
import java.io.InputStream;
31+
import java.net.URISyntaxException;
32+
import java.net.URL;
33+
import java.util.*;
34+
35+
import static com.lazerycode.selenium.repository.FileRepository.buildDownloadableFileRepository;
36+
import static com.lazerycode.selenium.repository.OperatingSystem.getOperatingSystem;
37+
import static com.lazerycode.selenium.repository.SystemArchitecture.getCurrentSystemArcitecture;
38+
4639
/**
4740
* Selenium Standalone Server Maven Plugin
4841
*
@@ -254,9 +247,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
254247
throw new MojoExecutionException("Failed to download all of the standalone executables: " + e.getLocalizedMessage());
255248
} catch (URISyntaxException e) {
256249
throw new MojoExecutionException("Invalid URI detected: " + e.getLocalizedMessage());
257-
} catch (XPathExpressionException rethrow) {
258-
throw new MojoExecutionException(rethrow.getMessage());
259-
} catch (JAXBException rethrow) {
250+
} catch (XPathExpressionException | JAXBException rethrow) {
260251
throw new MojoExecutionException(rethrow.getMessage());
261252
}
262253

@@ -284,12 +275,12 @@ protected void setSystemProperties(DriverMap driverRepository) {
284275
}
285276

286277
private File getRepositoryMapFile(String customRepositoryMap) {
287-
File repositoryMap = null;
278+
File repositoryMap;
288279
try {
289280
repositoryMap = locator.getResourceAsFile(customRepositoryMap);
290-
} catch (ResourceNotFoundException e) {
291-
LOG.info("Unable to access the specified custom repository map, defaulting to bundled version...\n");
292-
} catch (FileResourceCreationException e) {
281+
} catch (ResourceNotFoundException | FileResourceCreationException e) {
282+
LOG.info("Unable to find the specified custom repository map, attempting to use value as a file path...\n");
283+
repositoryMap = new File(customRepositoryMap);
293284
}
294285
return repositoryMap;
295286
}
@@ -331,12 +322,8 @@ protected void checkRepositoryMapIsValid(File repositoryMap) throws MojoExecutio
331322
validator.validate(xmlFile);
332323
LOG.info(" " + xmlFile.getSystemId() + " is valid");
333324
LOG.info(" ");
334-
} catch (SAXException saxe) {
335-
throw new MojoExecutionException(repositoryMap.getName() + " is not valid: " + saxe.getLocalizedMessage());
336-
} catch (IOException ioe) {
337-
//Assume it doesn't exist, set to null so that we default to packaged version
338-
this.customRepositoryMap = null;
325+
} catch (SAXException | IOException ex) {
326+
throw new MojoExecutionException(repositoryMap.getName() + " is not valid: " + ex.getLocalizedMessage());
339327
}
340328
}
341-
342329
}

0 commit comments

Comments
 (0)