Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

README.md

Nake

Nake is a simplified version of Make (Cake, Jake, Rake) for the Java 8 Nashorn Javascript Engine.

You define tasks in a project specific nakefile.js and call them from the command line. Tasks are written in Javascript and run natively on the JVM by utilizing Nashorns jjs -scripting command. This enables you to utilize everything from the JDK 8 API or any external Java libraries.

Usage

Running nake with no arguments prints all tasks in the current directory's Nakefile.

Use nake -- taskName [options] to run a specific task from your Nakefile.

Installation

Use the following steps to install Nake on POSIX systems (Mac OSX, Linux):

  • Install Java 8 and make sure $JAVA_HOME points to your Java home directory
  • Link jjs to /usr/bin so you can use it from any directory:
$ cd /usr/bin
$ ln -s $JAVA_HOME/bin/jjs jjs
  • Clone the nake repository or copy src/nake.js to your machine
  • Make nake.js executable: chmod +x /path/to/nake/src/nake.js
  • Link src/nake.js to usr/bin so you can use it from any directory:
$ cd /usr/bin
$ ln -s /path/to/nake/src/nake.js nake

Nake also runs on Windows: Set PATH to nake.js directory; then run Nake with jjs -scripting nake.js -- taskName.

Getting started

Create a file called nakefile.js in your projects root directory with the following content:

task('hello', 'Hello World', function() {
  print('Hello World!');
});

Open the terminal, cd into any project directory and type nake -- hello.

Next, check out the API Documentation and example tasks. You should also consider reading my Nashorn Tutorial to get started with the Nashorn engine.

Examples

The java example found in test/java contains a sample java application with some basic java-related nake tasks:

Run the java application:

Invokes the java main method. Nake arguments will be passed to java.

task("run", "Run java application", function(options) {
  shell()
    .dir("out")
    .exec("java com/winterbe/nake/java/Main ${options[0]}")
    .print();
});

Run the task from your terminal:

nake -- run [arg]

Compile all java files:

Compiles all java files from src to out.

task("compile", "Compile all java files", function() {
  shell()
    .exec("find src -name *.java")
    .apply(function(result) {
      return java.lang.String.join(" ", result.split("\n"));
    })
    .stash("files")
    .print("compiling java files...")
    .exec("mkdir -p out")
    .exec("javac -d out {{files}}")
    .print("done");
});

Run the task from your terminal:

nake -- compile

Keep in mind that you can run nake tasks from any subfolder of your project. Read the API Documentation for a detailed description.

Contribute

Your Feedback is highly appreciated. Feel free to file an issue or ping me on Twitter or Google+.

About

A simplified Make for Java 8 Nashorn

Resources

License

Packages

No packages published
You can’t perform that action at this time.