title: Dynamic leiningen :profiles
body: <p>I'm trying to use a function as the value for the <code>:profiles</code> key in a <code>defproject</code> form. Starting from a fresh project (<code>lein new app test</code>) this works fine:</p>
  <pre><code>:profiles {}
  </code></pre>
  <p>(as you might hope!). But if I change it to:</p>
  <pre><code>:profiles (merge {})
  </code></pre>
  <p>then when I run <code>lein repl</code> it explodes:</p>
  <pre><code>Caused by: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.util.Map$Entry
  </code></pre>
  <p>I'm confused by this since if I set <code>:profiles</code> back to the empty map and ask the repl these things are equal:</p>
  <pre><code>test.core=&gt; (= {} (merge {}))
  true
  </code></pre>
  <p>Where is my misunderstanding? Have I missed something basic? Is this an unfortunate artifact of the <code>defproject</code> macro? Something else?</p>
  <p>(clojure 1.8.0, leiningen 2.7.1, java 1.8.0_102)</p>
  <hr />
  <h2>Edit - working solution with Scott's answer:</h2>
  <pre><code>(def project-name 'myproj)
  (def mains [&quot;foo&quot; &quot;bar&quot;])
  ...
  (defn- lein-alias [main]
    { main [&quot;with-profile&quot; main] })
  
  (defn- lein-profile [main]
    (let [jar      (str main &quot;.jar&quot;)
          entry    `~(str project-name &quot;.&quot; main)]
      {(keyword main) {:main          entry 
                       :bin           {:name main}
                       :jar-name      jar
                       :uberjar-name  jar}}))
  
  (defproject project-name &quot;0.1.0&quot;
  ...
    :profiles ~(apply merge (concat (map lein-profile mains) {:uberjar {:aot :all}}))
    :aliases ~(apply merge (map lein-alias mains))
    ...
  </code></pre>
  <p>So now I can <code>lein foo bin</code> and <code>lein bar bin</code> to my heart's content.</p>