Hello all,
As per my earlier mail regarding the need for a Derby plugin for Eclipse, the following are the suggested changes.
1) additions to the main 'build.xml' 2) a simple Java file used in the plug-in build process
Using the above changes: - will serve as a permanent solution for building the plug-in - the plug-in build will always track the Derby versioning
To create a plug-in build (once the above changes are integrated): - use 'ant' to compile all classes - use 'ant plugin' to create the Derby plug-in zip
The 'derby_eclipse_plug-in.zip' will be created in the jars/insane directory along with all the other Apache Derby jars.
Eventually I suggest, Apache could have an update site for the Derby plug-in where the latest version can be downloaded using the
Eclipse Update Manager.
Please review these changes and do let me know if there are any questions/suggestions.
Regards, Rajesh
CHANGES: ========== 1) Additions to the main 'build.xml'
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<!-- =================================================================== -->
<!-- Eclipse Plugin -->
<!-- =================================================================== -->
<target name="plugin" depends= "buildjars">
<echo message="Begining Derby Eclipse plugin build"/>
<property name="plugin.tmp.dir" value ="plugintmp"/>
<mkdir dir="${derby.jar.dir}/${plugin.tmp.dir}"/>
<java classname="org.apache.derbyBuild.plugin.DerbyEclipsePlugin">
<arg value="${derby.jar.dir}/${plugin.tmp.dir}"/>
<classpath>
<pathelement path="${out.dir}"/>
</classpath>
</java>
<property file="${derby.jar.dir}/${plugin.tmp.dir}/plugintmp.properties"/>
<echo message="Derby Eclipse plugin build ${plugin.major}.${plugin.minor}.${plugin.maint}"/>
<property name="plugin.dir" value ="plugins"/>
<property name="plugin.core.dir" value ="org.apache.derby.core_${plugin.major}.${plugin.minor}.${plugin.maint}"/>
<mkdir dir="${derby.jar.dir}/${plugin.tmp.dir}/${plugin.dir}/${plugin.core.dir}"/>
<copy todir="${derby.jar.dir}/${plugin.tmp.dir}/${plugin.dir}/${plugin.core.dir}">
<fileset dir="${derby.jar.dir}" includes="derby*.jar"/>
</copy>
<copy todir="${derby.jar.dir}/${plugin.tmp.dir}/${plugin.dir}/${plugin.core.dir}">
<fileset dir="${derby.jar.dir}/${plugin.tmp.dir}" includes="plugin*.xml"/>
</copy>
<delete file="${derby.jar.dir}/${plugin.tmp.dir}/plugintmp.properties"/>
<delete file="${derby.jar.dir}/${plugin.tmp.dir}/plugin.xml"/>
<!-- ZIP to create the final Derby plug-in -->
<zip zipfile="${derby.jar.dir}/derby_eclipse_plug-in.zip" compress="true" basedir="${derby.jar.dir}/${plugin.tmp.dir}"/>
<delete dir="${derby.jar.dir}/${plugin.tmp.dir}"/>
</target>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2) A simple Java file used in the plug-in build process
The Java file DerbyEclipsePlugin.java can be placed in a org.apache.derbyBuild.plugin package under the java/build directory
Java file attached....
package org.apache.derbyBuild.plugin;
import java.util.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import org.apache.derby.iapi.services.info.ProductGenusNames;
import org.apache.derby.iapi.services.info.PropertyNames;
public class DerbyEclipsePlugin{
private static String MAJOR="plugin.major";
private static String MINOR="plugin.minor";
private static String MAINT="plugin.maint";
private static int MAINT_DIV=1000000;
private static String part_1="<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"+
"<?eclipse version=\"3.0\"?> \n"+
"<plugin \n" +
"\t id=\"org.apache.derby.core\" \n" +
"\t name=\"Apache Derby Core Plug-in\"
\n" +
"\t version=\"";
private static String part_2="\n\t provider-name=\"";
private static String part_3="\n\t <runtime> \n" +
"\t\t <library name=\"derby.jar\"> \n" +
"\t\t\t <export name=\"*\"/> \n" +
"\t\t </library> \n" +
"\t\t <library name=\"derbytools.jar\">
\n"+
"\t\t\t <export name=\"*\"/> \n"+
"\t\t </library> \n"+
"\t\t <library name=\"derbynet.jar\"> \n"+
"\t\t\t <export name=\"*\"/> \n"+
"\t\t </library> \n"+
"\t </runtime> \n"+
"\t <requires> \n"+
"\t </requires> \n"+
"</plugin>";
private String tmpPropFile="plugintmp.properties";
private static File tmpFileLocation=null;
private String pluginXMLFile="plugin.xml";
private static Properties tmpProp=new Properties();
public static void main(String [] args){
if(args.length<=0){
System.out.println("Incorrect number of arguments...");
return;
}
try{
tmpFileLocation=new File(args[0]);
DerbyEclipsePlugin dep = new DerbyEclipsePlugin();
dep.getProps();
dep.createTmpFiles();
}catch(Exception e)
{
e.printStackTrace();
}
}
public void getProps() throws Exception{
InputStream versionStream =
getClass().getResourceAsStream(ProductGenusNames.DBMS_INFO);
Properties prop=new Properties();
prop.load(versionStream);
//create the tmp Prop file
tmpProp.put(MAJOR,prop.getProperty(PropertyNames.PRODUCT_MAJOR_VERSION));
tmpProp.put(MINOR,prop.getProperty(PropertyNames.PRODUCT_MINOR_VERSION));
int
maint=Integer.parseInt(prop.getProperty(PropertyNames.PRODUCT_MAINT_VERSION));
tmpProp.put(MAINT,maint/MAINT_DIV+"."+maint%MAINT_DIV);
tmpProp.put(PropertyNames.PRODUCT_VENDOR_NAME,prop.getProperty(PropertyNames.PRODUCT_VENDOR_NAME));
//add info to plugin.xml strings
part_1+=tmpProp.getProperty(MAJOR)+"."+tmpProp.getProperty(MINOR)+"."+tmpProp.getProperty(MAINT)+"\"";
part_2+=tmpProp.getProperty(PropertyNames.PRODUCT_VENDOR_NAME)+"\">\n";
}
public void createTmpFiles() throws Exception{
File file=new
File(tmpFileLocation.getAbsolutePath()+File.separator+tmpPropFile);
FileOutputStream fo=new FileOutputStream(file);
tmpProp.store(fo,null);
fo.close();
file=new
File(tmpFileLocation.getAbsolutePath()+File.separator+pluginXMLFile);
FileWriter fw=new FileWriter(file);
fw.write(part_1+part_2+part_3);
fw.close();
}
}
