List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:org.jboss.windup.decorator.java.decompiler.BackupOfJadretroDecompilerAdapter.java
public BackupOfJadretroDecompilerAdapter() { LogController.LoggingAdapter.tieSystemOutAndErrToLog(); if (SystemUtils.IS_OS_WINDOWS) { APP_NAME = "jad.exe"; } else {//from w w w . ja v a 2 s . c o m APP_NAME = "jad"; } }
From source file:org.jboss.windup.decorator.java.decompiler.JadretroDecompilerAdapter.java
public JadretroDecompilerAdapter() { LogController.LoggingAdapter.tieSystemOutAndErrToLog(); if (SystemUtils.IS_OS_WINDOWS) { APP_NAME = "jad.exe"; } else {/*from w ww . java 2s . com*/ APP_NAME = "jad"; } }
From source file:org.jenkinsci.plugins.DependencyCheck.DependencyCheckBuilder.java
/** * Generate Options from build configuration preferences that will be passed to * the build step in DependencyCheck//from www .ja v a 2 s. c o m * @param build an AbstractBuild object * @return DependencyCheck Options */ private Options generateOptions(AbstractBuild build, BuildListener listener, boolean isMaster, ClassLoader classLoader) { Options options = new Options(); // Sets the DependencyCheck application name to the Jenkins display name. If a display name // was not defined, it will simply return the name of the build. options.setName(build.getProject().getDisplayName()); // If the configured output directory is empty, set this builds output dir to the root of the projects workspace FilePath outDirPath; if (StringUtils.isBlank(outdir)) { outDirPath = build.getWorkspace(); } else { outDirPath = new FilePath(build.getWorkspace(), substituteVariable(build, listener, outdir.trim())); } options.setOutputDirectory(new File(outDirPath.getRemote())); if (StringUtils.isNotBlank(suppressionFile)) { try { // Try to set the suppression file as a URL options.setSuppressionFile(new URL(suppressionFile.trim())); } catch (MalformedURLException e) { // If the format is not a valid URL, set it as a FilePath type options.setSuppressionFile(new File(new FilePath(build.getWorkspace(), substituteVariable(build, listener, suppressionFile.trim())).getRemote())); } } if (StringUtils.isNotBlank(zipExtensions)) { options.setZipExtensions(toCommaSeparatedString(zipExtensions)); } configureDataDirectory(build, listener, options); FilePath log = new FilePath(build.getWorkspace(), "dependency-check.log"); //FilePath logLock = new FilePath(build.getWorkspace(), "dependency-check.log.lck"); //deleteFilePath(log); // Uncomment to clear out the logs between builds //deleteFilePath(logLock); if (isVerboseLoggingEnabled) { options.setVerboseLoggingFile(new File(log.getRemote())); } options.setDataMirroringType(this.getDescriptor().dataMirroringType); if (options.getDataMirroringType() != 0) { String cveUrl12Modified = this.getDescriptor().cveUrl12Modified; String cveUrl20Modified = this.getDescriptor().cveUrl20Modified; String cveUrl12Base = this.getDescriptor().cveUrl12Base; String cveUrl20Base = this.getDescriptor().cveUrl20Base; if (!StringUtils.isBlank(cveUrl12Modified) && !StringUtils.isBlank(cveUrl20Modified) && !StringUtils.isBlank(cveUrl12Base) && !StringUtils.isBlank(cveUrl20Base)) { try { options.setCveUrl12Modified(new URL(cveUrl12Modified)); options.setCveUrl20Modified(new URL(cveUrl20Modified)); options.setCveUrl12Base(new URL(cveUrl12Base)); options.setCveUrl20Base(new URL(cveUrl20Base)); } catch (MalformedURLException e) { // todo: need to log this or otherwise warn. } } } // Proxy settings ProxyConfiguration proxy = Jenkins.getInstance() != null ? Jenkins.getInstance().proxy : null; if (proxy != null) { if (!StringUtils.isBlank(proxy.name)) { options.setProxyServer(proxy.name); options.setProxyPort(proxy.port); } if (!StringUtils.isBlank(proxy.getUserName())) { options.setProxyUsername(proxy.getUserName()); } if (!StringUtils.isBlank(proxy.getPassword())) { options.setProxyPassword(proxy.getPassword()); } } // If specified to use Maven artifacts as the scan path - get them and populate the options if (useMavenArtifactsScanPath && build.getProject() instanceof AbstractMavenProject) { options.setUseMavenArtifactsScanPath(true); final ArrayList<File> artifacts = determineMavenArtifacts(build, listener); options.setScanPath(artifacts); } else { options.setUseMavenArtifactsScanPath(false); // Support for multiple scan paths in a single analysis for (String tmpscanpath : scanpath.split(",")) { FilePath filePath = new FilePath(build.getWorkspace(), substituteVariable(build, listener, tmpscanpath.trim())); options.addScanPath(new File(filePath.getRemote())); } } options.setWorkspace(build.getWorkspace().getRemote()); // Enable/Disable Analyzers options.setJarAnalyzerEnabled(this.getDescriptor().isJarAnalyzerEnabled); options.setJavascriptAnalyzerEnabled(this.getDescriptor().isJavascriptAnalyzerEnabled); options.setArchiveAnalyzerEnabled(this.getDescriptor().isArchiveAnalyzerEnabled); options.setAssemblyAnalyzerEnabled(this.getDescriptor().isAssemblyAnalyzerEnabled); options.setNuspecAnalyzerEnabled(this.getDescriptor().isNuspecAnalyzerEnabled); options.setNexusAnalyzerEnabled(this.getDescriptor().isNexusAnalyzerEnabled); // Nexus options if (this.getDescriptor().isNexusAnalyzerEnabled && StringUtils.isNotBlank(this.getDescriptor().nexusUrl)) { try { options.setNexusUrl(new URL(this.getDescriptor().nexusUrl)); } catch (MalformedURLException e) { // todo: need to log this or otherwise warn. } options.setNexusProxyBypassed(this.getDescriptor().isNexusProxyBypassed); } // Maven Central options options.setCentralAnalyzerEnabled(this.getDescriptor().isCentralAnalyzerEnabled); try { options.setCentralUrl(new URL("http://search.maven.org/solrsearch/select")); } catch (MalformedURLException e) { // todo: need to log this or otherwise warn. } // Only set the Mono path if running on non-Windows systems. if (!SystemUtils.IS_OS_WINDOWS && StringUtils.isNotBlank(this.getDescriptor().monoPath)) { options.setMonoPath(new File(this.getDescriptor().monoPath)); } // If temp path has been specified, use it, otherwise Dependency-Check will default to the Java temp path if (StringUtils.isNotBlank(this.getDescriptor().tempPath)) { options.setTempPath(new File(substituteVariable(build, listener, this.getDescriptor().tempPath))); } options.setAutoUpdate(!isAutoupdateDisabled); if (includeHtmlReports) { options.setFormat(ReportGenerator.Format.ALL); } return options; }
From source file:org.jenkinsci.plugins.fortifycloudscan.util.CommandUtil.java
public static String generateShellCommand(String[] command) { String shellCommand;//from w ww . j a v a2s . c o m if (SystemUtils.IS_OS_WINDOWS) { shellCommand = "cmd /c " + CommandUtil.toString(command); } else { shellCommand = "sh -c '" + CommandUtil.toString(command) + "'"; } return shellCommand; }
From source file:org.jenkinsci.plugins.neoload.integration.NeoBuildAction.java
/** * Gets contents.//from w w w . j ava 2 s. c o m * * @return the contents */ @Override protected String getContents() { if (SystemUtils.IS_OS_WINDOWS) { new BatchFileMine().getContents(); } return new ShellMine().getContents(); }
From source file:org.jenkinsci.plugins.neoload.integration.NeoBuildAction.java
/** * Gets file extension./*w ww . j a v a 2s. c o m*/ * * @return the file extension */ @Override protected String getFileExtension() { if (SystemUtils.IS_OS_WINDOWS) { new BatchFileMine().getFileExtension(); } return new ShellMine().getFileExtension(); }
From source file:org.jenkinsci.plugins.pipeline.modeldefinition.AbstractModelDefTest.java
protected void onAllowedOS(PossibleOS... osList) throws Exception { boolean passed = true; for (PossibleOS os : osList) { switch (os) { case LINUX: if (!SystemUtils.IS_OS_LINUX) { passed = false;//from ww w . ja v a 2s .c o m } break; case WINDOWS: if (!SystemUtils.IS_OS_WINDOWS) { passed = false; } break; case MAC: if (!SystemUtils.IS_OS_MAC) { passed = false; } break; default: break; } } Assume.assumeTrue("Not on a valid OS for this test", passed); }
From source file:org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StatusAndTimingTest.java
@Test public void busyStepTest() throws Exception { WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "InputJob"); String sleep = "sh 'sleep 10000'\n"; if (SystemUtils.IS_OS_WINDOWS) { sleep = "bat 'timeout /t 30'\n"; }//from w ww. ja v a 2 s . co m job.setDefinition(new CpsFlowDefinition("node {\n" + " stage(\"parallelStage\"){\n" + " parallel left : {\n" + " echo \"running\"\n" + " input message: 'Please input branch to test against' \n" + " }, \n" + " right : {\n" + sleep + //13 " }\n" + " }\n" + "}")); QueueTaskFuture<WorkflowRun> buildTask = job.scheduleBuild2(0); WorkflowRun run = buildTask.getStartCondition().get(); CpsFlowExecution e = (CpsFlowExecution) run.getExecutionPromise().get(); while (run.getAction(InputAction.class) == null) { e.waitForSuspension(); } e = (CpsFlowExecution) (run.getExecution()); GenericStatus status = StatusAndTiming.computeChunkStatus(run, null, e.getNode("13"), e.getNode("13"), null); Assert.assertEquals(GenericStatus.IN_PROGRESS, status); status = StatusAndTiming.computeChunkStatus(run, null, e.getNode("12"), e.getNode("12"), null); Assert.assertEquals(GenericStatus.PAUSED_PENDING_INPUT, status); }
From source file:org.jiemamy.eclipse.core.ui.editor.action.ExportAction.java
@Override public void run() { logger.debug(LogMarker.LIFECYCLE, "run " + exporter.getName()); JiemamyContext context = (JiemamyContext) getViewer().getContents().getModel(); IFileEditorInput input = (IFileEditorInput) editor.getEditorInput(); wizard.setInput(input);/*from ww w.j a v a 2 s . com*/ IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection(); List<Object> selectedModels = Lists.newArrayList(); for (Object selectedObject : selection.toList()) { if (selectedObject instanceof EditPart) { EditPart editPart = (EditPart) selectedObject; selectedModels.add(editPart.getModel()); } } Shell shell = getViewer().getControl().getShell(); try { // ? WizardDialog dialog = new WizardDialog(shell, wizard); if (dialog.open() != Window.OK) { logger.debug(LogMarker.LIFECYCLE, "canceled " + exporter.getName()); return; } ExportConfig config = wizard.getConfig(); // boolean success = exporter.exportModel(context, config); if (success) { if (SystemUtils.IS_OS_WINDOWS && config instanceof FileExportConfig) { FileExportConfig fileExportConfig = (FileExportConfig) config; boolean result = MessageDialog.openQuestion(null, "Success", "???????????"); // RESOURCE if (result) { try { Runtime.getRuntime() .exec("cmd /c \"" + fileExportConfig.getOutputFile().getAbsolutePath() + "\""); } catch (IOException e) { MessageDialog.openError(shell, "Failed", "???????"); // RESOURCE } } } else { MessageDialog.openInformation(shell, "export succeeded", "???????"); // RESOURCE } } else { MessageDialog.openWarning(shell, "export aborted", "????????"); // RESOURCE } } catch (ExportException e) { MessageDialog.openError(shell, "export error", e.getMessage()); } finally { // try { ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException e) { ExceptionHandler.handleException(e); } } }
From source file:org.jiemamy.eclipse.core.ui.editor.diagram.dataset.DataSetEditDialog.java
private void exportToCsv() { FileDialog dialog = new FileDialog(btnExport.getShell(), SWT.SAVE); dialog.setText(Messages.DataSetEditDialog_export_title); dialog.setFileName(filename);//from w ww . j ava 2s .co m filename = dialog.open(); if (filename == null) { return; } File csv = new File(filename); if (csv.exists()) { boolean result = MessageDialog.openQuestion(getShell(), Messages.DataSetEditDialog_export_title, NLS.bind(CommonMessages.Common_fileOverwrite, csv.getPath())); if (result == false) { return; } if (csv.canWrite() == false) { MessageDialog.openError(getShell(), Messages.DataSetEditDialog_export_title, NLS.bind(CommonMessages.Common_fileWriteFailed, csv.getPath())); return; } } JmDataSet dataSet = getTargetCoreModel(); int tabIndex = tabFolder.getSelectionIndex(); if (tabIndex <= 0) { MessageDialog.openInformation(getShell(), "?", "???????????"); // RESOURCE return; } TabItem item = tabFolder.getItem(tabIndex); JmTable table = (JmTable) item.getData(); OutputStream out = null; try { out = new FileOutputStream(csv); DataSetUtil.exportToCsv(dataSet, table, out); } catch (IOException e) { ExceptionHandler.handleException(e); } finally { IOUtils.closeQuietly(out); } if (SystemUtils.IS_OS_WINDOWS) { boolean result = MessageDialog.openQuestion(getShell(), Messages.DataSetEditDialog_export_title, Messages.DataSetEditDialog_export_success_windows); if (result) { try { Runtime.getRuntime().exec("cmd /c \"" + csv.getAbsolutePath() + "\""); } catch (IOException e) { MessageDialog.openError(getShell(), Messages.DataSetEditDialog_export_title, Messages.DataSetEditDialog_export_openFailed); } } } else { MessageDialog.openInformation(getShell(), Messages.DataSetEditDialog_export_title, Messages.DataSetEditDialog_export_success); } }