VSiteGenTask.java
/*
* Copyright 2007 Roberto Fasciolo
*
* This file is part of vsitegen.
*
* vsitegen is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* vsitegen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with vsitegen; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.robyf.vsitegen.ant;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.LogLevel;
import net.robyf.vsitegen.engine.GeneratorException;
import net.robyf.vsitegen.engine.SiteGenerator;
public final class VSiteGenTask extends Task {
private String projectName;
private String template;
private File navigationFile;
private File contentDir;
private File outputDir;
public void setContent(final File contentDir) {
this.contentDir = contentDir;
}
public void setNavigation(final File navigationFile) {
this.navigationFile = navigationFile;
}
public void setOutput(final File outputDir) {
this.outputDir = outputDir;
}
public void setProject(final String projectName) {
this.projectName = projectName;
}
public void setTemplate(final String template) {
this.template = template;
}
@Override
public void execute() {
try (FileInputStream inputStream = new FileInputStream(navigationFile)) {
SiteGenerator generator = new SiteGenerator(inputStream,
this.contentDir.getAbsolutePath(),
this.outputDir.getAbsolutePath(),
this.projectName,
this.template);
generator.generate();
} catch (IOException e) {
throw new GeneratorException("Error getting navigation file", e);
} catch (RuntimeException e) {
this.log("Unexpected error executing the task", e, LogLevel.ERR.getLevel());
throw e;
}
}
}