Skip to content
This repository has been archived by the owner on Dec 24, 2023. It is now read-only.

External dependencies

Tomas Slusny edited this page Aug 17, 2015 · 6 revisions

This guide will be about adding and handling external Java libraries from http://mvnrepository.com and external Lua dependencies from http://luarocks.org.

Adding dependencies

To add Java library dependency to your project, we will use our awesome project.yml. In this guide we will be adding Apache Commons IO Java dependency and luaassert Lua dependency.

Java dependencies

libs:
  - commons-io:commons-io:2.4

As you can see, library names are delimited by :. First bit is dependency maintainer, second is dependency name and last one is dependency version.

Lua dependencies

rocks:
  - luassert

Lua dependencies are called rocks and including them is super simple as you can see above.

Now, try to start your project. Message stating that engine is downloading commons-io:commons-io:2.4 and installing luaassert should appear. Your project should succesfully start. You do not see anything new? That´s fine.

Using dependencies

Java dependencies

We will use java module to load some dependency code. We will try to use Commons IO to get us available storage space on our drive. So, let´s go.

import java from yae

FileSystemUtils = java.require "org.apache.commons.io.FileSystemUtils"

yae.ready = ->
  freeSpace = FileSystemUtils\freeSpaceKb!
  print freeSpace

Lua dependencies

To use them, we will use built-in require function:

assert = require "luassert"

assert.True true
assert.is.True true
assert.is_true true
assert.is_not.True false
assert.is.Not.True false
assert.is_not_true false
assert.are.equal 1, 1
assert.has.errors ->
  error "this should fail"