Get build working on jre6,7,8

This commit is contained in:
walterhiggins 2014-10-18 18:48:57 +01:00
parent eb8b78cce9
commit c36cd97c99
6 changed files with 56 additions and 62 deletions

View file

@ -2,12 +2,31 @@
<property file="build.properties"/> <property file="build.properties"/>
<description>Builds the scriptcraft.jar file - a plugin for bukkit</description> <description>Builds the scriptcraft.jar file - a plugin for bukkit</description>
<property name="src.canary" location="src/main/java/canary"/> <property name="src.canary" location="src/main/java/canary"/>
<property name="lib.canary" location="lib/canary.jar"/>
<property name="src.bukkit" location="src/main/java/bukkit"/> <property name="src.bukkit" location="src/main/java/bukkit"/>
<property name="build" location="target/classes"/> <property name="build" location="target/classes"/>
<property name="dist" location="target/" /> <property name="dist" location="target/" />
<property name="minecraft.dir" location="${dist}/minecraft" /> <property name="minecraft.dir" location="${dist}/minecraft" />
<property name="js-plugins-dir" value="scriptcraft"/> <property name="js-plugins-dir" value="scriptcraft"/>
<property name="http.agent" value="'Walter'" /> <property name="http.agent" value="'Walter'" />
<macrodef name="jscript">
<attribute name="src"/>
<attribute name="out"/>
<attribute name="err"/>
<element name="js-args" implicit="yes" optional="true"/>
<sequential>
<java classname="jscript" failonerror="true" fork="true" output="@{out}" error="@{err}">
<classpath>
<pathelement path="${build}"/>
<pathelement path="${lib.canary}"/>
</classpath>
<arg value="@{src}"/>
<js-args/>
</java>
</sequential>
</macrodef>
<target name="init"> <target name="init">
<property file="build.local.properties"/> <property file="build.local.properties"/>
<tstamp> <tstamp>
@ -35,7 +54,7 @@
<src path="${src.canary}"/> <src path="${src.canary}"/>
<src path="${src.bukkit}"/> <src path="${src.bukkit}"/>
<classpath> <classpath>
<pathelement path="lib/canary.jar" /> <pathelement path="${lib.canary}" />
<pathelement path="lib/bukkit-1.7.9-R0.2.jar" /> <pathelement path="lib/bukkit-1.7.9-R0.2.jar" />
</classpath> </classpath>
</javac> </javac>
@ -45,30 +64,19 @@
</target> </target>
<target name="compile-docs" depends="init"> <target name="compile-docs" depends="init">
<javac includeantruntime="false" <javac includeantruntime="false" srcdir="src/docs/java" destdir="${build}">
srcdir="src/docs/java" <classpath>
destdir="${build}" <pathelement path="${lib.canary}"/>
/> </classpath>
</javac>
</target> </target>
<target name="generate-api-ref-entries" depends="copy-js,compile-docs,init"> <target name="generate-api-ref-entries" depends="copy-js,compile-docs,init">
<java classname="jscript" failonerror="true" fork="true" output="${dist}/apiref.md"> <jscript src="src/docs/js/generateApiDocs.js" out="${dist}/apiref.md" err="${dist}/gen-api-error.log">
<classpath> <arg value="${dist}/js"/>
<pathelement path="${build}"/> </jscript>
</classpath> <jscript src="src/docs/js/generateItemsDoc.js" out="${dist}/items.md" err="${dist}/gen-items-error.log" />
<arg value="src/docs/js/generateApiDocs.js"/>
<arg value="${dist}/js"/>
</java>
<java classname="jscript" failonerror="true" fork="true" output="${dist}/items.md" error="${dist}/genitemserror.log">
<classpath>
<pathelement path="${build}"/>
<pathelement path="lib/canary.jar"/>
</classpath>
<arg value="src/docs/js/generateItemsDoc.js"/>
</java>
<concat destfile="${dist}/apiref-con.md"> <concat destfile="${dist}/apiref-con.md">
<fileset file="${dist}/apiref.md" /> <fileset file="${dist}/apiref.md" />
<fileset file="${dist}/items.md" /> <fileset file="${dist}/items.md" />
@ -80,32 +88,22 @@
<target name="gen-events-helper-canary" depends="compile-docs,init"> <target name="gen-events-helper-canary" depends="compile-docs,init">
<mkdir dir="${dist}/js/lib"/> <mkdir dir="${dist}/js/lib"/>
<java classname="jscript" failonerror="true" fork="true" output="${dist}/js/lib/events-helper.js" error="${dist}/geneventserror.log"> <jscript src="src/docs/js/generateEventsHelper.js" out="${dist}/js/lib/events-helper.js" err="${dist}/gen-events-canary-error.log">
<classpath>
<pathelement path="${build}"/>
<pathelement path="lib/canary.jar"/>
</classpath>
<arg value="src/generateEventsHelper.js"/>
<arg value="canary"/> <arg value="canary"/>
<arg value="lib/canary.jar"/> <arg value="${lib.canary}"/>
<arg value="blockDestroy"/> <arg value="blockDestroy"/>
<arg value="net.canarymod.hook.player.BlockDestroyHook"/> <arg value="net.canarymod.hook.player.BlockDestroyHook"/>
</java> </jscript>
</target> </target>
<target name="gen-events-helper-bukkit" depends="compile-docs,init"> <target name="gen-events-helper-bukkit" depends="compile-docs,init">
<mkdir dir="${dist}/js/lib"/> <mkdir dir="${dist}/js/lib"/>
<java classname="jscript" failonerror="true" fork="true" output="${dist}/js/lib/events-helper.js" error="${dist}/geneventserror.log"> <jscript src="src/docs/js/generateEventsHelper.js" out="${dist}/js/lib/events-helper.js" err="${dist}/gen-events-bukkit-error.log">
<classpath> <arg value="bukkit"/>
<pathelement path="${build}"/> <arg value="${lib.canary}"/>
<pathelement path="lib/canary.jar"/>
</classpath>
<arg value="src/generateEventsHelper.js"/>
<arg value="canary"/>
<arg value="lib/canary.jar"/>
<arg value="Break"/> <arg value="Break"/>
<arg value="org.bukkit.event.block.BlockBreakEvent"/> <arg value="org.bukkit.event.block.BlockBreakEvent"/>
</java> </jscript>
</target> </target>
<target name="construct-api-ref" depends="gen-toc-apiref,init"> <target name="construct-api-ref" depends="gen-toc-apiref,init">
@ -124,25 +122,17 @@ Walter Higgins
<fileset file="${dist}/apiref-con.md" /> <fileset file="${dist}/apiref-con.md" />
</concat> </concat>
</target> </target>
<target name="gen-toc-apiref" depends="compile-docs,generate-api-ref-entries, init" description="Generate Table of Contents for API Reference"> <target name="gen-toc-apiref" depends="compile-docs,generate-api-ref-entries, init" description="Generate Table of Contents for API Reference">
<java classname="jscript" failonerror="true" fork="true" output="${dist}/toc-apiref.md"> <jscript src="src/docs/js/generateTOC.js" out="${dist}/toc-apiref.md" err="${dist}/gen-toc-error.log">
<classpath>
<pathelement path="${build}"/>
</classpath>
<arg value="src/docs/js/generateTOC.js"/>
<arg value="${dist}/apiref-con.md"/> <arg value="${dist}/apiref-con.md"/>
</java> </jscript>
</target> </target>
<target name="gen-toc-ypgpm" depends="compile-docs,init" description="Generate Table of Contents for Young Programmers Guide"> <target name="gen-toc-ypgpm" depends="compile-docs,init" description="Generate Table of Contents for Young Programmers Guide">
<java classname="jscript" failonerror="true" fork="true" output="${dist}/toc-ypgpm.md"> <jscript src="src/docs/js/generateTOC.js" out="${dist}/toc-ypgpm.md" err="${dist}/gen-ypgpm-error.log">
<classpath>
<pathelement path="${build}"/>
</classpath>
<arg value="src/docs/js/generateTOC.js"/>
<arg value="src/docs/templates/ypgpm.md"/> <arg value="src/docs/templates/ypgpm.md"/>
</java> </jscript>
</target> </target>
<!-- Piece together the Young persons' guide from template and generated table of contents --> <!-- Piece together the Young persons' guide from template and generated table of contents -->

