Skip to content

Commit 79cd608

Browse files
committed
testing native-image plugin for leiningen
This works, but the image size is HUGE
1 parent 6292ead commit 79cd608

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ Tiny tool to query repology.org.
44

55
## Installation
66

7-
Download the uberjar. In the future I want to publish this as an executable.
7+
Download the application from the releases page.
88

99
## Usage
1010

11-
Currently needs java.
12-
1311
```
14-
$ java -jar repoman-0.1.0-standalone.jar -s starship --with-repo chocolatey --with-repo scoop
12+
$ rp -s starship --with-repo chocolatey --with-repo scoop
1513
"rust:starship-module-config-derive" is in 0/4 repositories
1614
"starship" is in 3/20 repositories
1715
18-
$ java -jar repoman-0.1.0-standalone.jar -p starship --with-repo chocolatey --with-repo scoop
16+
$ rp -p starship --with-repo chocolatey --with-repo scoop
1917
| :repo | :subrepo | :name | :version | :status |
2018
|------------+----------+-------------------+----------+----------|
2119
| chocolatey | | starship | 0.44.0 | newest |
@@ -52,7 +50,9 @@ rp: A tiny tool for querying repology
5250

5351
I wrote this in an afternoon. I had a vm with 4 non-language-specific package managers and wanted an easier way to query what was available, where.
5452

55-
After writing it, I realized it's small enough (< 150 loc) to be an excellent project for playing around with lumo, babashka, graal native image, etc. I plan to do that at some point.
53+
After writing it, I realized it's small enough (< 150 loc) to be an excellent project for playing around with lumo, babashka, graal native image, etc.
54+
55+
This has already been accomplished with graal native image. However, the image size is huge. I believe this is due to limitations with clj-http-lite.
5656

5757
## License
5858

project.clj

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,24 @@
55
:url "https://www.eclipse.org/legal/epl-2.0/"}
66
:dependencies [[org.clojure/clojure "1.10.1"]
77
[org.clojure/tools.cli "1.0.194"]
8-
[clj-http "3.10.1"]
8+
;; clj-http incompatible with graal
9+
[org.martinklepsch/clj-http-lite "0.4.3"]
910
[cheshire "5.10.0"]
1011
[camel-snake-kebab "0.4.1"]]
12+
:plugins [[io.taylorwood/lein-native-image "0.3.1"]]
1113
:main ^:skip-aot repoman.core
1214
:target-path "target/%s"
13-
:profiles {:uberjar {:aot :all}})
15+
:native-image
16+
{:name "rp"
17+
:graal-bin "C:\\Program Files\\GraalVM\\graalvm-ce-java11-20.1.0\\bin"
18+
:opts ["--verbose"
19+
"--report-unsupported-elements-at-runtime"
20+
"--initialize-at-build-time"
21+
"--allow-incomplete-classpath" ;; clj-http-lite requires this
22+
"--no-fallback"
23+
"-H:EnableURLProtocols=https"]}
24+
:profiles
25+
{:uberjar
26+
{:aot :all
27+
:native-image
28+
{:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}}})

src/repoman/core.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns repoman.core
22
(:require [clojure.pprint :refer [print-table]]
3-
[clj-http.client :as client]
3+
[clj-http.lite.client :as client]
44
[cheshire.core :as json]
55
[camel-snake-kebab.core :refer [->kebab-case-keyword]]
66
[camel-snake-kebab.extras :refer [transform-keys]]
@@ -11,6 +11,8 @@
1111
(:import [java.io File])
1212
(:gen-class))
1313

14+
;; (set! *warn-on-reflection* true)
15+
1416
(def endpoint "https://repology.org/api/v1/")
1517
(def pkg-keys [:repo :subrepo :name :version :status])
1618

@@ -40,7 +42,7 @@
4042
(defn get-repos
4143
"Returns a vector showing the repositories we are interested in"
4244
[repo-file {:keys [with-repo]}]
43-
(if (.exists repo-file)
45+
(if (.exists ^File repo-file)
4446
(try
4547
(concat
4648
(edn/read-string
@@ -141,7 +143,7 @@
141143
cfg (config)]
142144
(cond
143145
(:help opts) (format-help (:summary m))
144-
(:config opts) (println (.getAbsolutePath cfg))
146+
(:config opts) (println (.getAbsolutePath ^File cfg))
145147
:else
146148
(let [repos (get-repos cfg opts)]
147149
(cond

0 commit comments

Comments
 (0)