/** * Create an eclipse launch configuration file for the specified test * * @param test the GWTTestCase * @param testSrc the source directory where the test lives * @throws MojoExecutionException some error occured */ private void createLaunchConfigurationForGwtTestCase(File testSrc, String test) throws MojoExecutionException { File testFile = new File(testSrc, test); String fqcn = test.replace(File.separatorChar, '.').substring(0, test.lastIndexOf('.')); File launchFile = new File(getProject().getBasedir(), fqcn + ".launch"); if (launchFile.exists() && launchFile.lastModified() > testFile.lastModified()) { return; } Configuration cfg = new Configuration(); cfg.setClassForTemplateLoading(EclipseTestMojo.class, ""); Map<String, Object> context = new HashMap<String, Object>(); List<String> sources = new LinkedList<String>(); sources.addAll(executedProject.getTestCompileSourceRoots()); sources.addAll(executedProject.getCompileSourceRoots()); context.put("sources", sources); context.put("test", fqcn); int basedir = getProject().getBasedir().getAbsolutePath().length(); context.put("out", testOutputDirectory.getAbsolutePath().substring(basedir + 1)); context.put("extraJvmArgs", getExtraJvmArgs()); context.put("project", eclipseUtil.getProjectName(getProject())); try { // context.put( "gwtDevJarPath", getGwtDevJar().getAbsolutePath() ); Writer configWriter = WriterFactory.newXmlWriter(launchFile); Template template = cfg.getTemplate("test-launch.fm", "UTF-8"); template.process(context, configWriter); configWriter.flush(); configWriter.close(); getLog().info("Write launch configuration for GWT test : " + launchFile.getAbsolutePath()); } catch (IOException ioe) { throw new MojoExecutionException("Unable to write launch configuration", ioe); } catch (TemplateException te) { throw new MojoExecutionException("Unable to merge freemarker template", te); } }