// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/GenerateSiteXml.java
// public class GenerateSiteXml  {
// 
// 	private String eclipseFolder = null;
// 	private List<String> features = new ArrayList<String>();
// 
// 	public GenerateSiteXml(String eclipseFolder) {
// 		this.eclipseFolder = eclipseFolder;
// 	}
// 
// 	public void execute() throws FileNotFoundException, TransformerException,
// 			ParserConfigurationException {
// 
// 		File eclipseDirFile = new File(this.eclipseFolder);
// 		if (!eclipseDirFile.exists()) {
// 			throw new FileNotFoundException(
// 					"Can't find Eclipse Directory, does not exists");
// 		}
// 		if (!eclipseDirFile.isDirectory()) {
// 			throw new IllegalArgumentException(
// 					"Supplied argument must be a directory");
// 		}
// 		String featuresDir = this.eclipseFolder + File.separator + "features";
// 
// 		File featuresDirFile = new File(featuresDir);
// 		if (!featuresDirFile.exists()) {
// 			throw new FileNotFoundException("features sub directory not found");
// 		}
// 		if (!featuresDirFile.isDirectory()) {
// 			throw new IllegalArgumentException(
// 					"Directory must have sub-directory called features");
// 		}
// 		String[] featureJars = featuresDirFile.list();
// 		for (String subfile : featureJars) {
// 			if (subfile.endsWith(".jar")) {
// 				this.features.add(subfile);
// 			}
// 		}
// 		DocumentBuilderFactory docFactory = DocumentBuilderFactory
// 				.newInstance();
// 		DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
// 
// 		Document doc = docBuilder.newDocument();
// 		Element rootElement = doc.createElement("site");
// 		doc.appendChild(rootElement);
// 		for (String featureName : this.features) {
// 			if (featureName.endsWith(".jar") && featureName.contains("_")) {
// 				String[] bits = featureName.split("_");
// 
// 				String id = bits[0];
// 				String version = bits[1].substring(0, bits[1].lastIndexOf('.'));
// 				String url = "features/" + featureName;
// 
// 				Element feature = doc.createElement("feature");
// 				rootElement.appendChild(feature);
// 
// 				feature.setAttribute("url", url);
// 				feature.setAttribute("id", id);
// 				feature.setAttribute("version", version);
// 			}
// 		}
// 		TransformerFactory transformerFactory = TransformerFactory
// 				.newInstance();
// 		Transformer transformer = transformerFactory.newTransformer();
// 		DOMSource source = new DOMSource(doc);
// 		StreamResult result = new StreamResult(new File(eclipseDirFile,
// 				"site.xml"));
// 
// 		transformer.setOutputProperty("indent", "yes");
// 		transformer.setOutputProperty(
// 				"{http://xml.apache.org/xslt}indent-amount", "2");
// 
// 		transformer.transform(source, result);
// 
// 		System.out.println("File saved!");
// 	}
// 
// 	public static void main(String[] args) throws FileNotFoundException,
// 			TransformerException, ParserConfigurationException {
// 		if (args.length != 1) {
// 			System.out.println("Wrong number of arguments");
// 			System.out
// 					.println("expects update site root directory containing features directory");
// 		}
// 		String updateSiteFolder = args[0];
// 
// 		System.out.println("Running on " + updateSiteFolder);
// 
// 		GenerateSiteXml gen = new GenerateSiteXml(updateSiteFolder);
// 		gen.execute();
// 	}
// }


import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.GenerateSiteXml;
package com.gregorbyte.buildxpages.ant;




public class GenerateSiteXmlTask extends Task {

	private String eclipseDir;

	public void setEclipseDir(String eclipseDir) {
		this.eclipseDir = eclipseDir;
	}

