| 1 |
import java.io.FileOutputStream; |
| 2 |
import java.io.ObjectOutput; |
| 3 |
import java.io.ObjectOutputStream; |
| 4 |
import java.io.OutputStream; |
| 5 |
|
| 6 |
import javax.xml.transform.Source; |
| 7 |
import javax.xml.transform.Templates; |
| 8 |
import javax.xml.transform.TransformerFactory; |
| 9 |
import javax.xml.transform.stream.StreamSource; |
| 10 |
|
| 11 |
import net.sourceforge.jeuclid.elements.support.operatordict.OperatorDictionary2; |
| 12 |
import net.sourceforge.jeuclid.elements.support.operatordict.OperatorDictionary3; |
| 13 |
import net.sourceforge.jeuclid.elements.support.text.CharacterMapping; |
| 14 |
|
| 15 |
File basedir = new File("${project.basedir}"); |
| 16 |
|
| 17 |
//log.info("Precompiling XSLT stylesheet..."); |
| 18 |
//try { |
| 19 |
// Source stylesheet = new StreamSource(new File(basedir,"target/classes/content/mathmlc2p.xsl")) |
| 20 |
// TransformerFactory factory = TransformerFactory.newInstance(); |
| 21 |
// factory.setAttribute("generate-translet", Boolean.TRUE); |
| 22 |
// factory.setAttribute("package-name", "translet"); |
| 23 |
// File destDir = new File(basedir,"target/classes"); |
| 24 |
// factory.setAttribute("destination-directory", destDir.getAbsolutePath()); |
| 25 |
// Templates templates = factory.newTemplates(stylesheet); |
| 26 |
// |
| 27 |
// OutputStream os = new FileOutputStream(new File(basedir,"target/classes/content/mathmlc2p.ser")); |
| 28 |
// ObjectOutput oo = new ObjectOutputStream(os); |
| 29 |
// oo.writeObject(templates); |
| 30 |
// oo.close(); |
| 31 |
//} catch (Exception e) { |
| 32 |
// log.info("Could not precompile stylesheet (optional step)"); |
| 33 |
// log.info("Reason: "+e.getMessage()); |
| 34 |
//} |
| 35 |
|
| 36 |
File newDict2 = new File(basedir,"target/classes/net/sourceforge/jeuclid/moDictionary.ser"); |
| 37 |
File oldDict2 = new File(basedir,"target/classes/net/sourceforge/jeuclid/moDictionary.xml"); |
| 38 |
if (!newDict2.exists()) { |
| 39 |
log.info("Preloading operator dictionary 2..."); |
| 40 |
Object dict2 = OperatorDictionary2.getInstance(); |
| 41 |
os = new FileOutputStream(newDict2); |
| 42 |
oo = new ObjectOutputStream(os); |
| 43 |
oo.writeObject(dict2); |
| 44 |
oo.close(); |
| 45 |
} |
| 46 |
ant.delete(file:oldDict2); |
| 47 |
|
| 48 |
File newDict3 = new File(basedir,"target/classes/net/sourceforge/jeuclid/appendixc.ser"); |
| 49 |
File oldDict3 = new File(basedir,"target/classes/net/sourceforge/jeuclid/appendixc.xml"); |
| 50 |
if (!newDict3.exists()) { |
| 51 |
log.info("Preloading operator dictionary 3..."); |
| 52 |
Object dict3 = OperatorDictionary3.getInstance(); |
| 53 |
os = new FileOutputStream(newDict3); |
| 54 |
oo = new ObjectOutputStream(os); |
| 55 |
oo.writeObject(dict3); |
| 56 |
oo.close(); |
| 57 |
} |
| 58 |
ant.delete(file:oldDict3); |
| 59 |
|
| 60 |
File newMap = new File(basedir,"target/classes/net/sourceforge/jeuclid/charmap.ser"); |
| 61 |
File oldMap = new File(basedir,"target/classes/net/sourceforge/jeuclid/UnicodeData.txt"); |
| 62 |
if (!newMap.exists()) { |
| 63 |
log.info("Preloading character mappings..."); |
| 64 |
CharacterMapping map = CharacterMapping.getInstance(); |
| 65 |
os = new FileOutputStream(newMap); |
| 66 |
oo = new ObjectOutputStream(os); |
| 67 |
oo.writeObject(map); |
| 68 |
oo.close(); |
| 69 |
} |
| 70 |
ant.delete(file:oldMap); |
| 71 |
|
| 72 |
log.info("Precompilation done!"); |