1 21 22 package org.apache.derbyBuild.eclipse; 23 24 import java.util.*; 25 import java.io.File ; 26 import java.io.FileOutputStream ; 27 import java.io.FileWriter ; 28 import java.io.InputStream ; 29 import org.apache.derby.iapi.services.info.ProductGenusNames; 30 import org.apache.derby.iapi.services.info.PropertyNames; 31 32 57 public class DerbyEclipsePlugin{ 58 61 private static String PLUGIN_PKG="plugin.derby.core"; 62 private static String PLUGIN_PKG_NAME="org.apache.derby.core"; 63 66 private static String PLUGIN_ZIP_FILE="plugin.derby.core.zipfile"; 67 private static String PLUGIN_ZIP_FILE_NAME="derby_core_plugin"; 68 71 private static String PLUGIN_VERSION="plugin.derby.version"; 72 private static String PLUGIN_VERSION_BUILD_NUMBER="plugin.derby.version.build.number"; 73 private static int MAINT_DIV=1000000; 74 75 78 private static String part_1="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ 79 "<?eclipse version=\"3.0\"?> \n"+ 80 "<plugin \n" + 81 "\t id=\"org.apache.derby.core\" \n" + 82 "\t name=\"Apache Derby Core Plug-in for Eclipse\" \n" + 83 "\t version=\""; 84 85 private static String part_2="\n\t provider-name=\""; 86 private static String part_3="\n\t <runtime> \n" + 87 "\t\t <library name=\"derby.jar\"> \n" + 88 "\t\t\t <export name=\"*\"/> \n" + 89 "\t\t </library> \n" + 90 "\t\t <library name=\"derbyclient.jar\"> \n" + 91 "\t\t\t <export name=\"*\"/> \n" + 92 "\t\t </library> \n" + 93 "\t\t <library name=\"derbytools.jar\"> \n" + 94 "\t\t\t <export name=\"*\"/> \n"+ 95 "\t\t </library> \n"+ 96 "\t\t <library name=\"derbynet.jar\"> \n"+ 97 "\t\t\t <export name=\"*\"/> \n"+ 98 "\t\t </library> \n"+ 99 "\t </runtime> \n"+ 100 "\t <requires> \n"+ 101 "\t </requires> \n"+ 102 "</plugin>"; 103 104 private String version=""; 105 private String tmpPropFile="plugintmp.properties"; 106 private static File tmpFileLocation=null; 107 private static Properties tmpProp=new Properties(); 108 private String pluginXMLFile="plugin.xml"; 109 110 117 118 public static void main(String [] args){ 119 if(args.length<=0){ 120 System.out.println("Incorrect number of arguments."); 121 return; 122 } 123 try{ 124 tmpFileLocation=new File (args[0]); 125 DerbyEclipsePlugin dep = new DerbyEclipsePlugin(); 126 dep.getProps(); 127 dep.createTmpFiles(); 128 }catch(Exception e) 129 { 130 e.printStackTrace(); 131 } 132 133 134 135 136 } 137 143 private void getProps() throws Exception { 144 InputStream versionStream = getClass().getResourceAsStream(ProductGenusNames.DBMS_INFO); 145 Properties prop=new Properties(); 146 prop.load(versionStream); 147 148 tmpProp.put(PLUGIN_PKG,PLUGIN_PKG_NAME); tmpProp.put(PLUGIN_ZIP_FILE,PLUGIN_ZIP_FILE_NAME); tmpProp.put(PropertyNames.PRODUCT_VENDOR_NAME,prop.getProperty(PropertyNames.PRODUCT_VENDOR_NAME)); 152 int maint=Integer.parseInt(prop.getProperty(PropertyNames.PRODUCT_MAINT_VERSION)); 153 version=prop.getProperty(PropertyNames.PRODUCT_MAJOR_VERSION)+"."+prop.getProperty(PropertyNames.PRODUCT_MINOR_VERSION)+"."+maint/MAINT_DIV; 154 tmpProp.put(PLUGIN_VERSION,version); 155 156 161 version+="."+maint%MAINT_DIV; 162 tmpProp.put(PLUGIN_VERSION_BUILD_NUMBER,version+" ("+prop.getProperty(PropertyNames.PRODUCT_BUILD_NUMBER)+")"); 163 164 part_1+=version+"\""; 166 part_2+=tmpProp.getProperty(PropertyNames.PRODUCT_VENDOR_NAME)+"\">\n"; 167 168 } 169 175 private void createTmpFiles() throws Exception { 176 File file=new File (tmpFileLocation.getAbsolutePath()+File.separator+tmpPropFile); 177 FileOutputStream fo=new FileOutputStream (file); 178 tmpProp.store(fo,null); 179 fo.close(); 180 file=new File (tmpFileLocation.getAbsolutePath()+File.separator+pluginXMLFile); 181 FileWriter fw=new FileWriter (file); 182 fw.write(part_1+part_2+part_3); 183 fw.close(); 184 185 } 186 } 187 188 | Popular Tags |