verbose("System property '" + MAGIC_PROPERTY_CLASS_LOCATION + "' set, so use " + "its value '" + syspropValue + "' as location for collector class."); } else if (antpropValue != null) { locationName = antpropValue; verbose("Ant property '" + MAGIC_PROPERTY_CLASS_LOCATION + "' set, so use " + "its value '" + antpropValue + "' as location for collector class."); } else { locationName = DEFAULT_CLASS_LOCATION; verbose("System property '" + MAGIC_PROPERTY_CLASS_LOCATION + "' not set, so use " + "value as location for collector class: '" + DEFAULT_CLASS_LOCATION + "'"); File f = new File(getProject().getBaseDir(), locationName); locationName = f.getAbsolutePath(); verbose("Location file is relative (" + locationFile + ")" + " use absolute path instead (" + locationName + ")");
private void writeJavaClass() { try { File sourceFile = new File(getLocationName() + ".java"); verbose("Write collector class to '" + sourceFile.getAbsolutePath() + "'"); if (sourceFile.exists() && !sourceFile.delete()) { throw new IOException("could not delete " + sourceFile); } writer = new BufferedWriter(new FileWriter(sourceFile)); createClassHeader(); createSuiteMethod(); createClassFooter(); } catch (IOException e) { log(StringUtils.getStackTrace(e)); } finally { FileUtils.close(writer); } }
/** * This method is called by the Ant runtime by reflection. We use the project reference for * registration of this class as BuildListener. * * @param project * project reference */ @Override public void setProject(Project project) { // store project reference for logging super.setProject(project); // check if already registered // register if needed if (project.getBuildListeners().stream().noneMatch(FailureRecorder.class::isInstance)) { verbose("Register FailureRecorder (@" + this.hashCode() + ") as BuildListener"); project.addBuildListener(this); } }