Example usage for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX

List of usage examples for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX.

Prototype

boolean IS_OS_MAC_OSX

To view the source code for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX.

Click Source Link

Document

Is true if this is Mac.

The field will return false if OS_NAME is null.

Usage

From source file:org.codehaus.mojo.keytool.KeyToolUtil.java

/**
 * Constructs the operating system specific File path of the JRE cacerts file.
 *
 * @return a File representing the path to the command.
 *///from  w w  w .  j  ava 2  s  . c  o m
public static File getJRECACerts() {

    File cacertsFile;

    String cacertsFilepath = "lib" + File.separator + "security" + File.separator + "cacerts";

    // For IBM's JDK 1.2
    if (SystemUtils.IS_OS_AIX) {
        cacertsFile = new File(SystemUtils.getJavaHome() + "/", cacertsFilepath);
    } else if (SystemUtils.IS_OS_MAC_OSX) // what about IS_OS_MAC_OS ??
    {
        cacertsFile = new File(SystemUtils.getJavaHome() + "/", cacertsFilepath);
    } else {
        cacertsFile = new File(SystemUtils.getJavaHome() + "/", cacertsFilepath);
    }

    return cacertsFile;
}

From source file:org.ebayopensource.turmeric.tools.errorlibrary.ErrorLibraryGeneratorTest.java

private void addToClasspath(File source, File dest) throws Exception {
    String javaHomeStr = System.getProperty("java.home");
    File jreHome = new File(javaHomeStr);
    File toolsJar = new File(jreHome.getParent(), "lib/tools.jar");
    if (SystemUtils.IS_OS_MAC_OSX) {
        toolsJar = new File(jreHome.getParent(), "Classes/classes.jar");
    }//w  w  w  .  jav a2 s .c om
    if (!toolsJar.exists()) {
        if (javaHomeStr.indexOf("jre") > 0 || javaHomeStr.indexOf("JRE") > 0) {
            if (javaHomeStr.endsWith("/")) {
                javaHomeStr = javaHomeStr + "../";
            } else {
                javaHomeStr = javaHomeStr + "/../";
            }
            jreHome = new File(javaHomeStr);
            toolsJar = new File(jreHome.getParent(), "lib/tools.jar");
        }

    }

    URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
    Class<?> sysclass = URLClassLoader.class;
    Class<?>[] parameters = { URL.class };
    URL u = toolsJar.toURI().toURL();
    Method method = sysclass.getDeclaredMethod("addURL", parameters);
    method.setAccessible(true);
    method.invoke(sysloader, new Object[] { u });
    method.invoke(sysloader, new Object[] { source.toURI().toURL() });
    method.invoke(sysloader, new Object[] { dest.toURI().toURL() });
}

