| |
| [ Blog ] [ Open Source ] [ Programming ] | |
« setLocationRelativeTo | Main | Using local Javadoc in JDeveloper 10.1.3 »
I was asked how to list the versions of the extensions located in a given JDeveloper install directory, so here is a short example of how to do this from outside of JDeveloper. I'm sure I'll get a comment from Brian telling me I should use XPath in here, but version is pretty trivial to get without it.
package jdev.test;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import oracle.xml.parser.v2.DOMParser;
import org.xml.sax.SAXException;
public class ExtensionVersions {
public static void main(String[] args) {
File jdevhome = new File("C:\\jdev\\jdevstudio1013_3412");
File exthome = new File(jdevhome, "jdev\\extensions");
File[] jars = exthome.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName()
.toLowerCase(Locale.ENGLISH)
.endsWith(".jar");
}
}
);
for (File jar : jars) {
String version = getExtensionVersion(jar);
System.out.printf( "file: [%s] version: [%s]\n", jar.getName(), version );
}
}
private static String getExtensionVersion(File jar) {
try {
ZipFile zf = new ZipFile(jar);
ZipEntry ze = zf.getEntry("META-INF/extension.xml");
if (ze != null) {
DOMParser parser = new DOMParser();
parser.parse(zf.getInputStream(ze));
return parser.getDocument().getDocumentElement().getAttributeNS(null, "version");
}
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
return "(unknown)";
}
}
Posted by rcleveng at October 12, 2005 07:55 AM
There's been words, plans, discussions and code on Subversion support for JDeveloper. It's underway in development as we speak. We've got the JavaHL and commandline wrappers in place, and starting to work on some operations. I'm hoping to release it on Check for Updates (in beta form) after JDeveloper 10.1.3 production.
Rob
Posted by: Rob at October 15, 2005 09:34 AM
Has there been any word of a subversion plugin for JDeveloper? I was considering writing one myself (after noticing the June 2004 link: http://www.robsite.org/archives/2004/06/integrating_a_s.html ), but I wanted to make sure someone else's work wouldn't be duplicated. Thanks.
Posted by: Scott Van Wart at October 14, 2005 10:44 PM
I knew it. I knew you would do that ;-)
- Rob
Posted by: Rob at October 13, 2005 11:59 AM
Dude.
You should use xpath.
;)
Posted by: Brian Duff at October 13, 2005 03:31 AM