	@Override
	public void execute() throws BuildException {

		if (this.eclipseDir == null || this.eclipseDir.isEmpty())
			throw new BuildException("eclipseDir not Specified");
		
		File file = new File(eclipseDir);
		
		if (!file.exists())
			throw new BuildException("specified eclipseDir does not exists");
		
		if (!file.isDirectory())
			throw new BuildException("eclipseDir must be a directory");
		
		try {

// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/GenerateSiteXml.java
// public class GenerateSiteXml  {
// 
// 	private String eclipseFolder = null;
// 	private List<String> features = new ArrayList<String>();
// 
// 	public GenerateSiteXml(String eclipseFolder) {
// 		this.eclipseFolder = eclipseFolder;
// 	}
// 
// 	public void execute() throws FileNotFoundException, TransformerException,
// 			ParserConfigurationException {
// 
// 		File eclipseDirFile = new File(this.eclipseFolder);
// 		if (!eclipseDirFile.exists()) {
// 			throw new FileNotFoundException(
// 					"Can't find Eclipse Directory, does not exists");
// 		}
// 		if (!eclipseDirFile.isDirectory()) {
// 			throw new IllegalArgumentException(
// 					"Supplied argument must be a directory");
// 		}
// 		String featuresDir = this.eclipseFolder + File.separator + "features";
// 
// 		File featuresDirFile = new File(featuresDir);
// 		if (!featuresDirFile.exists()) {
// 			throw new FileNotFoundException("features sub directory not found");
// 		}
// 		if (!featuresDirFile.isDirectory()) {
// 			throw new IllegalArgumentException(
// 					"Directory must have sub-directory called features");
// 		}
// 		String[] featureJars = featuresDirFile.list();
// 		for (String subfile : featureJars) {
// 			if (subfile.endsWith(".jar")) {
// 				this.features.add(subfile);
// 			}
// 		}
// 		DocumentBuilderFactory docFactory = DocumentBuilderFactory
// 				.newInstance();
// 		DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
// 
// 		Document doc = docBuilder.newDocument();
// 		Element rootElement = doc.createElement("site");
// 		doc.appendChild(rootElement);
// 		for (String featureName : this.features) {
// 			if (featureName.endsWith(".jar") && featureName.contains("_")) {
// 				String[] bits = featureName.split("_");
// 
// 				String id = bits[0];
// 				String version = bits[1].substring(0, bits[1].lastIndexOf('.'));
// 				String url = "features/" + featureName;
// 
// 				Element feature = doc.createElement("feature");
// 				rootElement.appendChild(feature);
// 
// 				feature.setAttribute("url", url);
// 				feature.setAttribute("id", id);
// 				feature.setAttribute("version", version);
// 			}
// 		}
// 		TransformerFactory transformerFactory = TransformerFactory
// 				.newInstance();
// 		Transformer transformer = transformerFactory.newTransformer();
// 		DOMSource source = new DOMSource(doc);
// 		StreamResult result = new StreamResult(new File(eclipseDirFile,
// 				"site.xml"));
// 
// 		transformer.setOutputProperty("indent", "yes");
// 		transformer.setOutputProperty(
// 				"{http://xml.apache.org/xslt}indent-amount", "2");
// 
// 		transformer.transform(source, result);
// 
// 		System.out.println("File saved!");
// 	}
// 
// 	public static void main(String[] args) throws FileNotFoundException,
// 			TransformerException, ParserConfigurationException {
// 		if (args.length != 1) {
// 			System.out.println("Wrong number of arguments");
// 			System.out
// 					.println("expects update site root directory containing features directory");
// 		}
// 		String updateSiteFolder = args[0];
// 
// 		System.out.println("Running on " + updateSiteFolder);
// 
// 		GenerateSiteXml gen = new GenerateSiteXml(updateSiteFolder);
// 		gen.execute();
// 	}
// }


// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/GenerateSiteXmlTask.java
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.GenerateSiteXml;

package com.gregorbyte.buildxpages.ant;




public class GenerateSiteXmlTask extends Task {

	private String eclipseDir;

	public void setEclipseDir(String eclipseDir) {
		this.eclipseDir = eclipseDir;
	}

	@Override
	public void execute() throws BuildException {

		if (this.eclipseDir == null || this.eclipseDir.isEmpty())
			throw new BuildException("eclipseDir not Specified");
		
		File file = new File(eclipseDir);
		
		if (!file.exists())
			throw new BuildException("specified eclipseDir does not exists");
		
		if (!file.isDirectory())
			throw new BuildException("eclipseDir must be a directory");
		
		try {

			GenerateSiteXml gen = new GenerateSiteXml(this.eclipseDir);