diff --git a/hickory/.gitignore b/hickory/.gitignore new file mode 100644 index 0000000..d18f225 --- /dev/null +++ b/hickory/.gitignore @@ -0,0 +1,12 @@ +/target +/classes +/checkouts +profiles.clj +pom.xml +pom.xml.asc +*.jar +*.class +/.lein-* +/.nrepl-port +.hgignore +.hg/ diff --git a/hickory/README.md b/hickory/README.md new file mode 100644 index 0000000..13a2f95 --- /dev/null +++ b/hickory/README.md @@ -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. diff --git a/hickory/project.clj b/hickory/project.clj new file mode 100644 index 0000000..4bd917d --- /dev/null +++ b/hickory/project.clj @@ -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}"]}) diff --git a/hickory/src/simple/main.clj b/hickory/src/simple/main.clj new file mode 100644 index 0000000..c1982e6 --- /dev/null +++ b/hickory/src/simple/main.clj @@ -0,0 +1,20 @@ +(ns simple.main + (:require + [hickory.core :as h] + [hickory.select :as s]) + (:gen-class)) + +(defn -main [] + (let [sample-html (str "" "" "
" "" "" + "" "Select me!" "
" + "" "Select me too!" "
" + "" "")] + (->> sample-html + (h/parse) + (h/as-hickory) + (s/select (s/tag "p")) + (first) + (:content) + (println))))