Giter VIP home page Giter VIP logo

nake's Introduction

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+.

nake's People

Contributors

markusmoormann avatar winterbe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.