Great.  Can you augment this to be applied to a copy of the launcher
code we'll keep in the DRLVM tree?  And maybe a simpler buildfile that
isn't a part of the DRLVM build infrastructure? (which we want to get
away from...)

geir


Salikh Zakirov wrote:
> Hi,
> 
> I have been reviewing the DRLVM JIRA issues, and came across
> HARMONY-699 "[DRLVM] modification to eclipse plugin should be applied to 
> plugin itself"
> 
> So I took the hyplugin.patch from DRLVM distribution and applied the changes
> to plugin source tree, taking into account, that DRLVM executable is no 
> longer ij.exe,
> but plain java.exe.
> 
> Then I have tried to run the modified plugin, and found out that it does not 
> find
> kernel jar files by default, because DRLVM does not provide some property file
> (default location that is searched from is 
> 'jre/bin/default/clearvm.properties',
> which looks pretty similar to the default -vm -vmdir arguments of the 
> launcher).
> Anyway, DRLVM does not provide property files for kernel files 
> (* and I personally do not like them *),
> so I figured it would be reasonable to provide a reasonable default coded 
> right
> into the plugin code.
> 
> The resulting patch is provided below for review.
> (HARMONY-699 has the same changes in two patches).
> 
> Could you please review the modifications and commit the changes if there are
> no objections? This will allow to remove custom plugin build from DRLVM.
> 
> The plugin works okay on my Windows/ia32 laptop.
> 
> Thanks a lot!
> 
> 
> --- /dev/null
> +++ eclipse/org.apache.harmony.eclipse.jdt.launching/build.xml
> @@ -0,0 +1,74 @@
> +<?xml version="1.0" encoding="ISO-8859-1"?>
> +<!--
> +    Copyright 2005-2006 The Apache Software Foundation or its licensors, as 
> applicable.
> +  
> +    Licensed under the Apache License, Version 2.0 (the "License");
> +    you may not use this file except in compliance with the License.
> +    You may obtain a copy of the License at
> +  
> +       http://www.apache.org/licenses/LICENSE-2.0
> +  
> +    Unless required by applicable law or agreed to in writing, software
> +    distributed under the License is distributed on an "AS IS" BASIS,
> +    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +    See the License for the specific language governing permissions and
> +    limitations under the License.
> +-->
> +<project name="hyplugin" default="build">
> +
> +    <target name="init">
> +      <property name="build.dir" value="bin"/>
> +      <property name="jar.name" 
> value="${build.dir}/org.apache.harmony.eclipse.jdt.launching_1.0.0.jar" />
> +    </target>
> +
> +    <target name="find.eclipse">
> +
> +      <property environment="env"/>
> +      <available property="eclipse.home" value="${env.ECLIPSE_HOME}"
> +     file="${env.ECLIPSE_HOME}/startup.jar"/>
> +      <fail unless="eclipse.home">Error:
> +     Can't find eclipse home.
> +     Please set the environment variable ECLIPSE_HOME to Eclipse location
> +     or pass it as the property -Declipse.home=...
> +      </fail>
> +
> +      <path id="java.class.path">
> +     <fileset dir="${java.home}" includes="**/*.jar" />
> +     <fileset dir="${eclipse.home}" includes="**/*.jar" />
> +      </path>
> +
> +    </target>
> +
> +    <target name="build" depends="init, find.eclipse">
> +      <mkdir dir="${build.dir}"/>
> +      <javac destdir="${build.dir}"
> +     debug="yes"
> +     classpathref="java.class.path"
> +     srcdir="src"
> +     includes="**/*.java"/>
> +
> +      <jar destfile="${jar.name}" manifest="META-INF/MANIFEST.MF">
> +     <fileset dir="${build.dir}">
> +       <include name="**/*.class"/>
> +     </fileset>
> +     <fileset dir="src">
> +       <include name="**/*.properties"/>
> +     </fileset>
> +     <fileset dir="." includes="plugin.xml"/>
> +      </jar>
> +    </target>
> +
> +    <target name="clean" depends="init">
> +      <delete dir="${build.dir}"/>
> +    </target>
> +
> +    <target name="install" depends="init, find.eclipse">
> +      <available file="${jar.name}" property="jar.built"/>
> +      <fail unless="jar.built">
> +     Can't find built jar file ${jar.name}. 
> +     Please run 'ant build' first
> +      </fail>
> +      <copy file="${jar.name}" todir="${eclipse.home}/plugins"/>
> +    </target>
> +    
> +</project>
> diff --git 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java
>  
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java
> old mode 100644
> new mode 100755
> index 645f92e..c49f850
> --- 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java
> +++ 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java
> @@ -22,8 +22,14 @@ public class HyLauncherMessages {
>  
>       private static final String RESOURCE_BUNDLE = 
> "org.apache.harmony.eclipse.jdt.launching.HyLauncherMessages"; //$NON-NLS-1$
>  
> -     private static ResourceBundle resourceBundle = ResourceBundle
> -                     .getBundle(RESOURCE_BUNDLE);
> +     private static ResourceBundle resourceBundle;
> +     static {
> +             try {
> +                     resourceBundle = 
> ResourceBundle.getBundle(RESOURCE_BUNDLE);
> +             } catch (MissingResourceException e) {
> +                     System.err.println("Can't load resource bundle " + 
> RESOURCE_BUNDLE);
> +             }
> +     }
>  
>       private HyLauncherMessages() {
>               super();
> @@ -32,7 +38,7 @@ public class HyLauncherMessages {
>       public static String getString(String key) {
>               try {
>                       return resourceBundle.getString(key);
> -             } catch (MissingResourceException e) {
> +             } catch (Exception e) {
>                       return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
>               }
>       }
> diff --git 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java
>  
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java
> index 495ac1e..bf77850 100644
> --- 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java
> +++ 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java
> @@ -65,6 +65,9 @@ public class HyLaunchingPlugin extends P
>       }
>  
>       public static HyLaunchingPlugin getDefault() {
> +        if (plugin == null) {
> +            plugin = new HyLaunchingPlugin();
> +        }
>               return plugin;
>       }
>  
> diff --git 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java
>  
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java
> old mode 100644
> new mode 100755
> index 90364b8..c6dbf76
> --- 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java
> +++ 
> eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java
> @@ -91,9 +91,6 @@ public class HyVMInstallType extends Abs
>        * @see org.eclipse.jdt.launching.IVMInstallType#detectInstallLocation()
>        */
>       public File detectInstallLocation() {
> -             // Try to detect wether the current VM is a Harmony 
> installation.
> -             if 
> (!"clear".equals(System.getProperty("com.ibm.oti.configuration", "missing"))) 
> //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
> -                     return null;
>  
>               File home = new File(System.getProperty("java.home")); 
> //$NON-NLS-1$
>               IStatus status = validateInstallLocation(home);
> @@ -345,9 +342,21 @@ public class HyVMInstallType extends Abs
>                       kernelProperties.load(propsFile);
>                       propsFile.close();
>               } catch (IOException ex) {
> -                     System.out
> -                                     .println("Warning: could not open 
> properties file " + propertyFile.getPath()); //$NON-NLS-1$
> -                     return null;
> +                     // Can't open VM-specific properties file, 
> +                     // fall back to hardcoded default of lib/boot/kernel.jar
> +                     List kernelLibraries = new ArrayList();
> +                     File libraryFile = new File(installLocation, 
> +                             "lib" + File.separator + "boot" + 
> File.separator + "kernel.jar");
> +                     IPath libraryPath;
> +                     try {
> +                             libraryPath = new 
> Path(libraryFile.getCanonicalPath());
> +                     } catch (IOException e) {
> +                             libraryPath = new Path(libraryFile.getPath());
> +                     }
> +                     LibraryLocation libLocation = 
> +                             new LibraryLocation(libraryPath, Path.EMPTY, 
> Path.ROOT);
> +                     kernelLibraries.add(libLocation);
> +                     return kernelLibraries;
>               }
>               
>               // If we have a VME v1 style kernel (ie single kernel) then 
> read its location
> 
> 
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to