-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/target | ||
**/.clj-kondo/.cache | ||
**/.lsp | ||
**/.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
(ns antq.dep.gradle | ||
(:require | ||
[antq.record :as r] | ||
[antq.util.dep :as u.dep] | ||
[clojure.java.io :as io] | ||
[clojure.java.shell :as sh] | ||
[clojure.string :as str])) | ||
|
||
(def ^:private project-file "build.gradle") | ||
(def ^:private dep-regexp #"^[^-]\-+\s") | ||
|
||
(defn- filter-deps-from-gradle-dependencies | ||
[file-path] | ||
(let [{:keys [exit out]} (sh/sh "gradle" "--build-file" file-path "--quiet" "dependencies")] | ||
(if (= 0 exit) | ||
(->> (str/split-lines out) | ||
(filter seq) | ||
(filter #(re-seq dep-regexp %)) | ||
(map #(str/replace % dep-regexp "")) | ||
(map #(first (str/split % #" " 2))) | ||
(set)) | ||
(throw (ex-info "Failed to run gradle" {:exit exit}))))) | ||
|
||
(defn- convert-grandle-dependency | ||
"e.g. dep-str: 'org.clojure:clojure:1.10.0'" | ||
[file-path dep-str] | ||
(let [[group-id artifact-id version] (str/split dep-str #":" 3)] | ||
(r/map->Dependency {:project :gradle | ||
:type :java | ||
:file file-path | ||
:name (str group-id "/" artifact-id) | ||
:version version | ||
#_#_:repositories repositories}))) | ||
|
||
(defn extract-deps | ||
[file-path] | ||
(try | ||
(let [deps (filter-deps-from-gradle-dependencies file-path) | ||
deps (map #(convert-grandle-dependency file-path %) deps)] | ||
deps) | ||
(catch Exception _ | ||
;; FIXME | ||
nil))) | ||
|
||
(defn load-deps | ||
([] (load-deps ".")) | ||
([dir] | ||
(let [file (io/file dir project-file)] | ||
(when (.exists file) | ||
(extract-deps (u.dep/relative-path file)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
plugins { | ||
id 'dev.clojurephant.clojure' version '0.6.0' | ||
id 'maven-publish' | ||
} | ||
|
||
group = 'net.clojars.myname' | ||
version = '0.1.0-SNAPSHOT' | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { | ||
name = 'clojars' | ||
url = 'https://repo.clojars.org' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'org.clojure:clojure:1.10.0' | ||
|
||
testRuntimeOnly 'org.ajoberstar:jovial:0.3.0' | ||
|
||
devImplementation 'org.clojure:tools.namespace:1.0.0' | ||
} |