geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcco...@apache.org
Subject svn commit: r575055 - in /geronimo/devtools/eclipse-plugin/branches/2.0.0: eclipse/build.xml plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java
Date Wed, 12 Sep 2007 20:01:33 GMT
Author: mcconne
Date: Wed Sep 12 13:01:32 2007
New Revision: 575055

URL: http://svn.apache.org/viewvc?rev=575055&view=rev
Log:
GERONIMODEVTOOLS-202 Fix to correctly detect versions for Geroniom 2.x

Modified:
    geronimo/devtools/eclipse-plugin/branches/2.0.0/eclipse/build.xml
    geronimo/devtools/eclipse-plugin/branches/2.0.0/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java

Modified: geronimo/devtools/eclipse-plugin/branches/2.0.0/eclipse/build.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.0.0/eclipse/build.xml?rev=575055&r1=575054&r2=575055&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.0.0/eclipse/build.xml (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.0.0/eclipse/build.xml Wed Sep 12 13:01:32
2007
@@ -22,11 +22,14 @@
 <project name="EuropaArtifacts">
 
     <target name="init">
-        <property name="europa_download_url"    value="http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.3-200706251500/"/>
-        <property name="dtp_download_url"       value="http://www.eclipse.org/downloads/download.php?file=/datatools/downloads/1.5/"/>
-        <property name="emf_download_url"       value="http://www.eclipse.org/downloads/download.php?file=/modeling/emf/emf/downloads/drops/2.3.0/R200706262000/"/>
-        <property name="gef_download_url"       value="http://www.eclipse.org/downloads/download.php?file=/tools/gef/downloads/drops/R-3.3-200706281000/"/>
-        <property name="wtp_download_url"       value="http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R2.0/R-2.0-200706260303/"/>
+        <property name="base_url"               value="http://www.eclipse.org/downloads/download.php?file="/>
+        <property name="europa_win32_url"       value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
+        <property name="europa_linux_url"       value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
+        <property name="europa_macos_url"       value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
+        <property name="dtp_download_url"       value="${base_url}/datatools/downloads/1.5/"/>
+        <property name="emf_download_url"       value="${base_url}/modeling/emf/emf/downloads/drops/2.3.0/R200706262000/"/>
+        <property name="gef_download_url"       value="${base_url}/tools/gef/downloads/drops/R-3.3-200706281000/"/>
+        <property name="wtp_download_url"       value="${base_url}/webtools/downloads/drops/R2.0/R-2.0-200706260303/"/>
         <property name="europa_jee_win32"       value="eclipse-SDK-3.3-win32.zip"/>
         <property name="europa_jee_linux"       value="eclipse-SDK-3.3-linux-gtk.tar"/>
         <property name="europa_jee_macos"       value="eclipse-SDK-3.3-macosx-carbon.tar"/>
@@ -36,12 +39,13 @@
         <property name="emf_sdo" value="emf-sdo-xsd-SDK-2.3.0.zip"/>
         <property name="gef_sdk" value="GEF-SDK-3.3.zip"/>
         <property name="wtp_sdk" value="wtp-sdk-R-2.0-200706260303.zip"/>
+        <property name="protocol" value="&amp;r=1&amp;protocol=http"/>
     </target>
 
     <target name="win32" depends="init,common" description="Download Windows-specific
artifact(s)">
         <echo>Downloading ${europa_download_url}${europa_jee_win32}</echo>
         <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
-        <get src="${europa_download_url}${europa_jee_win32}&amp;r=1&amp;protocol=http"

+        <get src="${europa_win32_url}${europa_jee_win32}${protocol}"
              dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_win32}" 
              verbose="true"
              usetimestamp="true"/>
@@ -54,7 +58,7 @@
     <target name="linux" depends="init,common" description="Download Linux-specific artifact(s)">
         <echo>Downloading ${europa_download_url}${europa_jee_linux_gz}</echo>
         <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
-        <get src="${europa_download_url}${europa_jee_linux_gz}&amp;r=1&amp;protocol=http"

+        <get src="${europa_linux_url}${europa_jee_linux_gz}${protocol}"
              dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_linux_gz}" 
              verbose="true"
              usetimestamp="true"/>
@@ -68,7 +72,7 @@
     <target name="macos" depends="init,common" description="Download Mac-specific artifact(s)">
         <echo>Downloading ${europa_download_url}${europa_jee_macos_gz}</echo>
         <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
-        <get src="${europa_download_url}${europa_jee_macos_gz}&amp;r=1&amp;protocol=http"

+        <get src="${europa_macos_url}${europa_jee_macos_gz}${protocol}"
              dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_macos_gz}" 
              verbose="true"
              usetimestamp="true"/>
@@ -79,17 +83,17 @@
                dest="${LOCAL_M2_REPO}/eclipse"/>
     </target>
 
-    <target name="common" description="Download artifacts common to all OS'es">
+    <target name="common" depends="init" description="Download artifacts common to all
OS'es">
         <antcall target="dtp"/>
         <antcall target="emf"/> 
         <antcall target="gef"/> 
         <antcall target="wtp"/> 
     </target>
 
-    <target name="dtp" description="Download Data Tools Platform (DTP) artifact">
+    <target name="dtp" depends="init" description="Download Data Tools Platform (DTP)
artifact">
         <echo>Downloading ${dtp_download_url}${dtp_sdk}</echo>
         <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
-        <get src="${dtp_download_url}${dtp_sdk}&amp;r=1&amp;protocol=http" 
+        <get src="${dtp_download_url}${dtp_sdk}${protocol}"
              dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${dtp_sdk}" 
              verbose="true"
              usetimestamp="true"/>
@@ -99,10 +103,10 @@
                dest="${LOCAL_M2_REPO}/eclipse"/>
     </target>
 
-    <target name="emf" description="Download Eclipse Modeling Framework (EMF) artifact">
+    <target name="emf" depends="init" description="Download Eclipse Modeling Framework
(EMF) artifact">
         <echo>Downloading ${emf_download_url}${emf_sdo}</echo>
         <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
-        <get src="${emf_download_url}${emf_sdo}&amp;r=1&amp;protocol=http" 
+        <get src="${emf_download_url}${emf_sdo}${protocol}"
              dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${emf_sdo}" 
              verbose="true"
              usetimestamp="true"/>
@@ -112,10 +116,10 @@
                dest="${LOCAL_M2_REPO}/eclipse"/>
     </target>
 
-    <target name="gef" description="Download Graphical Editing Framework (GEF) artifact">
+    <target name="gef" depends="init" description="Download Graphical Editing Framework
(GEF) artifact">
         <echo>Downloading ${gef_download_url}${gef_sdk}</echo>
         <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
-        <get src="${gef_download_url}${gef_sdk}&amp;r=1&amp;protocol=http" 
+        <get src="${gef_download_url}${gef_sdk}${protocol}"
              dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${gef_sdk}" 
              verbose="true"
              usetimestamp="true"/>
@@ -125,10 +129,10 @@
                dest="${LOCAL_M2_REPO}/eclipse"/>
     </target>
 
-    <target name="wtp" description="Download Web Tools Platform (WTP) artifact">
+    <target name="wtp" depends="init" description="Download Web Tools Platform (WTP) artifact">
         <echo>Downloading ${wtp_download_url}${wtp_sdk}</echo>
         <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
-        <get src="${wtp_download_url}${wtp_sdk}&amp;r=1&amp;protocol=http" 
+        <get src="${wtp_download_url}${wtp_sdk}${protocol}"
              dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${wtp_sdk}" 
              verbose="true"
              usetimestamp="true"/>

Modified: geronimo/devtools/eclipse-plugin/branches/2.0.0/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.0.0/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java?rev=575055&r1=575054&r2=575055&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.0.0/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java
(original)
+++ geronimo/devtools/eclipse-plugin/branches/2.0.0/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java
Wed Sep 12 13:01:32 2007
@@ -21,7 +21,9 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.geronimo.st.core.internal.Messages;
@@ -153,10 +155,13 @@
 	 */
 	public String detectVersion() {
 
+		URL systemjarURL = null;
+		//
+		// Check lib directory first
+		//
 		File libDir = getRuntime().getLocation().append("lib").toFile();
 		if (libDir.exists()) {
 			File[] libs = libDir.listFiles();
-			URL systemjarURL = null;
 			for (int i = 0; i < libs.length; i++) {
 				if (libs[i].getName().startsWith("geronimo-system")) {
 					try {
@@ -167,15 +172,35 @@
 					}
 				}
 			}
-			if (systemjarURL != null) {
-				URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL });
-				try {
-					Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants");
-					Method method = clazz.getMethod("getVersion", new Class[] {});
-					return (String) method.invoke(null, null);
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
+		}
+		// 
+		// Check repository if necessary
+		//
+                if (systemjarURL == null) {
+                    File systemDir = getRuntime().getLocation().append("repository/org/apache/geronimo/modules/geronimo-system").toFile();
+                    if (systemDir.exists() && systemDir.isDirectory() &&
systemDir.canRead()) {
+                        List<File> dirFiles = scanDirectory(systemDir);
+                        for (File jarFile : dirFiles) {
+                            if (jarFile.getName().startsWith("geronimo-system") &&
jarFile.getName().endsWith("jar")) {
+                                try {
+                                    systemjarURL = jarFile.toURL();
+                                    break;
+                                }
+                                catch (MalformedURLException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+                    }
+                }
+		if (systemjarURL != null) {
+			URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL });
+			try {
+				Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants");
+				Method method = clazz.getMethod("getVersion", new Class[] {});
+				return (String) method.invoke(null, null);
+			} catch (Exception e) {
+				e.printStackTrace();
 			}
 		}
 		return null;
@@ -273,4 +298,23 @@
 	public boolean isUsingDefaultJRE() {
 		return getVMInstallTypeId() == null;
 	}
+
+        private static List<File> scanDirectory(File dir) {
+            List<File> dirFiles = new ArrayList<File>();
+            scanDirectory(dir, dirFiles);
+            return dirFiles;
+        }
+
+        private static void scanDirectory(File dir, List<File> dirFiles) {
+            File[] files = dir.listFiles();
+            for (int ii = 0; ii < files.length; ii++) {
+                if (files[ii].isDirectory()) {
+                    scanDirectory(files[ii], dirFiles);
+                }
+                else {
+                    dirFiles.add(files[ii]);    
+                }
+            }
+        }
+        
 }



Mime
View raw message