/** * Copy all the jar in a local folder. That allows to have a lot of dependencies on a Windows * plateform. On Windows the Command Line can't be longer than 8192 character. With that mecanism, * the local path are shorter than the full one. For example: "lib/myJar-1.0.jar" is shorter than * "d:\maven\repo\com\myCompany\myJar\1.0\myJar-1.0.jar". The method copy the jar and compute the * new classpath using these local jars. * * @param pClasspath The absolute classpath provided by Maven or FitNesse. * @return The new local classpath. * @throws MojoExecutionException If the classpath can't be found. */ String copyDependenciesLocally(String pClasspath) throws MojoExecutionException { String tPathSep = System.getProperty("path.separator"); String tFileSep = System.getProperty("file.separator"); File tFolder = new File(workingDir + tFileSep + "lib"); if (!tFolder.exists()) { tFolder.mkdirs(); } StringTokenizer tToken = new StringTokenizer(pClasspath, tPathSep); String tFileName, tShortFileName; File tFile; FileInputStream tFileInput; StringBuffer tBuffer = new StringBuffer(); File tResultFile; try { while (tToken.hasMoreTokens()) { tFileName = tToken.nextToken(); tFile = new File(tFileName); if (tFile.exists()) { tFileInput = new FileInputStream(tFile); int tIndex = tFileName.lastIndexOf(tFileSep); tShortFileName = tFileName.substring(tIndex + 1); tResultFile = new File(workingDir + tFileSep + "lib" + tFileSep + tShortFileName); FitnesseReportMojo.copyFile(getLog(), tFileInput, tResultFile); tBuffer.append("lib" + tFileSep + tShortFileName + tPathSep); } else { getLog().warn("Unable to find the file [" + tFileName + "], skipping this file"); } } } catch (FileNotFoundException e) { throw new MojoExecutionException("File not found", e); } catch (MavenReportException e) { throw new MojoExecutionException("File not found", e); } return tBuffer.toString(); }
/** * Main Mojo method. * * @throws MojoExecutionException If the method can't be executed. * @throws MojoFailureException If there is fitnesse tests failures. */ public void execute() throws MojoExecutionException, MojoFailureException { new File(this.workingDir).mkdirs(); checkConfiguration(); try { FitnesseReportMojo.copyAllResources( new File(this.workingDir), getLog(), getClass().getClassLoader()); } catch (MavenReportException e) { throw new MojoExecutionException("Unable to copy resources", e.getCause()); } getLog().info("Found " + getFitnesseSize() + " Fitnesse configuration."); for (int i = 0; i < getFitnesseSize(); i++) { Fitnesse tServer = getFitnesse(i); callFitnesse(tServer); transformResultPage(tServer); } }