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.jsweet.transpiler.JSweetTranspiler.java
private void initJavac(final TranspilationHandler transpilationHandler) { context = factory.createContext(this); options = Options.instance(context); if (classPath != null) { options.put(Option.CLASSPATH, classPath); for (String s : classPath.split(File.pathSeparator)) { if (s.contains(JSweetConfig.MAVEN_JAVA_OVERRIDE_ARTIFACT)) { context.strictMode = true; options.put(Option.BOOTCLASSPATH, s); }//ww w . j a v a 2 s . co m } } if (encoding != null) { options.put(Option.ENCODING, encoding); } logger.debug("classpath: " + options.get(Option.CLASSPATH)); logger.debug("bootclasspath: " + options.get(Option.BOOTCLASSPATH)); logger.debug("strict mode: " + context.strictMode); options.put(Option.XLINT, "path"); JavacFileManager.preRegister(context); fileManager = context.get(JavaFileManager.class); compiler = JavaCompiler.instance(context); compiler.attrParseOnly = true; compiler.verbose = false; compiler.genEndPos = true; compiler.keepComments = true; log = Log.instance(context); log.dumpOnError = false; log.emitWarnings = false; log.setWriters(new PrintWriter(new StringWriter() { @Override public void write(String str) { } })); log.setDiagnosticFormatter(new BasicDiagnosticFormatter(JavacMessages.instance(context)) { @Override public String format(JCDiagnostic diagnostic, Locale locale) { if (diagnostic.getKind() == Kind.ERROR) { if (!(ignoreJavaFileNameError && "compiler.err.class.public.should.be.in.file".equals(diagnostic.getCode()))) { transpilationHandler.report(JSweetProblem.INTERNAL_JAVA_ERROR, new SourcePosition(new File(diagnostic.getSource().getName()), null, (int) diagnostic.getLineNumber(), (int) diagnostic.getColumnNumber()), diagnostic.getMessage(locale)); } } switch (diagnostic.getKind()) { case ERROR: logger.error(diagnostic); break; case WARNING: case MANDATORY_WARNING: logger.debug(diagnostic); break; case NOTE: case OTHER: default: logger.trace(diagnostic); break; } if (diagnostic.getSource() != null) { return diagnostic.getMessage(locale) + " at " + diagnostic.getSource().getName() + "(" + diagnostic.getLineNumber() + ")"; } else { return diagnostic.getMessage(locale); } } }); }
From source file:com.taobao.android.builder.tasks.app.bundle.AwbJavaCompileConfigAction.java
/** * AwbInstantRun is not supported for the moment * * @param javacTask// w w w . j a v a 2 s. c o m */ @Override public void execute(AwbAndroidJavaCompile javacTask) { appVariantOutputContext.getAwbJavacTasks().put(awbBundle.getName(), javacTask); ProcessAwbAndroidResources processAwbAndroidResources = appVariantOutputContext.getAwbAndroidResourcesMap() .get(awbBundle.getName()); assert null != processAwbAndroidResources; javacTask.source(processAwbAndroidResources.getSourceOutputDir()); if (appVariantOutputContext.getVariantContext().isDataBindEnabled(awbBundle) && awbBundle.isDataBindEnabled()) { javacTask .source(appVariantOutputContext.getVariantContext().getAwbClassOutputForDataBinding(awbBundle)); } // ConventionMappingHelper.map(javacTask, "classpath", (Callable<FileCollection>) () -> getInputJars()); FileCollection classpath = getInputJars(); javacTask.setDestinationDir(appVariantOutputContext.getJAwbavaOutputDir(awbBundle)); final boolean keepDefaultBootstrap = scope.keepDefaultBootstrap(); if (!keepDefaultBootstrap) { // Set boot classpath if we don't need to keep the default. Otherwise, this is added as // normal classpath. javacTask.getOptions().setBootClasspath(Joiner.on(File.pathSeparator) .join(scope.getGlobalScope().getAndroidBuilder().getBootClasspathAsStrings(false))); } // FileCollection classpath = scope.getJavaClasspath(COMPILE_CLASSPATH, CLASSES); if (keepDefaultBootstrap) { classpath = classpath .plus(appVariantOutputContext.getVariantContext().getProject().files(appVariantOutputContext .getScope().getGlobalScope().getAndroidBuilder().getBootClasspath(false))); } javacTask.setClasspath(classpath); appVariantOutputContext.getScope().getTransformManager() .addStream(OriginalStream .builder(appVariantOutputContext.getVariantContext().getProject(), "awb-classes") .addContentType(QualifiedContent.DefaultContentType.CLASSES) .addScope(QualifiedContent.Scope.PROJECT) .setFileCollection(appVariantOutputContext.getVariantContext().getProject() .files(appVariantOutputContext.getJAwbavaOutputDir(awbBundle))) .build()); appVariantOutputContext.getAwbTransformMap().get(awbBundle.getName()) .setInputDir(appVariantOutputContext.getJAwbavaOutputDir(awbBundle)); CompileOptions compileOptions = scope.getGlobalScope().getExtension().getCompileOptions(); AbstractCompilesUtil.configureLanguageLevel(javacTask, compileOptions, scope.getGlobalScope().getExtension().getCompileSdkVersion(), scope.getJava8LangSupportType()); javacTask.getOptions().setEncoding(compileOptions.getEncoding()); Boolean includeCompileClasspath = scope.getVariantConfiguration().getJavaCompileOptions() .getAnnotationProcessorOptions().getIncludeCompileClasspath(); FileCollection processorPath = scope.getArtifactFileCollection(ANNOTATION_PROCESSOR, ALL, JAR); if (Boolean.TRUE.equals(includeCompileClasspath)) { // We need the jar files because annotation processors require the resources. processorPath = processorPath.plus(scope.getJavaClasspath(COMPILE_CLASSPATH, JAR)); } javacTask.getOptions().setAnnotationProcessorPath(processorPath); boolean incremental = AbstractCompilesUtil.isIncremental( appVariantOutputContext.getScope().getGlobalScope().getProject(), scope, compileOptions, null, /* processorConfiguration, JavaCompile handles annotation processor now */ LOG); javacTask.getOptions().setIncremental(incremental); AnnotationProcessorOptions annotationProcessorOptions = scope.getVariantConfiguration() .getJavaCompileOptions().getAnnotationProcessorOptions(); // javacTask.getOptions().getCompilerArgs().add("-processorpath"); // javacTask.getOptions().getCompilerArgs().add(FileUtils.joinFilePaths(processorPath)); if (!annotationProcessorOptions.getClassNames().isEmpty()) { javacTask.getOptions().getCompilerArgs().add("-processor"); javacTask.getOptions().getCompilerArgs() .add(Joiner.on(',').join(annotationProcessorOptions.getClassNames())); } if (!annotationProcessorOptions.getArguments().isEmpty()) { for (Map.Entry<String, String> arg : annotationProcessorOptions.getArguments().entrySet()) { String key = arg.getKey(); String value = arg.getValue(); if ("android.databinding.modulePackage".equals(key)) { value = awbBundle.getPackageName() + "._bundleapp_"; } else if ("android.databinding.artifactType".equals(key)) { //value = "LIBRARY"; } else if ("android.databinding.xmlOutDir".equals(key)) { value = appVariantOutputContext.getVariantContext() .getAwbLayoutInfoOutputForDataBinding(awbBundle).getAbsolutePath(); } else if ("android.databinding.bindingBuildFolder".equals(key)) { value = appVariantOutputContext.getVariantContext().getAwbDataBindingMergeArtifacts(awbBundle) .getParentFile().getAbsolutePath(); } else if ("android.databinding.generationalFileOutDir".equals(key)) { value = value + "-" + awbBundle.getName(); } javacTask.getOptions().getCompilerArgs().add("-A" + key + "=" + value); } } javacTask.getOptions().getCompilerArgs().add("-s"); javacTask.getOptions().getCompilerArgs().add(appVariantOutputContext.getVariantContext() .getAwbAnnotationProcessorOutputDir(awbBundle).getAbsolutePath()); FileUtils.mkdirs(appVariantOutputContext.getVariantContext().getAwbAnnotationProcessorOutputDir(awbBundle)); if (scope.getGlobalScope().getExtension().getDataBinding().isEnabled() && appVariantOutputContext.getVariantContext().isDataBindEnabled(awbBundle)) { File file = appVariantOutputContext.getVariantContext().getAwbDataBindingMergeArtifacts(awbBundle); ReflectUtils.updateField(javacTask, "dataBindingDependencyArtifacts", scope.getGlobalScope().getProject().files(file)); // FileCollection files = // appVariantOutputContext.getScope().getArtifactCollection(COMPILE_CLASSPATH, ALL, DATA_BINDING_ARTIFACT).getArtifactFiles(); // for (File databingFile : files.getFiles()) { // for (File binFile : org.apache.commons.io.FileUtils.listFiles(databingFile,new String[]{"bin"},true)) { // if (binFile.getName().contains("baseAdapters")) { // try { // FileUtils.copyFileToDirectory(binFile, appVariantOutputContext.getVariantContext().getAwbDataBindingMergeArtifacts(awbBundle)); // } catch (IOException e) { // e.printStackTrace(); // } // } // } // } } ReflectUtils.updateField(javacTask, "annotationProcessorOutputFolder", appVariantOutputContext.getVariantContext().getAwbAnnotationProcessorOutputDir(awbBundle)); ReflectUtils.updateField(javacTask, "compileSdkVersion", scope.getGlobalScope().getExtension().getCompileSdkVersion()); ReflectUtils.updateField(javacTask, "processorListFile", appVariantOutputContext.getVariantContext().getScope().getOutput(ANNOTATION_PROCESSOR_LIST)); ReflectUtils.updateField(javacTask, "variantName", scope.getFullVariantName()); ReflectUtils.updateField(javacTask, "mInstantRunBuildContext", scope.getInstantRunBuildContext()); GradleBuildVariant.Builder builder = ProcessProfileWriter .getOrCreateVariant(scope.getGlobalScope().getProject().getPath(), scope.getFullVariantName()); if (builder != null && builder.getAnnotationProcessorsList().size() > 0) { builder.clearAnnotationProcessors(); } javacTask.setAwbBundle(awbBundle); //modification }
From source file:org.apache.axis2.jaxws.description.builder.JAXWSRIWSDLGenerator.java
/** * Expand a directory path or list of directory paths (File.pathSeparator * delimited) into a list of file paths of all the jar files in those * directories.// w ww.java 2 s . co m * * @param dirPaths The string containing the directory path or list of * directory paths. * @return The file paths of the jar files in the directories. This is an * empty string if no files were found, and is terminated by an * additional pathSeparator in all other cases. */ public static String expandDirs(String dirPaths) { StringTokenizer st = new StringTokenizer(dirPaths, File.pathSeparator); StringBuffer buffer = new StringBuffer(); while (st.hasMoreTokens()) { String d = st.nextToken(); File dir = new File(d); if (dir.isDirectory()) { File[] files = dir.listFiles(new JavaArchiveFilter()); for (int i = 0; i < files.length; i++) { buffer.append(files[i]).append(File.pathSeparator); } } } return buffer.toString(); }
From source file:org.codehaus.mojo.exec.ExecMojo.java
private void handleArguments(List<String> commandArguments) throws MojoExecutionException, IOException { for (int i = 0; i < arguments.size(); i++) { Object argument = arguments.get(i); String arg;/* www .jav a2 s .c om*/ if (argument instanceof String && isLongClassPathArgument((String) argument)) { // it is assumed that starting from -cp or -classpath the arguments // are: -classpath/-cp %classpath mainClass // the arguments are replaced with: -jar $TMP/maven-exec.jar // NOTE: the jar will contain the classpath and the main class commandArguments.add("-jar"); File tmpFile = createJar(computePath((Classpath) arguments.get(i + 1)), (String) arguments.get(i + 2)); commandArguments.add(tmpFile.getAbsolutePath()); i += 2; } if (argument instanceof String && isLongModulePathArgument((String) argument)) { String filePath = "target/modulepath"; commandArguments.add('@' + filePath); String modulePath = StringUtils.join(computePath((Modulepath) arguments.get(++i)).iterator(), File.pathSeparator); createArgFile(filePath, Arrays.asList("-p", modulePath)); } else if (argument instanceof Classpath) { Classpath specifiedClasspath = (Classpath) argument; arg = computeClasspathString(specifiedClasspath); commandArguments.add(arg); } else if (argument instanceof Modulepath) { Modulepath specifiedModulepath = (Modulepath) argument; arg = computeClasspathString(specifiedModulepath); commandArguments.add(arg); } else { commandArguments.add((String) argument); } } }
From source file:atg.tools.dynunit.nucleus.NucleusUtils.java
public static Nucleus startNucleusWithModules(NucleusStartupOptions startupOptions) throws ServletException, FileNotFoundException { notNull(startupOptions);//from w w w. ja va 2 s . c om notEmpty(startupOptions.getInitialService()); final File dynamoRoot = getExistingFile(findDynamoRoot()); setDynamoPropertyIfEmpty("atg.dynamo.root", dynamoRoot.getAbsolutePath()); final File dynamoHome = new File(dynamoRoot, "home"); setDynamoPropertyIfEmpty("atg.dynamo.home", dynamoHome.getAbsolutePath()); final String modulesPath = StringUtils.join(startupOptions.getModules(), File.pathSeparatorChar); setDynamoProperty("atg.dynamo.modules", modulesPath); setSystemPropertyIfEmpty("atg.dynamo.license.read", "true"); setSystemPropertyIfEmpty("atg.license.read", "true"); // our temporary server directory. File fileServerDir = null; try { AppModuleManager moduleManager = new MultiInstallLocalAppModuleManager(dynamoRoot.getAbsolutePath(), dynamoRoot, modulesPath); AppLauncher launcher = AppLauncher.getLauncher(moduleManager, modulesPath); // Start Nucleus String configpath = DynamoServerLauncher.calculateConfigPath(launcher, startupOptions.getLiveConfig(), startupOptions.getLayersAsString(), false, null); // use the NucleusUtils config dir as a base, since it // empties out license checks, etc. File fileBaseConfig = getConfigPath(NucleusUtils.class, null, false); if ((fileBaseConfig != null) && fileBaseConfig.exists()) { configpath = configpath + File.pathSeparator + fileBaseConfig.getAbsolutePath(); } // add the additional config path as the last arg, if needed File fileTestConfig = getConfigPath(startupOptions.getClassRelativeTo(), startupOptions.getBaseConfigDirectory(), false); // now add it to the end of our config path if ((fileTestConfig != null) && fileTestConfig.exists()) { configpath = configpath + File.pathSeparator + fileTestConfig.getAbsolutePath(); } else if (fileTestConfig != null) { logger.error("Warning: did not find directory {}", fileTestConfig.getAbsolutePath()); } String dynUnitHome = DynUnit.getHome(); if (dynUnitHome != null) { configpath = configpath + File.pathSeparator + dynUnitHome + File.separatorChar + "licenseconfig"; } // finally, create a server dir. fileServerDir = createTempServerDir(); setSystemProperty("atg.dynamo.server.home", fileServerDir.getAbsolutePath()); NucleusServlet.addNamingFactoriesAndProtocolHandlers(); ArrayList<String> listArgs = new ArrayList<String>(); listArgs.add(configpath); listArgs.add("-initialService"); listArgs.add(startupOptions.getInitialService()); PropertyEditors.registerEditors(); logger.info("Starting nucleus with arguments: " + listArgs); Nucleus n = Nucleus.startNucleus(listArgs.toArray(new String[listArgs.size()])); // remember our temporary server directory for later deletion nucleiConfigPathsCache.put(n, fileServerDir); // clear out the variable, so our finally clause knows not to // delete it fileServerDir = null; return n; } catch (AppLauncherException e) { throw logger.throwing(new ServletException(e)); } catch (IOException e) { throw logger.throwing(new ServletException(e)); } finally { if (fileServerDir != null) { try { // a non-null value means it was created, but not added to our list, // so we should nuke it. FileUtils.deleteDirectory(fileServerDir); } catch (IOException e) { logger.catching(Level.ERROR, e); } } } }
From source file:org.evosuite.executionmode.TestGeneration.java
private static List<List<TestGenerationResult>> generateTests(Properties.Strategy strategy, String target, List<String> args) { LoggingUtils.getEvoLogger().info("* Going to generate test cases for class: " + target); if (!findTargetClass(target)) { return Arrays.asList(Arrays.asList(new TestGenerationResult[] { TestGenerationResultBuilder.buildErrorResult("Could not find target class") })); }//w ww . ja v a 2 s . com if (!BytecodeInstrumentation.checkIfCanInstrument(target)) { throw new IllegalArgumentException("Cannot consider " + target + " because it belongs to one of the packages EvoSuite cannot currently handle"); } List<String> cmdLine = new ArrayList<>(); cmdLine.add(EvoSuite.JAVA_CMD); handleClassPath(cmdLine); if (Properties.SPAWN_PROCESS_MANAGER_PORT != null) { cmdLine.add("-Dspawn_process_manager_port=" + Properties.SPAWN_PROCESS_MANAGER_PORT); } ExternalProcessHandler handler = new ExternalProcessHandler(); int port = handler.openServer(); if (port <= 0) { throw new RuntimeException("Not possible to start RMI service"); } cmdLine.add("-Dprocess_communication_port=" + port); cmdLine.add("-Dinline=true"); if (Properties.HEADLESS_MODE == true) { cmdLine.add("-Djava.awt.headless=true"); } cmdLine.add("-Dlogback.configurationFile=" + LoggingUtils.getLogbackFileName()); cmdLine.add("-Dlog4j.configuration=SUT.log4j.properties"); /* * FIXME: following 3 should be refactored, as not particularly clean. * First 2 does not work for master, as logback is read * before Properties is initialized */ if (Properties.LOG_LEVEL != null) { cmdLine.add("-Dlog.level=" + Properties.LOG_LEVEL); } if (Properties.LOG_TARGET != null) { cmdLine.add("-Dlog.target=" + Properties.LOG_TARGET); } String logDir = System.getProperty("evosuite.log.folder"); if (logDir != null) { // this parameter is for example used in logback-ctg.xml cmdLine.add(" -Devosuite.log.folder=" + logDir); } //------------------------------------------------ cmdLine.add("-Djava.library.path=lib"); // cmdLine.add("-Dminimize_values=true"); if (Properties.DEBUG) { // enabling debugging mode to e.g. connect the eclipse remote debugger to the given port cmdLine.add("-Ddebug=true"); cmdLine.add("-Xdebug"); cmdLine.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=" + Properties.PORT); LoggingUtils.getEvoLogger() .info("* Waiting for remote debugger to connect on port " + Properties.PORT + "..."); // TODO find the right // place for this } if (!Properties.PROFILE.isEmpty()) { // enabling debugging mode to e.g. connect the eclipse remote debugger to the given port File agentFile = new File(Properties.PROFILE); if (!agentFile.exists()) { LoggingUtils.getEvoLogger().info("* Error: " + Properties.PROFILE + " not found"); } else { cmdLine.add("-agentpath:" + Properties.PROFILE); LoggingUtils.getEvoLogger().info("* Using profiling agent " + Properties.PROFILE); } } if (Properties.JMC) { //FIXME: does not seem to work, at least on Mac. Looks like some RMI conflict cmdLine.add("-XX:+UnlockCommercialFeatures"); cmdLine.add("-XX:+FlightRecorder"); cmdLine.add("-Dcom.sun.management.jmxremote"); cmdLine.add("-Dcom.sun.management.jmxremote.autodiscovery"); cmdLine.add("-Dcom.sun.management.jmxremote.authenticate=false"); cmdLine.add("-Dcom.sun.management.jmxremote.ssl=false"); } cmdLine.add("-XX:MaxJavaStackTraceDepth=1000000"); cmdLine.add("-XX:+StartAttachListener"); for (String arg : args) { if (!arg.startsWith("-DCP=")) { cmdLine.add(arg); } } switch (strategy) { case EVOSUITE: cmdLine.add("-Dstrategy=EvoSuite"); break; case ONEBRANCH: cmdLine.add("-Dstrategy=OneBranch"); break; case RANDOM: cmdLine.add("-Dstrategy=Random"); break; case RANDOM_FIXED: cmdLine.add("-Dstrategy=Random_Fixed"); break; case REGRESSION: cmdLine.add("-Dstrategy=Regression"); break; case ENTBUG: cmdLine.add("-Dstrategy=EntBug"); break; case MOSUITE: cmdLine.add("-Dstrategy=MOSuite"); break; case DSE: cmdLine.add("-Dstrategy=Dynamic_Symbolic_Execution"); break; default: throw new RuntimeException("Unsupported strategy: " + strategy); } cmdLine.add("-DTARGET_CLASS=" + target); if (Properties.PROJECT_PREFIX != null) { cmdLine.add("-DPROJECT_PREFIX=" + Properties.PROJECT_PREFIX); } cmdLine.add(ClientProcess.class.getName()); /* * TODO: here we start the client with several properties that are set through -D. These properties are not visible to the master process (ie * this process), when we access the Properties file. At the moment, we only need few parameters, so we can hack them */ Properties.getInstance();// should force the load, just to be sure Properties.TARGET_CLASS = target; Properties.PROCESS_COMMUNICATION_PORT = port; /* * FIXME: refactor, and double-check if indeed correct * * The use of "assertions" in the client is pretty tricky, as those properties need to be transformed into JVM options before starting the * client. Furthermore, the properties in the property file might be overwritten from the commands coming from shell */ String definedEAforClient = null; String definedEAforSUT = null; final String DISABLE_ASSERTIONS_EVO = "-da:" + PackageInfo.getEvoSuitePackage() + "..."; final String ENABLE_ASSERTIONS_EVO = "-ea:" + PackageInfo.getEvoSuitePackage() + "..."; final String DISABLE_ASSERTIONS_SUT = "-da:" + Properties.PROJECT_PREFIX + "..."; final String ENABLE_ASSERTIONS_SUT = "-ea:" + Properties.PROJECT_PREFIX + "..."; for (String s : cmdLine) { // first check client if (s.startsWith("-Denable_asserts_for_evosuite")) { if (s.endsWith("false")) { definedEAforClient = DISABLE_ASSERTIONS_EVO; } else if (s.endsWith("true")) { definedEAforClient = ENABLE_ASSERTIONS_EVO; } } // then check SUT if (s.startsWith("-Denable_asserts_for_sut")) { if (s.endsWith("false")) { definedEAforSUT = DISABLE_ASSERTIONS_SUT; } else if (s.endsWith("true")) { definedEAforSUT = ENABLE_ASSERTIONS_SUT; } } } /* * the assertions might not be defined in the command line, but they might be in the property file, or just use default values. NOTE: if those * are defined in the command line, then they overwrite whatever we had in the conf file */ if (definedEAforSUT == null) { if (Properties.ENABLE_ASSERTS_FOR_SUT) { definedEAforSUT = ENABLE_ASSERTIONS_SUT; } else { definedEAforSUT = DISABLE_ASSERTIONS_SUT; } } if (definedEAforClient == null) { if (Properties.ENABLE_ASSERTS_FOR_EVOSUITE) { definedEAforClient = ENABLE_ASSERTIONS_EVO; } else { definedEAforClient = DISABLE_ASSERTIONS_EVO; } } /* * We add them in first position, after the java command To avoid confusion, we only add them if they are enabled. NOTE: this might have side * effects "if" in the future we have something like a generic "-ea" */ if (definedEAforClient.equals(ENABLE_ASSERTIONS_EVO)) { cmdLine.add(1, definedEAforClient); } if (definedEAforSUT.equals(ENABLE_ASSERTIONS_SUT)) { cmdLine.add(1, definedEAforSUT); } LoggingUtils logUtils = new LoggingUtils(); if (!Properties.CLIENT_ON_THREAD) { /* * We want to completely mute the SUT. So, we block all outputs from client, and use a remote logging */ boolean logServerStarted = logUtils.startLogServer(); if (!logServerStarted) { logger.error("Cannot start the log server"); return null; } int logPort = logUtils.getLogServerPort(); // cmdLine.add(1, "-Dmaster_log_port=" + logPort); cmdLine.add(1, "-Devosuite.log.appender=CLIENT"); } String[] newArgs = cmdLine.toArray(new String[cmdLine.size()]); for (String entry : ClassPathHandler.getInstance().getTargetProjectClasspath().split(File.pathSeparator)) { try { ClassPathHacker.addFile(entry); } catch (IOException e) { LoggingUtils.getEvoLogger().info("* Error while adding classpath entry: " + entry); } } handler.setBaseDir(EvoSuite.base_dir_path); if (handler.startProcess(newArgs)) { Set<ClientNodeRemote> clients = null; try { //FIXME: timeout here should be handled by TimeController clients = MasterServices.getInstance().getMasterNode().getClientsOnceAllConnected(60000); } catch (InterruptedException e) { } if (clients == null) { logger.error("Not possible to access to clients. Clients' state: " + handler.getProcessState() + ". Master registry port: " + MasterServices.getInstance().getRegistryPort()); } else { /* * The clients have started, and connected back to Master. * So now we just need to tell them to start a search */ for (ClientNodeRemote client : clients) { try { client.startNewSearch(); } catch (RemoteException e) { logger.error("Error in starting clients", e); } } int time = TimeController.getInstance().calculateForHowLongClientWillRunInSeconds(); handler.waitForResult(time * 1000); try { Thread.sleep(100); } catch (InterruptedException e) { } } if (Properties.CLIENT_ON_THREAD) { handler.stopAndWaitForClientOnThread(10000); } handler.killProcess(); } else { LoggingUtils.getEvoLogger().info("* Could not connect to client process"); } boolean hasFailed = false; if (Properties.NEW_STATISTICS) { if (MasterServices.getInstance().getMasterNode() == null) { logger.error("Cannot write results as RMI master node is not running"); hasFailed = true; } else { boolean written = SearchStatistics.getInstance().writeStatistics(); hasFailed = !written; } } /* * FIXME: it is unclear what is the relation between TestGenerationResult and writeStatistics() */ List<List<TestGenerationResult>> results = SearchStatistics.getInstance().getTestGenerationResults(); SearchStatistics.clearInstance(); handler.closeServer(); if (Properties.CLIENT_ON_THREAD) { handler.stopAndWaitForClientOnThread(10000); } else { try { Thread.sleep(100); } catch (InterruptedException e) { } logUtils.closeLogServer(); } logger.debug("Master process has finished to wait for client"); //FIXME: tmp hack till understood what TestGenerationResult is... if (hasFailed) { logger.error("failed to write statistics data"); //note: cannot throw exception because would require refactoring of many SystemTests return new ArrayList<List<TestGenerationResult>>(); } return results; }
From source file:com.bugvm.maven.surefire.BugVMSurefireProvider.java
private Config.Builder createConfig() throws IOException { Config.Builder configBuilder = new Config.Builder(); final Logger logger = new Logger() { public void debug(String format, Object... args) { if (Boolean.getBoolean(PROP_LOG_DEBUG)) { providerParameters.getConsoleLogger().info("[DEBUG] " + String.format(format, args) + "\n"); }//from www . ja v a 2 s . c o m } public void info(String format, Object... args) { providerParameters.getConsoleLogger().info("[INFO] " + String.format(format, args) + "\n"); } public void warn(String format, Object... args) { providerParameters.getConsoleLogger().info("[WARNING] " + String.format(format, args) + "\n"); } public void error(String format, Object... args) { providerParameters.getConsoleLogger().info("[ERROR] " + String.format(format, args) + "\n"); } }; configBuilder.logger(logger); BugVMResolver roboVMResolver = new BugVMResolver(); roboVMResolver.setLogger(new com.bugvm.maven.resolver.Logger() { public void info(String logLine) { logger.info(logLine); } public void debug(String logLine) { logger.debug(logLine); } }); Home home = null; try { home = Home.find(); } catch (Throwable t) { } if (home == null || !home.isDev()) { home = new Home(roboVMResolver.resolveAndUnpackBugVMDistArtifact(Version.getVersion())); } configBuilder.home(home); if (home.isDev()) { configBuilder.useDebugLibs(Boolean.getBoolean("bugvm.useDebugLibs")); configBuilder.dumpIntermediates(true); } File basedir = new File(System.getProperty("basedir")); if (System.getProperties().containsKey(PROP_PROPERTIES_FILE)) { File propertiesFile = new File(System.getProperty(PROP_PROPERTIES_FILE)); if (!propertiesFile.exists()) { throw new FileNotFoundException("Failed to find specified " + PROP_PROPERTIES_FILE + ": " + propertiesFile.getAbsolutePath()); } logger.debug("Loading BugVM config properties from " + propertiesFile.getAbsolutePath()); configBuilder.addProperties(propertiesFile); } else { configBuilder.readProjectProperties(basedir, true); } if (System.getProperties().containsKey(PROP_CONFIG_FILE)) { File configFile = new File(System.getProperty(PROP_CONFIG_FILE)); if (!configFile.exists()) { throw new FileNotFoundException( "Failed to find specified " + PROP_CONFIG_FILE + ": " + configFile.getAbsolutePath()); } logger.debug("Loading BugVM config from " + configFile.getAbsolutePath()); configBuilder.read(configFile); } else { configBuilder.readProjectConfig(basedir, true); } if (System.getProperty(PROP_OS) != null) { configBuilder.os(OS.valueOf(System.getProperty(PROP_OS))); } if (System.getProperty(PROP_ARCH) != null) { configBuilder.arch(Arch.valueOf(System.getProperty(PROP_ARCH))); } if (Boolean.getBoolean(PROP_IOS_SKIP_SIGNING)) { configBuilder.iosSkipSigning(true); } else { if (System.getProperty(PROP_IOS_SIGNING_IDENTITY) != null) { String iosSignIdentity = System.getProperty(PROP_IOS_SIGNING_IDENTITY); logger.debug("Using explicit iOS Signing identity: " + iosSignIdentity); configBuilder.iosSignIdentity(SigningIdentity.find(SigningIdentity.list(), iosSignIdentity)); } if (System.getProperty(PROP_IOS_PROVISIONING_PROFILE) != null) { String iosProvisioningProfile = System.getProperty(PROP_IOS_PROVISIONING_PROFILE); logger.debug("Using explicit iOS provisioning profile: " + iosProvisioningProfile); configBuilder.iosProvisioningProfile( ProvisioningProfile.find(ProvisioningProfile.list(), iosProvisioningProfile)); } // if (System.getProperty(PROP_KEYCHAIN_PASSWORD) != null) { // configBuilder.keychainPassword(System.getProperty(PROP_KEYCHAIN_PASSWORD)); // } else if (System.getProperty(PROP_KEYCHAIN_PASSWORD_FILE) != null) { // configBuilder.keychainPasswordFile(new File(System.getProperty(PROP_KEYCHAIN_PASSWORD_FILE))); // } } if (System.getProperty(PROP_CACHE_DIR) != null) { File cacheDir = new File(System.getProperty(PROP_CACHE_DIR)); logger.debug("Using explicit cache dir: " + cacheDir); configBuilder.cacheDir(cacheDir); } // Ignore any classpath entries in the loaded bugvm.xml file. configBuilder.clearClasspathEntries(); configBuilder.addClasspathEntry( roboVMResolver.resolveArtifact("com.bugvm:bugvm-junit-server:" + Version.getVersion()).asFile()); if (isIOS()) { configBuilder.addClasspathEntry( roboVMResolver.resolveArtifact("com.bugvm:bugvm-rt:" + Version.getVersion()).asFile()); configBuilder.addClasspathEntry( roboVMResolver.resolveArtifact("com.bugvm:bugvm-objc:" + Version.getVersion()).asFile()); configBuilder.addClasspathEntry( roboVMResolver.resolveArtifact("com.bugvm:bugvm-cocoatouch:" + Version.getVersion()).asFile()); } for (String p : System.getProperty("java.class.path").split(File.pathSeparator)) { configBuilder.addClasspathEntry(new File(p)); } if (testClassLoader.getClass().getName().equals("org.apache.maven.surefire.booter.IsolatedClassLoader")) { // Not fork mode. We need to get to the URLs of the IsolatedClassLoader. // Only way is to use reflection. try { Field f = testClassLoader.getClass().getDeclaredField("urls"); f.setAccessible(true); @SuppressWarnings("unchecked") Collection<URL> urls = (Collection<URL>) f.get(testClassLoader); for (URL url : urls) { File file = new File(url.getFile()); if (file.isDirectory() || file.getName().toLowerCase().matches(".*\\.(jar|zip)$")) { configBuilder.addClasspathEntry(file); } } } catch (Throwable t) { throw new RuntimeException("Failed to get classpath URLs from IsolatedClassLoader using reflection", t); } } else { Properties props = providerParameters.getProviderProperties(); for (int i = 0; true; i++) { String path = props.getProperty("classPathUrl." + i); if (path == null) { break; } configBuilder.addClasspathEntry(new File(path)); } } for (Class<?> c : testsToRun.getLocatedClasses()) { configBuilder.addForceLinkClass(c.getName()); } configBuilder.skipInstall(true); return configBuilder; }
From source file:net.grinder.engine.agent.AgentImplementationEx.java
private Properties rebaseSystemClassPath(Properties properties, File curDir) { Properties newProperties = new Properties(); newProperties.putAll(properties);//from w ww . j a va2 s .c om StringBuilder newClassPath = new StringBuilder(); boolean isFirst = true; for (String each : StringUtils.split(properties.getProperty("java.class.path"), File.pathSeparator)) { File file = new File(each); if (!file.isAbsolute()) { file = new File(curDir, each); } if (!isFirst) { newClassPath.append(File.pathSeparator); } isFirst = false; newClassPath.append(FilenameUtils.normalize(file.getAbsolutePath())); } newProperties.put("java.class.path", newClassPath.toString()); return newProperties; }
From source file:com.googlecode.mycontainer.maven.plugin.ExecMojo.java
CommandLine getExecutablePath(Map enviro, File dir) { File execFile = new File(executable); String exec = null;/* w ww . ja va2s. c o m*/ if (execFile.exists()) { getLog().debug("Toolchains are ignored, 'executable' parameter is set to " + executable); exec = execFile.getAbsolutePath(); } else { Toolchain tc = getToolchain(); // if the file doesn't exist & toolchain is null, the exec is // probably in the PATH... // we should probably also test for isFile and canExecute, but the // second one is only // available in SDK 6. if (tc != null) { getLog().info("Toolchain in exec-maven-plugin: " + tc); exec = tc.findTool(executable); } else { if (OS.isFamilyWindows()) { String ex = executable.indexOf(".") < 0 ? executable + ".bat" : executable; File f = new File(dir, ex); if (f.exists()) { exec = ex; } else { // now try to figure the path from PATH, PATHEXT env // vars // if bat file, wrap in cmd /c String path = (String) enviro.get("PATH"); if (path != null) { String[] elems = StringUtils.split(path, File.pathSeparator); for (int i = 0; i < elems.length; i++) { f = new File(new File(elems[i]), ex); if (f.exists()) { exec = ex; break; } } } } } } } if (exec == null) { exec = executable; } CommandLine toRet; if (OS.isFamilyWindows() && exec.toLowerCase(Locale.getDefault()).endsWith(".bat")) { toRet = new CommandLine("cmd"); toRet.addArgument("/c"); toRet.addArgument(exec); } else { toRet = new CommandLine(exec); } return toRet; }
From source file:org.craftercms.cstudio.alfresco.service.impl.PermissionServiceImpl.java
protected String getSiteFromKey(String key) { return key.substring(0, key.indexOf(File.pathSeparator)); }