From source file:org.eclipse.ice.developer.actions.LaunchNewICEHandler.java

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    // Get the Launch Manager
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

    if (manager != null) {
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        IProject productProject = root.getProject("org.eclipse.ice.product");

        if (productProject != null) {

            // Local Declarations
            ArrayList<String> currentPlugins = new ArrayList<String>();
            ArrayList<String> notIncludedProjects = new ArrayList<String>();
            String fileName = "", currentPluginsStr = "", key = "selected_workspace_plugins";
            String vmArgs = "", vmArgsKey = "org.eclipse.jdt.launching.VM_ARGUMENTS";
            String[] plugins;/*w  ww.  j  a  va 2s  .  c  om*/

            // Get the proper file name
            if (SystemUtils.IS_OS_WINDOWS) {
                fileName = "ice.product_WINDOWS.launch";
            } else if (SystemUtils.IS_OS_MAC_OSX) {
                fileName = "ice.macosx_product.launch";
            } else if (SystemUtils.IS_OS_LINUX) {
                fileName = "ice.product_linux.launch";
            } else {
                throw new ExecutionException("Could not get the current OS. Cannot launch new version of ICE.");
            }

            // Get the Launch Configurations files
            IFile launchICE = productProject.getFile("modified_" + fileName);
            if (!launchICE.exists()) {
                IFile tempCopy = productProject.getFile(fileName);
                try {
                    launchICE.create(tempCopy.getContents(), true, null);
                } catch (CoreException e1) {
                    e1.printStackTrace();
                    logger.error("Could not create file withe name modified_" + fileName, e1);
                }
            }

            // Get the Launch Configuration from those files
            ILaunchConfiguration launchConfig = manager.getLaunchConfiguration(launchICE);
            try {
                currentPluginsStr = launchConfig.getAttribute(key, "");
                vmArgs = launchConfig.getAttribute(vmArgsKey, "");
                vmArgs = vmArgs.replace("org.eclipse.equinox.http.jetty.http.port=8081",
                        "org.eclipse.equinox.http.jetty.http.port=8082");

                // Put all workspace plugins in the launch config into a
                // list
                plugins = currentPluginsStr.split(",");
                for (String s : plugins) {
                    currentPlugins.add(s.split("@")[0]);
                }

                // Get any project name that is not currently in the run
                // config
                List<String> pluginsToIgnore = Arrays.asList("org.eclipse.ice.aggregator", "reflectivity",
                        "xsede", "ICEDocCleaner", "all", "default", "developerMenu", "dynamicUI", "fileFormats",
                        "installation", "introToPTP", "itemDB", "moose-tutorial", "newItemGeneration",
                        "org.eclipse.ice.examples.reflectivity", "org.eclipse.ice.installer",
                        "org.eclipse.ice.parent", "org.eclipse.ice.product", "org.eclipse.ice.repository");
                for (IProject p : root.getProjects()) {
                    String name = p.getName();
                    if (!currentPlugins.contains(p.getName()) && !name.endsWith(".test")
                            && !name.contains("Tutorial") && !name.contains("target.")
                            && !name.contains("feature") && !pluginsToIgnore.contains(name)) {
                        notIncludedProjects.add(p.getName());
                    }
                }

                // Display a list selection for the user to select which
                // plugins to add.
                ListSelectionDialog dialog = new ListSelectionDialog(
                        PlatformUI.getWorkbench().getDisplay().getActiveShell(), notIncludedProjects.toArray(),
                        ArrayContentProvider.getInstance(), new LabelProvider(),
                        "Select new plugins to include in the new ICE instance.");
                dialog.setTitle("Plugin Addition Selection");

                // Open the dialog
                int ok = dialog.open();

                if (ok == Window.OK) {
                    // Get the results
                    Object[] results = dialog.getResult();
                    for (Object s : results) {
                        currentPluginsStr = s.toString() + "@default:true," + currentPluginsStr;
                    }

                    ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();

                    // Set the launch configs list of plugins
                    wc.setAttribute(key, currentPluginsStr);
                    wc.setAttribute(vmArgsKey, vmArgs);

                    // Save the configuration
                    ILaunchConfiguration config = wc.doSave();

                    // Create and launch the Job.
                    Job job = new WorkspaceJob("Launching New Instance of ICE") {

                        @Override
                        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                            config.launch(ILaunchManager.RUN_MODE, monitor);
                            return Status.OK_STATUS;
                        }

                    };

                    // Launch the job
                    job.schedule();
                }
            } catch (CoreException e) {
                e.printStackTrace();
                logger.error("Could not create or launch new run configuration.", e);
            }

        }

    }

    return null;
}

From source file:org.eclipse.smarthome.core.service.AbstractWatchServiceTest.java

@BeforeClass
public static void setUpBeforeClass() {
    // set the NO_EVENT_TIMEOUT_IN_SECONDS according to the operating system used
    if (SystemUtils.IS_OS_MAC_OSX) {
        NO_EVENT_TIMEOUT_IN_SECONDS = 15;
    } else {// w w w  .  j  a  va 2s  .  co m
        NO_EVENT_TIMEOUT_IN_SECONDS = 3;
    }
}

From source file:org.esa.s2tbx.dataio.rapideye.metadata.RapidEyeMetadataTest.java

@Test
public void testGetPath() throws Exception {
    String root = System.getProperty(TestUtil.PROPERTYNAME_DATA_DIR);
    String partialPath = root + File.separator + productsFolder
            + "2009-04-16T104920_RE4_1B-NAC_3436599_84303_metadata.xml";
    if (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        partialPath = partialPath.replaceAll("\\\\", "/");
    }//  w ww. j  a  v  a  2 s.c o m

    assertEquals(partialPath, metadata.getPath());
}

From source file:org.esa.s2tbx.dataio.spot.dimap.SpotViewMetadataTest.java

@Test
public void testGetPath() throws Exception {
    String root = System.getProperty(TestUtil.PROPERTYNAME_DATA_DIR);
    String partialPath = root + File.separator + productsFolder
            + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL\\metadata.xml";
    if (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        partialPath = partialPath.replaceAll("\\\\", "/");
    }//from  w  ww.  ja  va  2s .  c  om

    assertEquals(partialPath, metadata.getPath());
}

From source file:org.esa.snap.utils.TestUtil.java

