@Override public void prettyprint() { long tstart = System.currentTimeMillis(); try { modelBuilder.generateProcessedSourceFiles(getEnvironment().getOutputType(), typeFilter); } catch (Exception e) { throw new SpoonException(e); } if (!getEnvironment().getOutputType().equals(OutputType.NO_OUTPUT) && getEnvironment().isCopyResources()) { for (File dirInputSource : modelBuilder.getInputSources()) { if (dirInputSource.isDirectory()) { final Collection<?> resources = FileUtils.listFiles(dirInputSource, RESOURCES_FILE_FILTER, ALL_DIR_FILTER); for (Object resource : resources) { final String resourceParentPath = ((File) resource).getParent(); final String packageDir = resourceParentPath.substring(dirInputSource.getPath().length()); final String targetDirectory = getEnvironment().getDefaultFileGenerator().getOutputDirectory() + packageDir; try { FileUtils.copyFileToDirectory((File) resource, new File(targetDirectory)); } catch (IOException e) { throw new SpoonException(e); } } } } } getEnvironment().debugMessage("pretty-printed in " + (System.currentTimeMillis() - tstart) + " ms"); }
/** * Compile the original code * * @param properties */ protected void compileProject(ProjectConfiguration properties) { final Launcher launcher = new Launcher(); for (String path_src : properties.getOriginalDirSrc()) { log.debug("Add folder to compile: " + path_src); launcher.addInputResource(path_src); } for (String path_test : properties.getTestDirSrc()) { log.debug("Add folder to compile: " + path_test); launcher.addInputResource(path_test); } String binoutput = properties.getWorkingDirForBytecode() + File.separator + (ProgramVariant.DEFAULT_ORIGINAL_VARIANT); launcher.setBinaryOutputDirectory(binoutput); log.info("Compiling original code from " + launcher.getModelBuilder().getInputSources() + "\n bytecode saved in " + launcher.getModelBuilder().getBinaryOutputDirectory()); launcher.getEnvironment() .setPreserveLineNumbers(ConfigurationProperties.getPropertyBool("preservelinenumbers")); launcher.getEnvironment().setComplianceLevel(ConfigurationProperties.getPropertyInt("javacompliancelevel")); launcher.getEnvironment().setShouldCompile(true); launcher.getEnvironment().setSourceClasspath(properties.getDependenciesString().split(File.pathSeparator)); launcher.buildModel(); launcher.getModelBuilder().generateProcessedSourceFiles(OutputType.COMPILATION_UNITS); launcher.getModelBuilder().compile(InputType.FILES); // launcher.getModelBuilder().generateProcessedSourceFiles(OutputType.CLASSES); }