geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hogst...@apache.org
Subject svn commit: r430409 - in /geronimo/sandbox/contrib/releasetools/trunk/src: java/org/apache/geroinimo/releasetools/VersionVerifier.java resources/ test/
Date Thu, 10 Aug 2006 15:09:54 GMT
Author: hogstrom
Date: Thu Aug 10 08:09:52 2006
New Revision: 430409

URL: http://svn.apache.org/viewvc?rev=430409&view=rev
Log:
Updated release tool to track Geronimo Dependencies

Added:
    geronimo/sandbox/contrib/releasetools/trunk/src/resources/
    geronimo/sandbox/contrib/releasetools/trunk/src/test/
Modified:
    geronimo/sandbox/contrib/releasetools/trunk/src/java/org/apache/geroinimo/releasetools/VersionVerifier.java

Modified: geronimo/sandbox/contrib/releasetools/trunk/src/java/org/apache/geroinimo/releasetools/VersionVerifier.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/contrib/releasetools/trunk/src/java/org/apache/geroinimo/releasetools/VersionVerifier.java?rev=430409&r1=430408&r2=430409&view=diff
==============================================================================
--- geronimo/sandbox/contrib/releasetools/trunk/src/java/org/apache/geroinimo/releasetools/VersionVerifier.java
(original)
+++ geronimo/sandbox/contrib/releasetools/trunk/src/java/org/apache/geroinimo/releasetools/VersionVerifier.java
Thu Aug 10 08:09:52 2006
@@ -46,13 +46,21 @@
 public class VersionVerifier {
 
 	File geronimoRoot = null;
+
 	static Properties p = null;
+
 	ArrayList projectXmls = null;
+
 	Dependency currentDependency = null;
+
 	ArrayList dependencyList = null;
+
 	boolean processingGroup = false;
+
 	boolean processingArtifact = false;
+
 	boolean processingVersion = false;
+
 	String currentXML = null;
 
 	/**
@@ -64,11 +72,74 @@
 
 		v.init(args);
 		v.processProjectXMLs();
-		for (int x = 0; x < v.dependencyList.size(); x++) {
-			v.getJarInfo((Dependency)v.dependencyList.get(x));
+		v.projectReport();
+		// for (int x = 0; x < v.dependencyList.size(); x++) {
+		// v.getJarInfo((Dependency)v.dependencyList.get(x));
+		// }
+	}
+
+	/**
+	 * Argument 0 is the Geronimo Tree name to check versions on.
+	 */
+	private boolean init(String[] args) {
+		geronimoRoot = new File(args[0]);
+		projectXmls = new ArrayList(500);
+		dependencyList = new ArrayList(500);
+		String propertiesFileName = geronimoRoot.getAbsolutePath()
+				+ "/etc/project.properties";
+
+		// Get our properties
+		if (geronimoRoot.exists()) {
+			File etcProperties = new File(propertiesFileName);
+			p = new Properties();
+			try {
+				p.load(new FileInputStream(etcProperties));
+			} catch (Exception e) {
+				System.err.println("Unable to open file " + propertiesFileName
+						+ ".\n    Message is " + e.getMessage());
+				return false;
+			}
+			getProjectXmlFiles(geronimoRoot);
+		}
+		return true;
+	}
+
+	/**
+	 * After this routine returns we have a list of all project.xml files in the
+	 * Geronimo Tree in the ArrayList projectXmls.
+	 */
+	private void getProjectXmlFiles(File geronimoRoot) {
+		// get Module list
+		searchDirs(geronimoRoot);
+		// searchDirs(new File(geronimoRoot.getAbsoluteFile() + "/configs"));
+		for (int x = 0; x < projectXmls.size(); x++) {
+			System.out.println(((File) projectXmls.get(x)).getAbsolutePath());
+		}
+	}
+
+	/**
+	 * 
+	 */
+	private void searchDirs(File dirName) {
+		if (dirName.isDirectory()) {
+			// So far so good
+			File[] modList = dirName.listFiles();
+			for (int x = 0; x < modList.length; x++) {
+				File pFile = new File(modList[x].getAbsoluteFile()
+						+ "/project.xml");
+				if (pFile.exists() && pFile.isFile()) {
+					projectXmls.add(pFile);
+				} else {
+					if (modList[x].isDirectory())
+						searchDirs(modList[x]);
+				}
+			}
 		}
 	}
 
+	/**
+	 * 
+	 */
 	private void processProjectXMLs() {
 		File cFile = null;
 		for (int x = 0; x < projectXmls.size(); x++) {
@@ -89,24 +160,26 @@
 					Element dependencyElement = (Element) configs.item(i);
 					String project = cFile.getCanonicalPath();
 					String groupId = getString(dependencyElement, "groupId");
-					String artifactId = getString(dependencyElement, "artifactId");
-					String version = resolveVersion(getString( dependencyElement, "version"));
+					String artifactId = getString(dependencyElement,
+							"artifactId");
+					String version = resolveVersion(getString(
+							dependencyElement, "version"));
 					String type = getString(dependencyElement, "type");
 					if (type == null) {
 						type = "jar";
 					}
-					dependencyList.add(new Dependency(project,
-							groupId, artifactId, version, type));
+					dependencyList.add(new Dependency(project, groupId,
+							artifactId, version, type));
 				}
 			} catch (IOException e) {
 				throw (IllegalStateException) new IllegalStateException(
-						"Unable to parse  file in "+cFile.getAbsoluteFile());
+						"Unable to parse  file in " + cFile.getAbsoluteFile());
 			} catch (ParserConfigurationException e) {
 				throw (IllegalStateException) new IllegalStateException(
-						"Unable to parse  file in "+cFile.getAbsoluteFile());
+						"Unable to parse  file in " + cFile.getAbsoluteFile());
 			} catch (SAXException e) {
 				throw (IllegalStateException) new IllegalStateException(
-						"Unable to parse  file in "+cFile.getAbsoluteFile());
+						"Unable to parse  file in " + cFile.getAbsoluteFile());
 			}
 
 		}
