How to fix leiningen :aot warning
Asked Answered
S

1

16

I am getting

Warning: specified :main without including it in :aot.
If you only need AOT for your uberjar, consider adding :aot :all into your
:uberjar profile instead.

Here is my project.clj

(defproject korma-test "0.1.0-SNAPSHOT"
  :description "korma db test"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [korma "0.3.0-RC5"]
                 ]
   :main korma-test.core)

and here is core.clj

(ns korma-test.core
  (require [korma.db :as kdb])
  (require [clojure.string :as str])
  (:use [clojure.tools.cli])
  (:import java.util.Date)
  (:gen-class)
)
; Parses for options passed in on the command line.

(defn parse-opts
  "Using the newer cli library, parses command line args."
  [args]
  (cli args
       (optional ["-host" "Informix host" :default "localhost"] )
       (optional ["-port" "Informix host's service port" :default "1498"] )
       (required ["-username" "user name"] )
       (required ["-password" "password"] )
       (optional ["-database" "Informix host's database" :default "stores7/ministores.dbs" ] )))


(defn -main 
  [& args]
  (if (= 0 (count args))
    (println "Usage: korma-test --host <host-name> --port <port-num> --database <db-name>")
    (let [opts (parse-opts args)
          start-time (str (Date.))]
          (def db-config {:classname "com.informix.jdbc.IfxDriver"
                          :subprotocol "postgresql"
                          :subname (format "//%s:(:port opts)/%s" 
                                           (:host opts)
                                           (:database opts))
                          :user (:user opts)
                          :password (:password opts)})

          (kdb/defdb db db-config)

    (println opts))))

I'm confused as to where to put :aot to satisfy the warning.

Shortcake answered 5/3, 2014 at 19:6 Comment(2)
What version of leiningen are you running and when do you get the warning?Coniferous
@Coniferous My fault for not posting all of core.clj. I get this error Warning: specified :main without including it in :aot. Implicit AOT of :main will be removed in Leiningen 3.0.0. If you only need AOT for your uberjar, consider adding :aot :all into your :uberjar profile instead. even with a main function.Shortcake
C
14

I could have sworn it worked without warning before but in any case you now need to add an :aot directive in your project.clj See here

The following works

project.clj

(defproject korma-test "0.1.0-SNAPSHOT"
  :description "korma db test"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [korma "0.3.0-RC5"]
                 [org.clojure/tools.cli "0.3.1"]]
   :main korma-test.core
   :aot [korma-test.core])

core.clj

(ns korma-test.core
  (:require [korma.db :as kdb])
  (:require [clojure.string :as str])
  (:require [clojure.tools.cli :as c])
  (:import java.util.Date)
  (:gen-class))

; Parses for options passed in on the command line.

    (defn parse-opts
      "Using the newer cli library, parses command line args."
      [args]
      (c/cli args
           [ ["-host" "Informix host" :default "localhost"] 
            ["-port" "Informix host's service port" :default "1498"] 
            ["-username" "user name"] 
            ["-password" "password"] 
            ["-database" "Informix host's database" :default "stores7/ministores.dbs" ]]))


(defn -main 
  [& args]
  (if (= 0 (count args))
    (println "Usage: korma-test --host <host-name> --port <port-num> --database <db-name>")
    (let [opts (parse-opts args)
          start-time (str (Date.))
          db-config {:classname "com.informix.jdbc.IfxDriver"
                          :subprotocol "postgresql"
                          :subname (format "//%s:(:port opts)/%s" 
                                           (:host opts)
                                           (:database opts))
                          :user (:user opts)
                          :password (:password opts)}]
          (kdb/defdb db db-config)
    (println opts))))
Coniferous answered 5/3, 2014 at 20:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.