Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 20090 invoked from network); 10 Aug 2006 15:10:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Aug 2006 15:10:35 -0000 Received: (qmail 8387 invoked by uid 500); 10 Aug 2006 15:10:27 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 8352 invoked by uid 500); 10 Aug 2006 15:10:27 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 8283 invoked by uid 99); 10 Aug 2006 15:10:25 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Aug 2006 08:10:25 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Aug 2006 08:10:22 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 433CC1A981A; Thu, 10 Aug 2006 08:09:55 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: hogstrom@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060810150955.433CC1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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("", Pattern.CASE_INSENSITIVE); - Pattern artifactPattern = Pattern.compile(".*", Pattern.CASE_INSENSITIVE); + Pattern aRefPattern = Pattern.compile("", + Pattern.CASE_INSENSITIVE); + Pattern artifactPattern = Pattern.compile(".*", + 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;