Add artifacts to Maven central repository.

This commit is contained in:
James Roseborough
2013-02-02 05:24:37 +00:00
parent 9ffb9499e5
commit 05ac5f22e0
4 changed files with 202 additions and 10 deletions

View File

@@ -725,6 +725,28 @@ See the <a href="http://luaj.sourceforge.net/api/3.0/org/luaj/vm2/ast/package-su
<h1>7 - <a name="7">Building and Testing</a></h1> <h1>7 - <a name="7">Building and Testing</a></h1>
<h2>Maven integration</h2>
The main jar files are now deployed in the maven central repository. To use them in your maven-based project, list them as a dependency:
<p>
For JSE projects, add this dependency for the luaj-jse jar:
<pre>
&lt;dependency&gt;
&lt;groupId&gt;org.luaj&lt;/groupId&gt;
&lt;artifactId&gt;luaj-jse&lt;/artifactId&gt;
&lt;version&gt;3.0-alpha3&lt;/version&gt;
&lt;/dependency&gt;
</pre>
while for JME projects, use the luaj-jme jar:
<pre>
&lt;dependency&gt;
&lt;groupId&gt;org.luaj&lt;/groupId&gt;
&lt;artifactId&gt;luaj-jme&lt;/artifactId&gt;
&lt;version&gt;3.0-alpha3&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<h2>Building the jars</h2> <h2>Building the jars</h2>
An ant file is included in the root directory which builds the libraries by default. An ant file is included in the root directory which builds the libraries by default.
@@ -743,9 +765,9 @@ The main luaj JUnit tests are organized into a JUnit 3 suite:
Unit test scripts can be found in these locations Unit test scripts can be found in these locations
<pre> <pre>
test/lua/*.lua test/lua/*.lua
test/junit/org/luaj/vm2/compiler/lua5.1-tests.zip test/lua/errors/*.lua
test/junit/org/luaj/vm2/compiler/regressions.zip test/lua/perf/*.lua
test/junit/org/luaj/vm2/vm1/luajvm1-tests.zip test/lua/luaj3.0-tests.zip
</pre> </pre>
<h2>Code coverage</h2> <h2>Code coverage</h2>
@@ -769,11 +791,7 @@ Sources are hosted on SourceForge and available via sourceforge.net
<a href="http://sourceforge.net/project/platformdownload.php?group_id=197627">SourceForge Luaj Download Area</a> <a href="http://sourceforge.net/project/platformdownload.php?group_id=197627">SourceForge Luaj Download Area</a>
</pre> </pre>
<p/> <p/>
and LuaForge: Files are no longer hosted at LuaForge.
<pre>
<a href="http://luaforge.net/projects/luaj/">LuaForge Luaj Project Page</a>
<a href="http://luaforge.net/frs/?group_id=457">LuaForge Luaj Project Area</a>
</pre>
<h1>9 - <a name="9">Release Notes</a></h1> <h1>9 - <a name="9">Release Notes</a></h1>
@@ -823,6 +841,7 @@ and LuaForge:
<li>Fix bug 3597515 memory leak due to string caching by simplifying caching logic.</li> <li>Fix bug 3597515 memory leak due to string caching by simplifying caching logic.</li>
<li>Fix bug 3565008 so that short substrings are backed by short arrays.</li> <li>Fix bug 3565008 so that short substrings are backed by short arrays.</li>
<li>Fix bug 3495802 to return correct offset of substrings from string.find().</li> <li>Fix bug 3495802 to return correct offset of substrings from string.find().</li>
<li>Add artifacts to Maven central repository.</li>
</ul></td></tr> </ul></td></tr>
</table></td></tr></table> </table></td></tr></table>

148
build-maven.xml Normal file
View File

@@ -0,0 +1,148 @@
<project default="usage">
<!-- Ant file to deploy to maven once the distribution is released on sourceforge.
-->
<property file="version.properties"/>
<property name="major" value="3.0"/>
<macrodef name="write_pom">
<attribute name="platform"/>
<sequential>
<mkdir dir="build/maven-${version}"/>
<echo file="build/maven-${version}/luaj-@{platform}-${version}.pom"><![CDATA[<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.luaj</groupId>
<artifactId>luaj-]]>@{platform}<![CDATA[</artifactId>
<version>]]>${version}<![CDATA[</version>
<packaging>jar</packaging>
<name>luaj-]]>@{platform}<![CDATA[</name>
<description>Luaj ]]>${version}<![CDATA[ for the ]]>@{platform}<![CDATA[ platform</description>
<url>http://sourceforge.net/projects/luaj/</url>
<licenses>
<license>
<name>MIT License</name>
<url>http://luaj.sourceforge.net/license.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>jrosebor</id>
<name>James Roseborough</name>
<email>jim.roseborough@luaj.org</email>
<timezone>-8</timezone>
<roles></roles>
</developer>
<developer>
<id>ifarmer</id>
<name>Ian Farmer</name>
<email>ian.farmer@luaj.org</email>
<timezone>-8</timezone>
<roles></roles>
</developer>
</developers>
<scm>
<url>http://luaj.cvs.sourceforge.net/viewvc/luaj/luaj-vm/</url>
</scm>
</project>
]]></echo>
</sequential>
</macrodef>
<macrodef name="prepare_files">
<attribute name="platform"/>
<sequential>
<mkdir dir="build/maven-${version}"/>
<write_pom platform="@{platform}"/>
<get src="http://downloads.sourceforge.net/project/luaj/luaj-${major}/${version}/luaj-${version}.zip"
dest="build/maven-${version}/luaj-${version}.zip"
skipexisting="true"/>
<unzip src="build/maven-${version}/luaj-${version}.zip" dest="build/maven-${version}"/>
<copy file="build/maven-${version}/luaj-${version}/lib/luaj-@{platform}-${version}.jar" todir="build/maven-${version}"/>
<!-- make a -sources file -->
<mkdir dir="build/maven-${version}/sources-@{platform}"/>
<copy todir="build/maven-${version}/sources-@{platform}">
<fileset dir="build/maven-${version}/luaj-${version}/src/core"/>
<fileset dir="build/maven-${version}/luaj-${version}/src/@{platform}"/>
<filterchain>
<tokenfilter><replacestring from='"Luaj 0.0"' to='"Luaj-@{platform} ${version}"'/></tokenfilter>
</filterchain>
</copy>
<zip destfile="build/maven-${version}/luaj-@{platform}-${version}-sources.jar"
basedir="build/maven-${version}/sources-@{platform}"/>
<!-- make a -javadoc file -->
<mkdir dir="build/maven-${version}/javadoc-@{platform}"/>
<javadoc defaultexcludes="yes"
destdir="build/maven-${version}/javadoc-@{platform}"
author="true"
version="true"
use="true"
windowtitle="Luaj API">
<fileset dir="build/maven-${version}/sources-@{platform}">
<include name="org/luaj/vm/*.java"/>
<include name="org/luaj/vm2/*.java"/>
<include name="**/LuaC.java"/>
<include name="**/LuaJC.java"/>
<include name="**/lib/*/*.java"/>
</fileset>
<doctitle><![CDATA[<h1>Luaj API</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright &#169; 2007-2013 Luaj.org. All Rights Reserved.</i>]]></bottom>
<tag name="todo" scope="all" description="To do:"/>
<link offline="true" href="http://sourceforge.net/projects/luaj/" packagelistLoc="C:\tmp"/>
<link href="http://sourceforge.net/projects/luaj/"/>
</javadoc>
<zip destfile="build/maven-${version}/luaj-@{platform}-${version}-javadoc.jar"
basedir="build/maven-${version}/javadoc-@{platform}"/>
</sequential>
</macrodef>
<macrodef name="sign_and_deploy">
<attribute name="platform"/>
<sequential>
<exec executable="mvn">
<arg value="gpg:sign-and-deploy-file"/>
<arg value="-Durl=http://oss.sonatype.org/service/local/staging/deploy/maven2"/>
<arg value="-DrepositoryId=nexus-releases"/>
<arg value="-DpomFile=build/maven-${version}/luaj-@{platform}-${version}.pom"/>
<arg value="-Dfile=build/maven-${version}/luaj-@{platform}-${version}.jar"/>
<arg value="-Dsources=build/maven-${version}/luaj-@{platform}-${version}-sources.jar"/>
<arg value="-Djavadoc=build/maven-${version}/luaj-@{platform}-${version}-javadoc.jar"/>
</exec>
</sequential>
</macrodef>
<macrodef name="prepare_and_install">
<attribute name="platform"/>
<sequential>
<prepare_files platform="@{platform}"/>
<exec executable="mvn">
<arg value="install:install-file"/>
<arg value="-Dfile=build/maven-${version}/luaj-@{platform}-${version}.jar"/>
<arg value="-DpomFile=build/maven-${version}/luaj-@{platform}-${version}.pom"/>
</exec>
</sequential>
</macrodef>
<macrodef name="prepare_and_deploy">
<attribute name="platform"/>
<sequential>
<prepare_files platform="@{platform}"/>
<sign_and_deploy platform="@{platform}"/>
</sequential>
</macrodef>
<target name="install">
<prepare_and_install platform="jse"/>
<prepare_and_install platform="jme"/>
</target>
<target name="deploy">
<prepare_and_deploy platform="jse"/>
<prepare_and_deploy platform="jme"/>
</target>
<target name="usage">
<echo level="info">Usage: ant -Dmajor=${major} -Dversion=${version} -f build-maven.xml [install | deploy]</echo>
</target>
</project>

View File

@@ -11,7 +11,7 @@ public class App
{ {
public static void main( String[] args ) public static void main( String[] args )
{ {
String script = "print 'hello, from luaj!'"; String script = "print('hello, world', _VERSION)";
// create an environment to run in // create an environment to run in
Globals globals = JsePlatform.standardGlobals(); Globals globals = JsePlatform.standardGlobals();

View File

@@ -1,9 +1,19 @@
package acme; package acme;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.jse.JsePlatform;
import acme.App;
/** /**
* Skeleton unit test for App, required for maven to be used to build the app. * Skeleton unit test for App, required for maven to be used to build the app.
*/ */
@@ -18,7 +28,22 @@ public class AppTest
return new TestSuite( AppTest.class ); return new TestSuite( AppTest.class );
} }
public void testAppCanBeExecuted() { public void testMainProgramExecution() {
App.main(new String[0]); App.main(new String[0]);
} }
public void testScriptEngineEvaluation() throws ScriptException {
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine e = sem.getEngineByExtension(".lua");
String result = e.eval("return math.pi").toString().substring(0,8);
assertEquals("3.141592", result);
}
public void testDirectEvaluation() {
String script = "return math.pow(..., 3)";
Globals globals = JsePlatform.standardGlobals();
LuaValue chunk = globals.loadString(script, "cube");
int result = chunk.call(LuaValue.valueOf(5)).toint();
assertEquals(125, result);
}
} }