Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions hickory/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/target
/classes
/checkouts
profiles.clj
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
.hgignore
.hg/
20 changes: 20 additions & 0 deletions hickory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Sample-project

Use this project as template for testing a specific library with GraalVM **native-image**

## Usage

Currently testing:

[hickory "0.7.1]

Test with:

lein do clean, uberjar, native, run-native

1. clj-easy/graal-build-time does not work here! Instead you need to rely on the deprecated `--initialize-at-build-time`
2. hickory 0.7.2 and 0.7.3 do not compile with the demo project provided as is (note this is fixed in master)
3. Note that `native-image` was not in my path, so I edited the project.clj to hardcode it's full path.
4. For a slightly more complex project combining hickory with clj-http-lite check out [bbyt](https://github.com/port19x/bbyt).
5. Expect build times of 1-2 minutes, that's normal.
6. Test out different permutations of cli args for native-image. I have found `"-J-Xmx3g"` to be unnecessary for example.
24 changes: 24 additions & 0 deletions hickory/project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(defproject sample-project "0.1.0-SNAPSHOT"

:dependencies [[org.clojure/clojure "1.10.3"]
;; add the library here
[hickory "0.7.1"]]

:main simple.main

:uberjar-name "simple-main.jar"

:profiles {:uberjar {:aot :all}
:dev {:plugins [[lein-shell "0.5.0"]]}}

:aliases
{"native"
["shell"
;; ADD GraalVM bin dir to the $PATH
"native-image" "--report-unsupported-elements-at-runtime"
"--no-server" "--no-fallback"
"--initialize-at-build-time"
"-jar" "./target/${:uberjar-name:-${:name}-${:version}-standalone.jar}"
"-H:Name=./target/${:name}"]

"run-native" ["shell" "./target/${:name}"]})
20 changes: 20 additions & 0 deletions hickory/src/simple/main.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(ns simple.main
(:require
[hickory.core :as h]
[hickory.select :as s])
(:gen-class))

(defn -main []
(let [sample-html (str "<!DOCTYPE html>" "<html>" "<head>" "</head>" "<body>"
"<h1>" "Don't select me!" "</h1>"
"<i>" "Don't select me either!" "</i>"
"<p>" "Select me!" "</p>"
"<p>" "Select me too!" "</p>"
"</body>" "</html>")]
(->> sample-html
(h/parse)
(h/as-hickory)
(s/select (s/tag "p"))
(first)
(:content)
(println))))