Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
[l.d.build] Move obtaining annotations.jar to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Aug 21, 2015
1 parent fae13d4 commit 65c6bac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
17 changes: 8 additions & 9 deletions src/leiningen/droid/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[utils :only [get-sdk-android-jar sh dev-build?
ensure-paths with-process read-password append-suffix
create-debug-keystore get-project-file read-project
sdk-binary relativize-path
sdk-binary relativize-path get-sdk-annotations-jar
get-resource-jars get-sdk-build-tools-path]]])
(:require [clojure.string :as str]
[clojure.set :as set]
Expand All @@ -33,18 +33,17 @@
(defn- run-proguard-minifying
"Run proguard on the compiled classes and dependencies, create an JAR with
minimized and shaken classes."
[{{:keys [sdk-path external-classes-paths target-version
[{{:keys [external-classes-paths
proguard-conf-path proguard-opts proguard-output-jar-path]} :android
compile-path :compile-path :as project}]
(info "Running Proguard...")
(ensure-paths compile-path proguard-conf-path)
(let [proguard-bin (sdk-binary project :proguard)
android-jar (get-sdk-android-jar sdk-path target-version)
proguard-opts (or proguard-opts [])

annotations (io/file sdk-path "tools" "support" "annotations.jar")
android-jar (get-sdk-android-jar project)
annotations (get-sdk-annotations-jar project)
deps (resolve-dependencies :dependencies project)
external-paths (or external-classes-paths [])]
external-paths (or external-classes-paths [])
proguard-opts (or proguard-opts [])]
(sh proguard-bin (str "@" proguard-conf-path)
"-injars" (->> (concat [compile-path] deps external-paths)
(map str)
Expand Down Expand Up @@ -96,7 +95,7 @@
(defn- run-dx
"Run dex on the given target paths, each should be either a directory with
.class files or a jar file."
[{{:keys [sdk-path out-dex-path force-dex-optimize dex-opts multi-dex
[{{:keys [out-dex-path force-dex-optimize dex-opts multi-dex
multi-dex-root-classes-path multi-dex-main-dex-list-path]} :android :as project}
target-paths]
(if multi-dex
Expand All @@ -107,7 +106,7 @@
options (or dex-opts [])
no-optimize (if (and (not force-dex-optimize) (dev-build? project))
"--no-optimize" [])
annotations (io/file sdk-path "tools" "support" "annotations.jar")
annotations (get-sdk-annotations-jar project)
multi-dex (if multi-dex
["--multi-dex" "--main-dex-list" multi-dex-main-dex-list-path]
[])]
Expand Down
10 changes: 5 additions & 5 deletions src/leiningen/droid/classpath.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"Contains functions and hooks for Android-specific classpath
manipulation."
(:require [leiningen.droid.aar :refer [get-aar-classes]]
[leiningen.droid.utils :refer [get-sdk-android-jar]]
[leiningen.droid.utils :refer [get-sdk-android-jar
get-sdk-annotations-jar]]
[robert.hooke :refer [add-hook]])
(:import org.sonatype.aether.util.version.GenericVersionScheme))

Expand Down Expand Up @@ -72,12 +73,11 @@
extracting the path to the Android SDK and the target version from it.
Then the path to the actual `android.jar` file is constructed and
appended to the rest of the classpath list."
[f {{:keys [sdk-path target-version external-classes-paths]}
:android :as project}]
[f {{:keys [external-classes-paths]} :android :as project}]
(let [classpath (f project)
result (conj (concat classpath external-classes-paths)
(get-sdk-android-jar sdk-path target-version)
(str sdk-path "/tools/support/annotations.jar"))]
(get-sdk-android-jar project)
(get-sdk-annotations-jar project))]
result))

(defn init-hooks []
Expand Down
8 changes: 8 additions & 0 deletions src/leiningen/droid/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@
([sdk-root version]
(str (file (get-sdk-platform-path sdk-root version) "android.jar"))))

(defn get-sdk-annotations-jar
"Returns a path to annotations.jar file."
[sdk-root-or-project]
(let [sdk-root (if (map? sdk-root-or-project)
(get-in sdk-root-or-project [:android :sdk-path])
sdk-root-or-project)]
(str (file sdk-root "tools" "support" "annotations.jar"))))

(defn get-resource-jars
"Get the list of dependency libraries that has `:use-resources true`
in their definition."
Expand Down

0 comments on commit 65c6bac

Please sign in to comment.