org.hibernate.tool.ant.JavaFormatterTask Maven / Gradle / Ivy
package org.hibernate.tool.ant;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.hibernate.tool.hbm2x.ExporterException;
import org.hibernate.tool.ide.formatting.DefaultJavaPrettyPrinterStrategy;
public class JavaFormatterTask extends Task {
private List fileSets = new ArrayList();
private boolean failOnError;
private File configurationFile;
public void addConfiguredFileSet(FileSet fileSet) {
fileSets.add(fileSet);
}
public void setConfigurationFile(File configurationFile) {
this.configurationFile = configurationFile;
}
private Properties readConfig(File cfgfile) throws IOException {
BufferedInputStream stream = null;
try {
stream = new BufferedInputStream(new FileInputStream(cfgfile));
final Properties settings = new Properties();
settings.load(stream);
return settings;
} catch (IOException e) {
throw e;
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
}
}
}
}
public void execute() throws BuildException {
Map