clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

lein-droid ignores ${HOME}/.lein/profiles.clj settings #114

Closed sakuraiyuta closed 9 years ago

sakuraiyuta commented 9 years ago

lein-droid ignores some(or all?) settings in ${HOME}/.lein/profiles.clj.

I created new project, build, and got the error The value of sdk-path is nil., as follows:

$ lein droid new sample-lein-droid-admob sample.lein.droid.admob
$ cd sample-lein-droid-admob
$ lein droid build

Retrieving lein-droid/lein-droid/0.3.0-SNAPSHOT/lein-droid-0.3.0-20141102.170355-2.pom from clojars
Retrieving lein-droid/lein-droid/0.3.0-SNAPSHOT/lein-droid-0.3.0-20141102.170355-2.jar from clojars
Generating manifest...
Generating R.java...
The value of sdk-path is nil. Abort execution.

Generated project.clj:

$ cat ./project.clj
(defproject sample-lein-droid-admob/sample-lein-droid-admob "0.0.1-SNAPSHOT"
  :description "FIXME: Android project description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :global-vars {*warn-on-reflection* true}

  :source-paths ["src/clojure" "src"]
  :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
  :plugins [[lein-droid "0.3.0-SNAPSHOT"]]

  :dependencies [[org.clojure-android/clojure "1.6.0-RC1" :use-resources true]
                 [neko/neko "3.1.0-beta1"]]
  :profiles {:default [:dev]

             :dev
             [;; :android-common :android-user
              {:dependencies [[org.clojure/tools.nrepl "0.2.3"]]
               :target-path "target/debug"
               :android {:aot :all-with-unused
                         :rename-manifest-package "sample.lein.droid.admob.debug"
                         :manifest-options {:app-name "sample-lein-droid-admob - debug"}}}]
             :release
             [;; :android-common
              {:target-path "target/release"
               :android
               { ;; Specify the path to your private keystore
                ;; and the the alias of the key you want to
                ;; sign APKs with.
                ;; :keystore-path "/home/user/.android/private.keystore"
                ;; :key-alias "mykeyalias"

                :ignore-log-priority [:debug :verbose]
                :aot :all
                :build-type :release}}]}

  :android {;; Specify the path to the Android SDK directory.
            ;; :sdk-path "/home/user/path/to/android-sdk/"

            ;; Try increasing this value if dexer fails with
            ;; OutOfMemoryException. Set the value according to your
            ;; available RAM.
            :dex-opts ["-JXmx4096M"]

            ;; If previous option didn't work, uncomment this as well.
            ;; :force-dex-optimize true

            :target-version "15"
            :aot-exclude-ns ["clojure.parallel" "clojure.core.reducers"
                             "cljs-tooling.complete" "cljs-tooling.info"
                             "cljs-tooling.util.analysis" "cljs-tooling.util.misc"
                             "cider.nrepl" "cider-nrepl.plugin"]})

My profiles, variously tried:

$ cat ~/.lein/profiles.clj
{:user {:plugins [[lein-pprint "1.1.1"]
                  [lein-droid "0.2.4"]]
        :dev {:android {:sdk-path "/opt/android-sdk"}}
        :android {:sdk-path "/opt/android-sdk"}}
 :android {:sdk-path "/opt/android-sdk"}
 :android-common {:android {:sdk-path "/opt/android-sdk"}}
 :dev {:android {:sdk-path "/opt/android-sdk"}}
 :profiles {:dev {:android {:sdk-path "/opt/android-sdk"}}}}

I tried that using 0.2.4 and 0.3.0-beta4 and got same error.

It works well if you fix project.clj as follows:

Is it expected result? Do I wrong?

alexander-yakushev commented 9 years ago

Yes, it is expected in 0.3.x. :default [:dev] makes the default profile ignore :user profile which usually contains extra dependencies unfit for Android. Please see https://github.com/clojure-android/lein-droid/wiki/Profiles

alexander-yakushev commented 9 years ago

Long story short: to make up for missing :user, make :android-common and :android-user profiles in profiles.clj and put there your system-wide Android-specific options. Then inherit these profiles in the project's :dev and :release profiles (as proposed in the sample)

sakuraiyuta commented 9 years ago

Sorry, I had make same mistake as issue #111. Removed comment-out :dev [;; :android-common :android-user] elements, and worked well. (lein droid build uses my profiler's settings :android-common)

I think good to remove comment-out of keyword :dev [;; :android-common :android-user] by default. What is the reason for comment-out by default? To keep compatibility on older lein-droid?

Anyway, I was a little understanding about profiler. Many thanks for quick response.

alexander-yakushev commented 9 years ago

Here's the reason: if you keep those lines uncommented, and you don't have :android-common and :android-user profiles, Leiningen will complain. It's just a warning, but still a confusing one. I mention the new way of dealing with profiles a several times in Tutorial, so new users should know what's going on, but the users migrating from 0.2.x to 0.3.x might have such difficulties. I'm sorry for that.

sakuraiyuta commented 9 years ago

I also feel that lein-droid is now in the transition period. I know that Leiningen shows warning when :android-common not found, but there's no problem. Rather, it's better way to suggest to users, "You should use :android-common".

lein-droid has continued to glow, It's awesome. Of course, now, many problems remain, to use clojure on android. However, I want to contribute to this project. Thanks!

alexander-yakushev commented 9 years ago

Well, maybe it would be better to uncomment those profiles by default. I will think about it.

sakuraiyuta commented 9 years ago

:+1: