List of usage examples for java.io File pathSeparator
String pathSeparator
To view the source code for java.io File pathSeparator.
Click Source Link
From source file:org.eclipse.emf.teneo.util.StoreUtil.java
/** Build list of possible or descriptor file paths */ private static String[] buildPackagelist() { // walk through all the classnames final ArrayList<String> newPackagePathList = new ArrayList<String>(); newPackagePathList.add(File.pathSeparator); // add the root package // TODO: move this to the EModelResolver! for (Class<?> clazz : EModelResolver.instance().getAllClassesAndInterfaces()) { final String className = clazz.getName(); final int classNameIndex = className.lastIndexOf(PACKAGE_SEPARATOR); final String trunkClassName = className.substring(0, classNameIndex); final String startPath = PATH_SEPARATOR + trunkClassName.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR); buildPackagePathFromClassName(startPath, newPackagePathList); }/*from www . ja va 2 s. co m*/ return newPackagePathList.toArray(new String[newPackagePathList.size()]); }
From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java
protected List<File> parseExtClasspath(AFCliRequest cliRequest) { String extClassPath = cliRequest.getUserProperties().getProperty(EXT_CLASS_PATH); if (extClassPath == null) { extClassPath = cliRequest.getSystemProperties().getProperty(EXT_CLASS_PATH); }/*from w w w .j a v a2 s. c o m*/ List<File> jars = new ArrayList<File>(); if (StringUtils.isNotEmpty(extClassPath)) { for (String jar : StringUtils.split(extClassPath, File.pathSeparator)) { File file = resolveFile(new File(jar), cliRequest.getWorkingDirectory()); slf4jLogger.debug(" Included " + file); jars.add(file); } } return jars; }
From source file:org.apache.jmeter.JMeter.java
private void updateClassLoader() { updatePath("search_paths", ";", true); //$NON-NLS-1$//$NON-NLS-2$ updatePath("user.classpath", File.pathSeparator, true);//$NON-NLS-1$ updatePath("plugin_dependency_paths", ";", false);//$NON-NLS-1$ }
From source file:org.apache.geode.management.internal.cli.commands.GfshCommandJUnitTest.java
private String toClasspath(final String... jarFilePathnames) { String classpath = org.apache.commons.lang.StringUtils.EMPTY; if (jarFilePathnames != null) { for (final String jarFilePathname : jarFilePathnames) { classpath += (classpath.isEmpty() ? org.apache.commons.lang.StringUtils.EMPTY : File.pathSeparator); classpath += jarFilePathname; }//from w ww . j a v a 2s . c o m } return classpath; }
From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
private void saveRecentPatchFileList() { StringBuilder sb = new StringBuilder(128); if (recentPatchFileList != null) { int k = recentPatchFileList.listModel.getSize() - 1; for (int index = 0; index <= k; index++) { File file = recentPatchFileList.listModel.getElementAt(k - index); if (sb.length() > 0) { sb.append(File.pathSeparator); }//from w w w .java 2 s.com String fp = file.getPath(); System.out.println(fp + " Path Length = " + fp.length()); sb.append(file.getPath()); System.out.println("RUFL Length = " + sb.length()); } Preferences p = Preferences.userNodeForPackage(RecentFileList.class); p.put("RecentPatchFileList.fileList", sb.toString()); } }
From source file:com.redhat.ceylon.compiler.java.test.cmr.CMRTests.java
private void compileJavaModule(File jarOutputFolder, File classesOutputFolder, String moduleName, String moduleVersion, File sourceFolder, File[] extraClassPath, String... sourceFileNames) throws IOException { JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler(); assertNotNull("Missing Java compiler, this test is probably being run with a JRE instead of a JDK!", javaCompiler);/* ww w . j av a 2s .c om*/ StandardJavaFileManager fileManager = javaCompiler.getStandardFileManager(null, null, null); Set<String> sourceDirectories = new HashSet<String>(); File[] javaSourceFiles = new File[sourceFileNames.length]; for (int i = 0; i < javaSourceFiles.length; i++) { javaSourceFiles[i] = new File(sourceFolder, sourceFileNames[i]); String sfn = sourceFileNames[i].replace(File.separatorChar, '/'); int p = sfn.lastIndexOf('/'); String sourceDir = sfn.substring(0, p); sourceDirectories.add(sourceDir); } Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjects(javaSourceFiles); StringBuilder cp = new StringBuilder(); for (int i = 0; i < extraClassPath.length; i++) { if (i > 0) cp.append(File.pathSeparator); cp.append(extraClassPath[i]); } CompilationTask task = javaCompiler.getTask(null, null, null, Arrays.asList("-d", classesOutputFolder.getPath(), "-cp", cp.toString(), "-sourcepath", sourceFolder.getPath()), null, compilationUnits); assertEquals(Boolean.TRUE, task.call()); File jarFolder = new File(jarOutputFolder, moduleName.replace('.', File.separatorChar) + File.separatorChar + moduleVersion); jarFolder.mkdirs(); File jarFile = new File(jarFolder, moduleName + "-" + moduleVersion + ".jar"); // now jar it up JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(jarFile)); for (String sourceFileName : sourceFileNames) { String classFileName = sourceFileName.substring(0, sourceFileName.length() - 5) + ".class"; ZipEntry entry = new ZipEntry(classFileName); outputStream.putNextEntry(entry); File classFile = new File(classesOutputFolder, classFileName); FileInputStream inputStream = new FileInputStream(classFile); Util.copy(inputStream, outputStream); inputStream.close(); outputStream.flush(); } outputStream.close(); for (String sourceDir : sourceDirectories) { File module = null; String sourceName = "module.properties"; File properties = new File(sourceFolder, sourceDir + File.separator + sourceName); if (properties.exists()) { module = properties; } else { sourceName = "module.xml"; properties = new File(sourceFolder, sourceDir + File.separator + sourceName); if (properties.exists()) { module = properties; } } if (module != null) { File moduleFile = new File(sourceFolder, sourceDir + File.separator + sourceName); FileInputStream inputStream = new FileInputStream(moduleFile); FileOutputStream moduleOutputStream = new FileOutputStream(new File(jarFolder, sourceName)); Util.copy(inputStream, moduleOutputStream); inputStream.close(); moduleOutputStream.flush(); moduleOutputStream.close(); } } }
From source file:org.apache.hadoop.mapred.TestYARNRunner.java
private void testAMStandardEnv(boolean customLibPath) throws Exception { // the Windows behavior is different and this test currently doesn't really // apply//from ww w . j av a2s .c o m // MAPREDUCE-6588 should revisit this test if (Shell.WINDOWS) { return; } final String ADMIN_LIB_PATH = "foo"; final String USER_LIB_PATH = "bar"; final String USER_SHELL = "shell"; JobConf jobConf = new JobConf(); String pathKey = Environment.LD_LIBRARY_PATH.name(); if (customLibPath) { jobConf.set(MRJobConfig.MR_AM_ADMIN_USER_ENV, pathKey + "=" + ADMIN_LIB_PATH); jobConf.set(MRJobConfig.MR_AM_ENV, pathKey + "=" + USER_LIB_PATH); } jobConf.set(MRJobConfig.MAPRED_ADMIN_USER_SHELL, USER_SHELL); YARNRunner yarnRunner = new YARNRunner(jobConf); ApplicationSubmissionContext appSubCtx = buildSubmitContext(yarnRunner, jobConf); // make sure PWD is first in the lib path ContainerLaunchContext clc = appSubCtx.getAMContainerSpec(); Map<String, String> env = clc.getEnvironment(); String libPath = env.get(pathKey); assertNotNull(pathKey + " not set", libPath); String cps = jobConf.getBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM, MRConfig.DEFAULT_MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM) ? ApplicationConstants.CLASS_PATH_SEPARATOR : File.pathSeparator; String expectedLibPath = MRApps.crossPlatformifyMREnv(conf, Environment.PWD); if (customLibPath) { // append admin libpath and user libpath expectedLibPath += cps + ADMIN_LIB_PATH + cps + USER_LIB_PATH; } else { expectedLibPath += cps + MRJobConfig.DEFAULT_MR_AM_ADMIN_USER_ENV.substring(pathKey.length() + 1); } assertEquals("Bad AM " + pathKey + " setting", expectedLibPath, libPath); // make sure SHELL is set String shell = env.get(Environment.SHELL.name()); assertNotNull("SHELL not set", shell); assertEquals("Bad SHELL setting", USER_SHELL, shell); }
From source file:com.agilejava.docbkx.maven.AbstractTransformerMojo.java
/** * Configures and executes the given ant tasks, mainly preprocess and postprocess defined in the pom configuration. * * @param antTasks The tasks to execute//from ww w.ja va 2s . c om * @param mavenProject The current maven project * @throws MojoExecutionException If something wrong occurs while executing the ant tasks. */ protected void executeTasks(Target antTasks, MavenProject mavenProject) throws MojoExecutionException { try { ExpressionEvaluator exprEvaluator = (ExpressionEvaluator) antTasks.getProject() .getReference("maven.expressionEvaluator"); Project antProject = antTasks.getProject(); PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(antProject); propertyHelper.setNext(new AntPropertyHelper(exprEvaluator, getLog())); DefaultLogger antLogger = new DefaultLogger(); antLogger.setOutputPrintStream(System.out); antLogger.setErrorPrintStream(System.err); antLogger.setMessageOutputLevel(2); antProject.addBuildListener(antLogger); antProject.setBaseDir(mavenProject.getBasedir()); Path p = new Path(antProject); p.setPath(StringUtils.join(mavenProject.getArtifacts().iterator(), File.pathSeparator)); antProject.addReference("maven.dependency.classpath", p); p = new Path(antProject); p.setPath(StringUtils.join(mavenProject.getCompileClasspathElements().iterator(), File.pathSeparator)); antProject.addReference("maven.compile.classpath", p); p = new Path(antProject); p.setPath(StringUtils.join(mavenProject.getRuntimeClasspathElements().iterator(), File.pathSeparator)); antProject.addReference("maven.runtime.classpath", p); p = new Path(antProject); p.setPath(StringUtils.join(mavenProject.getTestClasspathElements().iterator(), File.pathSeparator)); antProject.addReference("maven.test.classpath", p); List artifacts = getArtifacts(); List list = new ArrayList(artifacts.size()); File file; for (Iterator i = artifacts.iterator(); i.hasNext(); list.add(file.getPath())) { Artifact a = (Artifact) i.next(); file = a.getFile(); if (file == null) throw new DependencyResolutionRequiredException(a); } p = new Path(antProject); p.setPath(StringUtils.join(list.iterator(), File.pathSeparator)); antProject.addReference("maven.plugin.classpath", p); getLog().info("Executing tasks"); antTasks.execute(); getLog().info("Executed tasks"); } catch (Exception e) { throw new MojoExecutionException("Error executing ant tasks", e); } }
From source file:org.apache.hadoop.mapreduce.v2.util.MRApps.java
public static void setEnvFromInputString(Map<String, String> env, String envString, Configuration conf) { String classPathSeparator = conf.getBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM, MRConfig.DEFAULT_MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM) ? ApplicationConstants.CLASS_PATH_SEPARATOR : File.pathSeparator; Apps.setEnvFromInputString(env, envString, classPathSeparator); }
From source file:com.qspin.qtaste.testsuite.impl.JythonTestScript.java
public static List<String> getAdditionalPythonPath(File file) { List<String> pythonlibs = new ArrayList<>(); //add librairies references by the environment variable for (String additionnalPath : StaticConfiguration.JYTHON_LIB.split(File.pathSeparator)) { File directory = new File(additionnalPath); pythonlibs.add(directory.toString()); }/* w w w. ja v a 2 s.co m*/ if (!file.getAbsolutePath().contains("TestSuites")) { return pythonlibs; } try { File directory = file.getAbsoluteFile().getCanonicalFile(); while (!directory.getName().equals("TestSuites")) { //File testSuitesDirectory = new File("TestSuites").getAbsoluteFile().getCanonicalFile(); //do { directory = directory.getParentFile(); pythonlibs.add(directory + File.separator + "pythonlib"); } //while (!directory.equals(testSuitesDirectory)); } catch (IOException e) { logger.error("Error while getting pythonlib directories: " + e.getMessage()); } return pythonlibs; }