/******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ /** * This class finds the version of a plug-in, or fragment listed in a feature * and writes =_ for each in a properties file. * The file produced from this task can be loaded by an Ant script to find files in the * binary versions of plugins and fragments. */ package org.eclipse.releng.generators; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.SAXException; import java.io.*; import java.util.Hashtable; import java.util.Enumeration; import org.apache.tools.ant.Task; import java.util.Vector; public class VersionTrackerTask extends Task { private String buildDirectory; private Hashtable elements; private SAXParser parser; private Vector allElements; //the feature to from which to collect version information private String featurePath; //the path to the file in which to write the results private String outputFilePath; public void execute(){ VersionTrackerTask tracker = new VersionTrackerTask(getBuildDirectory()); tracker.parse(getFeaturePath(),new FeatureHandler()); tracker.parse(new PluginHandler()); tracker.writeProperties(getOutputFilePath(), true); } //test public static void main(String[] args) { VersionTrackerTask Tracker = new VersionTrackerTask(args[1]); Tracker.parse(args[0],Tracker.new FeatureHandler()); Tracker.parse(Tracker.new PluginHandler()); Tracker.writeProperties(args[2], true); } public VersionTrackerTask(){ } public VersionTrackerTask(String install) { elements = new Hashtable(); allElements=new Vector(); SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); try { parser = saxParserFactory.newSAXParser(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } // directory containing the source for a given build buildDirectory = install; } private void parse (DefaultHandler handler){ for (int i=0; i