ryoakg
3/14/2017 - 3:25 PM

gradle-tooling.clj

;;; https://dzone.com/articles/gradle-tooling-api-introduction

;;; https://discuss.gradle.org/t/make-the-tooling-api-available-on-maven-central/365
(merge-env! :repositories '#{["gradle" {:url "http://repo.gradle.org/gradle/libs-releases-local"}]})

;;; https://mvnrepository.com/artifact/org.gradle/gradle-tooling-api
(set-env! :dependencies '[[org.gradle/gradle-tooling-api "3.3"]])

(require '[clojure.java.io :as io])

(with-open [conn (-> (org.gradle.tooling.GradleConnector/newConnector)
                     (.forProjectDirectory (io/file "."))
                     .connect)]
  (-> conn
      (.getModel org.gradle.tooling.model.GradleProject)
      .getTasks
      (->> (map #(.getName %)))))
;; => ("buildEnvironment" "components" "dependencies" "dependencyInsight" "dependentComponents" "help" "init" "model" "projects" "properties" "tasks" "wrapper")