View file

@ -1,5 +1,7 @@
import javax.script.*; import javax.script.*;
import java.io.FileReader; import java.io.FileReader;
import net.canarymod.api.Server;
import net.canarymod.api.inventory.ItemType;
public class jscript public class jscript
{ {
@ -10,6 +12,7 @@ public class jscript
java.io.File file = new java.io.File(args[0]); java.io.File file = new java.io.File(args[0]);
engine.put("engine",engine); engine.put("engine",engine);
engine.put("args",args); engine.put("args",args);
engine.put("itemTypeClass",ItemType.class);
FileReader fr = new java.io.FileReader(file); FileReader fr = new java.io.FileReader(file);
engine.eval(fr); engine.eval(fr);
fr.close(); fr.close();

View file

@ -106,11 +106,10 @@ if (typeof importPackage == 'undefined'){
} }
var dir = args[0]; var dir = args[0];
var io = Packages.java.io;
importPackage(java.io); var File = io.File;
var store = []; var store = [];
find(new File(dir),store,/\/[a-zA-Z0-9_\-]+\.js$/); find(new io.File(dir),store,/\/[a-zA-Z0-9_\-]+\.js$/);
store.sort(sorter([ store.sort(sorter([
/lib\/scriptcraft\.js$/, /lib\/scriptcraft\.js$/,
@ -127,7 +126,7 @@ store.sort(sorter([
var contents = []; var contents = [];
foreach(store, function(filename){ foreach(store, function(filename){
var br = new BufferedReader(new FileReader(filename)); var br = new io.BufferedReader(new io.FileReader(filename));
var line ; var line ;
while ( (line = br.readLine()) != null){ while ( (line = br.readLine()) != null){
contents.push(line); contents.push(line);

View file

@ -33,12 +33,12 @@ for (var i = 0; i< content.length; i++){
out.println(content[i]); out.println(content[i]);
} }
while ( ( entry = zis.nextEntry) != null) { while ( ( entry = zis.nextEntry) != null) {
var name = '' + entry.name; var name = new String( entry.name );
var re1 = /org\/bukkit\/event\/.+Event\.class$/; var re1 = /org\/bukkit\/event\/.+Event\.class$/;
if (args[0] == 'canary'){ if (args[0] == 'canary'){
re1 = /net\/canarymod\/hook\/.+Hook\.class$/; re1 = /net\/canarymod\/hook\/.+Hook\.class$/;
} }
if (name.match(re1)){ if ( re1.test(name) ) {
name = name.replace(/\//g,'.').replace('.class',''); name = name.replace(/\//g,'.').replace('.class','');
try { try {
clz = java.lang.Class.forName(name); clz = java.lang.Class.forName(name);

View file

@ -20,13 +20,12 @@ var content = [
]; ];
//var ItemType = java.lang.Class.forName('net.canarymod.api.inventory.ItemType'); //var ItemType = java.lang.Class.forName('net.canarymod.api.inventory.ItemType');
var ItemType = Packages.net.canarymod.api.inventory.ItemType; var materials = itemTypeClass.getDeclaredFields();
var materials = ItemType.class.getDeclaredFields();
var enumVals = []; var enumVals = [];
for (var i = 0;i < materials.length; i++ ){ for (var i = 0;i < materials.length; i++ ){
if (materials[i].type != ItemType.class) { if (materials[i].type != itemTypeClass) {
continue; continue;
} }
var materialField = materials[i]; var materialField = materials[i];

View file

@ -17,7 +17,10 @@ for (var i = 0;i < materials.length; i++ ){
continue; continue;
} }
var materialField = materials[i]; var materialField = materials[i];
var name = (''+materialField.name).replace(/^(.)/,function(a){ return a.toLowerCase() }); var name = (''+materialField.name);
name = name.replace(/^(.)/,function(a){
return a.toLowerCase();
});
items[name] = (function(material){ items[name] = (function(material){
return function(amount){ return function(amount){