private static File getTestFileOrDirectory(String file) {
    String partialPath = file;//from   w  ww  .j  a va 2 s  . c  o m
    if (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        partialPath = file.replaceAll("\\\\", "/");
    }

    String path = System.getProperty(PROPERTYNAME_DATA_DIR);
    return new File(path, partialPath);
}

From source file:org.jajuk.util.TestUtilSystem.java

/**
 * Test method for {@link org.jajuk.util.UtilSystem#isUnderOSX()}.
 */
public void testIsUnderOSX() {
    assertEquals(SystemUtils.IS_OS_MAC_OSX, UtilSystem.isUnderOSX());
}

From source file:org.jboss.pressgang.ccms.contentspec.client.commands.EditCommand.java

protected String getCommand(final String file) {
    if (getClientConfig().getEditorRequiresTerminal()) {
        if (SystemUtils.IS_OS_WINDOWS) {
            return "start \"\" \"" + getClientConfig().getEditorCommand() + "\" \"" + file + "\"";
        } else if (SystemUtils.IS_OS_LINUX) {
            return ClientUtilities.getLinuxTerminalCommand().replace("<COMMAND>",
                    getClientConfig().getEditorCommand() + " " + file);
        } else if (SystemUtils.IS_OS_MAC_OSX) {
            return "osascript -e 'tell app \"Terminal\" to do script \"" + getClientConfig().getEditorCommand()
                    + " " + file + "; exit\"'";
        } else {/*from  w  ww .ja v a  2 s  .  c o m*/
            printErrorAndShutdown(Constants.EXIT_FAILURE, "ERROR_UNABLE_TO_OPEN_EDITOR_IN_TERMINAL_MSG", false);
            return null;
        }
    } else {
        return getClientConfig().getEditorCommand() + " \"" + file + "\"";
    }
}

From source file:org.kitodo.selenium.testframework.helper.WebDriverProvider.java

/**
 * Downloads Geckodriver, extracts archive file and set system property
 * "webdriver.gecko.driver". On Linux the method also sets executable
 * permission./*from ww  w . j a  v  a 2s. c o  m*/
 *
 * @param geckoDriverVersion
 *            The geckodriver version.
 * @param downloadFolder
 *            The folder in which the downloaded files will be put in.
 * @param extractFolder
 *            The folder in which the extracted files will be put in.
 */
public static void provideGeckoDriver(String geckoDriverVersion, String downloadFolder, String extractFolder)
        throws IOException {
    String geckoDriverUrl = "https://github.com/mozilla/geckodriver/releases/download/v" + geckoDriverVersion
            + "/";
    String geckoDriverFileName;
    if (SystemUtils.IS_OS_WINDOWS) {
        geckoDriverFileName = "geckodriver.exe";
        File geckoDriverZipFile = new File(downloadFolder + "geckodriver.zip");
        FileUtils.copyURLToFile(new URL(geckoDriverUrl + "geckodriver-v" + geckoDriverVersion + "-win64.zip"),
                geckoDriverZipFile);
        extractZipFileToFolder(geckoDriverZipFile, new File(extractFolder));
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        geckoDriverFileName = "geckodriver";
        File geckoDriverTarFile = new File(downloadFolder + "geckodriver.tar.gz");
        FileUtils.copyURLToFile(
                new URL(geckoDriverUrl + "geckodriver-v" + geckoDriverVersion + "-macos.tar.gz"),
                geckoDriverTarFile);
        File theDir = new File(extractFolder);
        if (!theDir.exists()) {
            theDir.mkdir();
        }
        extractTarFileToFolder(geckoDriverTarFile, theDir);
    } else {
        geckoDriverFileName = "geckodriver";
        File geckoDriverTarFile = new File(downloadFolder + "geckodriver.tar.gz");
        FileUtils.copyURLToFile(
                new URL(geckoDriverUrl + "geckodriver-v" + geckoDriverVersion + "-linux64.tar.gz"),
                geckoDriverTarFile);
        extractTarFileToFolder(geckoDriverTarFile, new File(extractFolder));
    }
    File geckoDriverFile = new File(extractFolder, geckoDriverFileName);

    if (geckoDriverFile.exists()) {
        if (!SystemUtils.IS_OS_WINDOWS) {
            ExecutionPermission.setExecutePermission(geckoDriverFile);
        }

        if (geckoDriverFile.canExecute()) {
            System.setProperty("webdriver.gecko.driver", geckoDriverFile.getPath());
        } else {
            logger.error("Geckodriver not executeable");
        }
    } else {
        logger.error("Geckodriver file not found");
    }
}