@@ -145,68 +218,37 @@
 		return value.trim();
 	}
 
-	/*
-	 * Argument 0 is the Geronimo Tree name to check versions on.
+	/**
+	 * 
 	 */
-	private boolean init(String[] args) {
-		geronimoRoot = new File(args[0]);
-		projectXmls = new ArrayList(500);
-		dependencyList = new ArrayList(500);
-
-		// Get our properties
-		if (geronimoRoot.exists()) {
-			File etcProperties = new File(geronimoRoot.getAbsolutePath()
-					+ "/etc/project.properties");
-			p = new Properties();
-			try {
-				p.load(new FileInputStream(etcProperties));
-			} catch (Exception e) {
-				System.err.println("Unable to open file.  Message is "
-						+ e.getMessage());
-			}
-			getProjectXmlFiles(geronimoRoot);
-		}
-		return true;
-	}
-
-	// After this routeine returns we have a list of all project.xml files in
-	// the
-	// Geronimo Tree in the ArrayList projectXmls.
-	private void getProjectXmlFiles(File geronimoRoot) {
-		// get Module list
-		searchDirs(geronimoRoot);
-		// searchDirs(new File(geronimoRoot.getAbsoluteFile() + "/configs"));
-		for (int x = 0; x < projectXmls.size(); x++) {
-			System.out.println(((File) projectXmls.get(x)).getAbsolutePath());
+	void projectReport() {
+		for (int x = 0; x < dependencyList.size(); x++) {
+            Dependency d = (Dependency) dependencyList.get(x);
+            System.out.println(" ************************************");
+            System.out.println("   Project: "+d.project);
+            System.out.println("     Group: "+d.groupId);
+            System.out.println("ArtifactId: "+d.artifactId);
+            System.out.println("      Type: "+d.type);
 		}
 	}
 
-	private void searchDirs(File dirName) {
-		if (dirName.isDirectory()) {
-			// So far so good
-			File[] modList = dirName.listFiles();
-			for (int x = 0; x < modList.length; x++) {
-				File pFile = new File(modList[x].getAbsoluteFile()
-						+ "/project.xml");
-				if (pFile.exists() && pFile.isFile()) {
-					projectXmls.add(pFile);
-				} else {
-					if (modList[x].isDirectory())
-						searchDirs(modList[x]);
-				}
-			}
-		}
-	}
+	// Lifted this from org.apache.geronimo.system.repository.Maven1Repository
+	// (originally from Brett Porter)
+	private static final Pattern MAVEN_1_PATTERN = Pattern
+			.compile("(.+)-([0-9].+)\\.*");
 
-	// Lifted this from org.apache.geronimo.system.repository.Maven1Repository (originally from
Brett Porter)
-	private static final Pattern MAVEN_1_PATTERN = Pattern.compile("(.+)-([0-9].+)\\.*");
-	
+	/**
+	 * Used to explore the external Maven repositories looking for latest
+	 * versions of jars.
+	 */
 	private String[] getJarInfo(Dependency dependency) {
 		String mavenSiteUrl = "http://www.ibiblio.com/maven/";
 		URL compositeUrl = null;
 		String url = mavenSiteUrl;
-		Pattern aRefPattern = Pattern.compile("<A HREF=\".*\">", 	Pattern.CASE_INSENSITIVE);
-		Pattern artifactPattern = Pattern.compile("</A>.*", 	Pattern.CASE_INSENSITIVE);
+		Pattern aRefPattern = Pattern.compile("<A HREF=\".*\">",
+				Pattern.CASE_INSENSITIVE);
+		Pattern artifactPattern = Pattern.compile("</A>.*",
+				Pattern.CASE_INSENSITIVE);
 
 		try {
 			url += dependency.groupId + "/" + dependency.type + "s";
@@ -224,32 +266,35 @@
 			System.out.println("Connection opened...");
 			data = new DataInputStream(new BufferedInputStream(conn
 					.getInputStream()));
-			
+
 			System.out.println("Reading data...");
 			while ((line = data.readLine()) != null) {
 				buf.append(line + "\n");
 			}
-		
-			String [] arefMatch = aRefPattern.split(buf);
-			
+
+			String[] arefMatch = aRefPattern.split(buf);
+
 			Matcher matcher = MAVEN_1_PATTERN.matcher("");
-			
-			for (int y=0; y< arefMatch.length; y++) {
+
+			for (int y = 0; y < arefMatch.length; y++) {
 				if (arefMatch[y].startsWith(dependency.artifactId)) {
-					String [] t = artifactPattern.split(arefMatch[y]);
-					if (t[0].endsWith("sha1") || t[0].endsWith("md5") || t[0].endsWith("asc")) continue;
+					String[] t = artifactPattern.split(arefMatch[y]);
+					if (t[0].endsWith("sha1") || t[0].endsWith("md5")
+							|| t[0].endsWith("asc"))
+						continue;
 					System.out.println(t[0]);
 					matcher.reset(t[0]);
-		             if (matcher.matches() && matcher.group(1).equals(dependency.artifactId))
{
-		            	     String m = matcher.group(2);
-		            	     for (int z=m.length()-1; z>0; z--) {
-		            	    	   if (m.charAt(z) == '.') { 
-		            	    		   m = m.substring(0,z);
-		            	    		   break;
-		            	    	   }
-		            	     }
-		            	     System.out.println(m);
-		             }
+					if (matcher.matches()
+							&& matcher.group(1).equals(dependency.artifactId)) {
+						String m = matcher.group(2);
+						for (int z = m.length() - 1; z > 0; z--) {
+							if (m.charAt(z) == '.') {
+								m = m.substring(0, z);
+								break;
+							}
+						}
+						System.out.println(m);
+					}
 				}
 			}
 			System.out.println();
@@ -260,7 +305,6 @@
 		return new String[3];
 	}
 
-
 	class MavenXMLHandler extends DefaultHandler {
 		public void startDocument() throws SAXException {
 		}
@@ -325,16 +369,20 @@
 
 	class Dependency {
 		String groupId = null;
+
 		String artifactId = null;
+
 		String version = null;
+
 		String type = null;
+
 		String project = null;
 
 		Dependency() {
 		}
 
-		Dependency(String project, String groupId,
-				String artifactId, String version, String type) {
+		Dependency(String project, String groupId, String artifactId,
+				String version, String type) {
 			this.project = project;
 			this.groupId = groupId;
 			this.artifactId = artifactId;



Mime
View raw message