Created
June 17, 2014 13:41
-
-
Save cescoffier/48b3a48ab1a14c196289 to your computer and use it in GitHub Desktop.
Check that firefox is accessible
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
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-enforcer-plugin</artifactId> | |
<version>1.3.1</version> | |
<executions> | |
<execution> | |
<id>enforce-beanshell</id> | |
<goals> | |
<goal>enforce</goal> | |
</goals> | |
<configuration> | |
<rules> | |
<evaluateBeanshell> | |
<!-- Check whether firefox is accessible --> | |
<message>Cannot find 'firefox' in your System PATH.</message> | |
<condition> | |
//MacOS X case | |
mac = new File("/Applications/Firefox.app/Contents/MacOS/firefox"); | |
if (mac.isFile()) { return true;} | |
// Linux and Windows | |
candidates = new String[] { "firefox", "firefox.exe"}; | |
systemPath = System.getenv("PATH"); | |
if (systemPath == null) { | |
return false; | |
} | |
pathDirs = systemPath.split(java.io.File.pathSeparator); | |
for (pathDir : pathDirs) { | |
for (candidate : candidates) { | |
file = new java.io.File(pathDir, candidate); | |
if (file.isFile()) { | |
return true; | |
} | |
} | |
} | |
System.out.println("Cannot find 'firefox' in your System Path"); | |
return false; | |
</condition> | |
</evaluateBeanshell> | |
</rules> | |
<fail>true</fail> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment