Skip to content

Commit cb058df

Browse files
author
Tim McConnell
committed
GERONIMODEVTOOLS-202 Fix to correctly detect versions for Geroniom 2.x
git-svn-id: https://svn.apache.org/repos/asf/geronimo/devtools/eclipse-plugin/branches/2.0.0@575055 13f79535-47bb-0310-9956-ffa450edef68
1 parent 2ecec1b commit cb058df

File tree

2 files changed

+75
-27
lines changed

2 files changed

+75
-27
lines changed

eclipse/build.xml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
<project name="EuropaArtifacts">
2323

2424
<target name="init">
25-
<property name="europa_download_url" value="http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.3-200706251500/"/>
26-
<property name="dtp_download_url" value="http://www.eclipse.org/downloads/download.php?file=/datatools/downloads/1.5/"/>
27-
<property name="emf_download_url" value="http://www.eclipse.org/downloads/download.php?file=/modeling/emf/emf/downloads/drops/2.3.0/R200706262000/"/>
28-
<property name="gef_download_url" value="http://www.eclipse.org/downloads/download.php?file=/tools/gef/downloads/drops/R-3.3-200706281000/"/>
29-
<property name="wtp_download_url" value="http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R2.0/R-2.0-200706260303/"/>
25+
<property name="base_url" value="http://www.eclipse.org/downloads/download.php?file="/>
26+
<property name="europa_win32_url" value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
27+
<property name="europa_linux_url" value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
28+
<property name="europa_macos_url" value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
29+
<property name="dtp_download_url" value="${base_url}/datatools/downloads/1.5/"/>
30+
<property name="emf_download_url" value="${base_url}/modeling/emf/emf/downloads/drops/2.3.0/R200706262000/"/>
31+
<property name="gef_download_url" value="${base_url}/tools/gef/downloads/drops/R-3.3-200706281000/"/>
32+
<property name="wtp_download_url" value="${base_url}/webtools/downloads/drops/R2.0/R-2.0-200706260303/"/>
3033
<property name="europa_jee_win32" value="eclipse-SDK-3.3-win32.zip"/>
3134
<property name="europa_jee_linux" value="eclipse-SDK-3.3-linux-gtk.tar"/>
3235
<property name="europa_jee_macos" value="eclipse-SDK-3.3-macosx-carbon.tar"/>
@@ -36,12 +39,13 @@
3639
<property name="emf_sdo" value="emf-sdo-xsd-SDK-2.3.0.zip"/>
3740
<property name="gef_sdk" value="GEF-SDK-3.3.zip"/>
3841
<property name="wtp_sdk" value="wtp-sdk-R-2.0-200706260303.zip"/>
42+
<property name="protocol" value="&amp;r=1&amp;protocol=http"/>
3943
</target>
4044

4145
<target name="win32" depends="init,common" description="Download Windows-specific artifact(s)">
4246
<echo>Downloading ${europa_download_url}${europa_jee_win32}</echo>
4347
<mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
44-
<get src="${europa_download_url}${europa_jee_win32}&amp;r=1&amp;protocol=http"
48+
<get src="${europa_win32_url}${europa_jee_win32}${protocol}"
4549
dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_win32}"
4650
verbose="true"
4751
usetimestamp="true"/>
@@ -54,7 +58,7 @@
5458
<target name="linux" depends="init,common" description="Download Linux-specific artifact(s)">
5559
<echo>Downloading ${europa_download_url}${europa_jee_linux_gz}</echo>
5660
<mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
57-
<get src="${europa_download_url}${europa_jee_linux_gz}&amp;r=1&amp;protocol=http"
61+
<get src="${europa_linux_url}${europa_jee_linux_gz}${protocol}"
5862
dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_linux_gz}"
5963
verbose="true"
6064
usetimestamp="true"/>
@@ -68,7 +72,7 @@
6872
<target name="macos" depends="init,common" description="Download Mac-specific artifact(s)">
6973
<echo>Downloading ${europa_download_url}${europa_jee_macos_gz}</echo>
7074
<mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
71-
<get src="${europa_download_url}${europa_jee_macos_gz}&amp;r=1&amp;protocol=http"
75+
<get src="${europa_macos_url}${europa_jee_macos_gz}${protocol}"
7276
dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_macos_gz}"
7377
verbose="true"
7478
usetimestamp="true"/>
@@ -79,17 +83,17 @@
7983
dest="${LOCAL_M2_REPO}/eclipse"/>
8084
</target>
8185

82-
<target name="common" description="Download artifacts common to all OS'es">
86+
<target name="common" depends="init" description="Download artifacts common to all OS'es">
8387
<antcall target="dtp"/>
8488
<antcall target="emf"/>
8589
<antcall target="gef"/>
8690
<antcall target="wtp"/>
8791
</target>
8892

89-
<target name="dtp" description="Download Data Tools Platform (DTP) artifact">
93+
<target name="dtp" depends="init" description="Download Data Tools Platform (DTP) artifact">
9094
<echo>Downloading ${dtp_download_url}${dtp_sdk}</echo>
9195
<mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
92-
<get src="${dtp_download_url}${dtp_sdk}&amp;r=1&amp;protocol=http"
96+
<get src="${dtp_download_url}${dtp_sdk}${protocol}"
9397
dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${dtp_sdk}"
9498
verbose="true"
9599
usetimestamp="true"/>
@@ -99,10 +103,10 @@
99103
dest="${LOCAL_M2_REPO}/eclipse"/>
100104
</target>
101105

102-
<target name="emf" description="Download Eclipse Modeling Framework (EMF) artifact">
106+
<target name="emf" depends="init" description="Download Eclipse Modeling Framework (EMF) artifact">
103107
<echo>Downloading ${emf_download_url}${emf_sdo}</echo>
104108
<mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
105-
<get src="${emf_download_url}${emf_sdo}&amp;r=1&amp;protocol=http"
109+
<get src="${emf_download_url}${emf_sdo}${protocol}"
106110
dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${emf_sdo}"
107111
verbose="true"
108112
usetimestamp="true"/>
@@ -112,10 +116,10 @@
112116
dest="${LOCAL_M2_REPO}/eclipse"/>
113117
</target>
114118

115-
<target name="gef" description="Download Graphical Editing Framework (GEF) artifact">
119+
<target name="gef" depends="init" description="Download Graphical Editing Framework (GEF) artifact">
116120
<echo>Downloading ${gef_download_url}${gef_sdk}</echo>
117121
<mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
118-
<get src="${gef_download_url}${gef_sdk}&amp;r=1&amp;protocol=http"
122+
<get src="${gef_download_url}${gef_sdk}${protocol}"
119123
dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${gef_sdk}"
120124
verbose="true"
121125
usetimestamp="true"/>
@@ -125,10 +129,10 @@
125129
dest="${LOCAL_M2_REPO}/eclipse"/>
126130
</target>
127131

128-
<target name="wtp" description="Download Web Tools Platform (WTP) artifact">
132+
<target name="wtp" depends="init" description="Download Web Tools Platform (WTP) artifact">
129133
<echo>Downloading ${wtp_download_url}${wtp_sdk}</echo>
130134
<mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
131-
<get src="${wtp_download_url}${wtp_sdk}&amp;r=1&amp;protocol=http"
135+
<get src="${wtp_download_url}${wtp_sdk}${protocol}"
132136
dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${wtp_sdk}"
133137
verbose="true"
134138
usetimestamp="true"/>

plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import java.net.MalformedURLException;
2222
import java.net.URL;
2323
import java.net.URLClassLoader;
24+
import java.util.ArrayList;
2425
import java.util.HashMap;
26+
import java.util.List;
2527
import java.util.Map;
2628

2729
import org.apache.geronimo.st.core.internal.Messages;
@@ -153,10 +155,13 @@ public void setRuntimeSourceLocation(String path) {
153155
*/
154156
public String detectVersion() {
155157

158+
URL systemjarURL = null;
159+
//
160+
// Check lib directory first
161+
//
156162
File libDir = getRuntime().getLocation().append("lib").toFile();
157163
if (libDir.exists()) {
158164
File[] libs = libDir.listFiles();
159-
URL systemjarURL = null;
160165
for (int i = 0; i < libs.length; i++) {
161166
if (libs[i].getName().startsWith("geronimo-system")) {
162167
try {
@@ -167,15 +172,35 @@ public String detectVersion() {
167172
}
168173
}
169174
}
170-
if (systemjarURL != null) {
171-
URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL });
172-
try {
173-
Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants");
174-
Method method = clazz.getMethod("getVersion", new Class[] {});
175-
return (String) method.invoke(null, null);
176-
} catch (Exception e) {
177-
e.printStackTrace();
178-
}
175+
}
176+
//
177+
// Check repository if necessary
178+
//
179+
if (systemjarURL == null) {
180+
File systemDir = getRuntime().getLocation().append("repository/org/apache/geronimo/modules/geronimo-system").toFile();
181+
if (systemDir.exists() && systemDir.isDirectory() && systemDir.canRead()) {
182+
List<File> dirFiles = scanDirectory(systemDir);
183+
for (File jarFile : dirFiles) {
184+
if (jarFile.getName().startsWith("geronimo-system") && jarFile.getName().endsWith("jar")) {
185+
try {
186+
systemjarURL = jarFile.toURL();
187+
break;
188+
}
189+
catch (MalformedURLException e) {
190+
e.printStackTrace();
191+
}
192+
}
193+
}
194+
}
195+
}
196+
if (systemjarURL != null) {
197+
URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL });
198+
try {
199+
Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants");
200+
Method method = clazz.getMethod("getVersion", new Class[] {});
201+
return (String) method.invoke(null, null);
202+
} catch (Exception e) {
203+
e.printStackTrace();
179204
}
180205
}
181206
return null;
@@ -273,4 +298,23 @@ public String getVMInstallId() {
273298
public boolean isUsingDefaultJRE() {
274299
return getVMInstallTypeId() == null;
275300
}
301+
302+
private static List<File> scanDirectory(File dir) {
303+
List<File> dirFiles = new ArrayList<File>();
304+
scanDirectory(dir, dirFiles);
305+
return dirFiles;
306+
}
307+
308+
private static void scanDirectory(File dir, List<File> dirFiles) {
309+
File[] files = dir.listFiles();
310+
for (int ii = 0; ii < files.length; ii++) {
311+
if (files[ii].isDirectory()) {
312+
scanDirectory(files[ii], dirFiles);
313+
}
314+
else {
315+
dirFiles.add(files[ii]);
316+
}
317+
}
318+
}
319+
276320
}

0 commit comments

Comments
 (0)