Skip to content

Instantly share code, notes, and snippets.

@cescoffier
Created June 17, 2014 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cescoffier/48b3a48ab1a14c196289 to your computer and use it in GitHub Desktop.
Save cescoffier/48b3a48ab1a14c196289 to your computer and use it in GitHub Desktop.
Check that firefox is accessible
<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