Skip to content

Commit

Permalink
Release version 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorwood committed May 27, 2018
1 parent ae37eb6 commit 3832bca
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The `lein native-image` command compiles your project then uses GraalVM's [`nati
```clojure
(defproject my-app "0.1.0"
:dependencies [[org.clojure/clojure "1.9.0"]]
:plugins [[io.taylorwood/lein-native-image "0.2.0-SNAPSHOT"]]
:plugins [[io.taylorwood/lein-native-image "0.2.0"]]
:native-image {:graal-bin "/path/to/graalvm-1.0.0-rc1/Contents/Home/bin"
:name "my-app"}
:main ^:skip-aot my-app.core
Expand All @@ -28,7 +28,7 @@ The `lein native-image` command compiles your project then uses GraalVM's [`nati

## Usage

1. Put `[io.taylorwood/lein-native-image "0.2.0-SNAPSHOT"]` into the `:plugins` vector of your project.clj, or in your Leiningen user profile.
1. Put `[io.taylorwood/lein-native-image "0.2.0"]` into the `:plugins` vector of your project.clj, or in your Leiningen user profile.

1. Optionally specify a custom image name, path to GraalVM's `bin` directory or `native-image` path, or `native-image` CLI options in your project.clj:
```clojure
Expand All @@ -45,7 +45,7 @@ The `lein native-image` command compiles your project then uses GraalVM's [`nati

You can also specify these in your Leiningen user profile `~/.lein/profiles.clj`:
```clojure
{:user {:plugins [[io.taylorwood/lein-native-image "0.2.0-SNAPSHOT"]]
{:user {:plugins [[io.taylorwood/lein-native-image "0.2.0"]]
:native-image {:graal-bin "/path/to/graalvm-1.0.0-rc1/Contents/Home/bin"}}}
```

Expand Down
28 changes: 18 additions & 10 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
# Example Projects

Some sample Leiningen projects that have been tested with `lein-native-image`.
Some sample Leiningen projects that have been tested with `lein-native-image` to produce working GraalVM native images.

Run `lein native-image` from an example project directory and execute the generated image.

## jdnsmith

A CLI tool that reads JSON from stdin, converts it to EDN, and writes it to stdout.
A CLI tool that reads JSON from stdin then writes it to stdout in EDN format.

```
➜ echo "{\"foo\": [{\"bar\": 1.33}]}" | ./target/jdn
{:foo [{:bar 1.33}]}
```

## http-api

A simple web server using http-kit + Ring + Compojure.
Includes endpoints for making HTTP requests to other sites and...
- returning the response in Hiccup/EDN format
A simple web server using http-kit + Ring + Compojure. Build the native image, then start it:
```
➜ ./target/server
Hello, Web!
```

You can now make requests to endpoints that in turn make HTTP requests to other sites and...
- return the response in Hiccup/EDN format:
```
➜ curl localhost:3000/hick/clojuredocs.org
("<!DOCTYPE html>" [:html {} [:head {} [:meta {:content "width=device-width, maximum-scale=1.0", :name "viewport"}] [:meta {:content "yes", :name "apple-mobile-web-app-capable"}] [:meta {:content "default", :name "apple-mobile-web-app-status-bar-style"}] [:meta {:content "ClojureDocs" ...
```
- computing the frequency of each character in the response
- compute the frequency of each character in the response:
```
➜ curl localhost:3000/freq/clojuredocs.org
{"frequencies":{" ":1320,"!":11,"A":15,"a":2440,"\"":1392,"B":12,"b":295,"#":66,"C":50,"c":1160,"D":44,"d":574,"❤":1,"%":12,"E":26,"e":1330,"&":144,"F":28,"f":460,"❦":1,"'":44,"G":47,"g":422,"(":44,"H":7,"h":512,")":44,"I":6,"i":1000,"\n":55,"*":3,"J":6,"j":134,"+":2,"K":5,"k":156,",":46,"L":17,"l":1045,"-":345,"M":7,"m":582,".":342,"N":12,"n":981,"/":1156,"O":8,"o":1022,"0":168,"P":48,"p":753,"1":158,"Q":3,"q":15,"2":277,"R":11,"r":1292,"3":228,"S":7,"s":1674,"4":198,"T":13,"t":1431,"5":112,"U":4,"u":542,"6":125,"V":3,"v":526,"7":135,"W":2,"w":263,"8":141,"X":2,"x":42,"9":118,"Y":3,"y":233,"∙":6,":":224,"Z":2,"z":20,";":183,"[":13,"{":11,"<":1012,"|":7,"=":924,"]":13,"}":11,">":1015,"^":1,"?":94,"_":15},"timestamp":"2018-05-27T21:15:52.438Z"}%
```

The project's `core.clj` also demonstrates a workaround for dealing with `native-image` limitations related to runtime reflection.

# Building

Run `lein native-image` from an example project directory and execute the generated image.
4 changes: 2 additions & 2 deletions examples/http-api/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
[compojure "1.6.1"]
[clj-http-lite "0.3.0"]
[hickory "0.7.1"]]
:plugins [[io.taylorwood/lein-native-image "0.2.0-SNAPSHOT"]]
:plugins [[io.taylorwood/lein-native-image "0.2.0"]]
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]
:native-image {:graal-bin "/Users/Taylor/Projects/graalvm-1.0.0-rc1/Contents/Home/bin"
:native-image {:graal-bin "/path/to/graalvm-1.0.0-rc1/Contents/Home/bin"
:opts ["-H:EnableURLProtocols=http"
"-H:+ReportUnsupportedElementsAtRuntime" ;; ignore native-image build errors
"--no-server" ;; TODO issue with subsequent builds failing on same server
Expand Down
2 changes: 1 addition & 1 deletion examples/jdnsmith/project.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(defproject jdnsmith "0.1.0-SNAPSHOT"
:plugins [[io.taylorwood/lein-native-image "0.2.0-SNAPSHOT"]]
:plugins [[io.taylorwood/lein-native-image "0.2.0"]]
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/data.json "0.2.6"]]
:main ^:skip-aot jdnsmith.core
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject io.taylorwood/lein-native-image "0.2.0-SNAPSHOT"
(defproject io.taylorwood/lein-native-image "0.2.0"
:description "A Leiningen plugin for generating GraalVM native images from your project."
:url "https://github.com/taylorwood/lein-native-image"
:license {:name "The MIT License"
Expand Down

0 comments on commit 3832bca

Please sign in to comment.