leiningen with multiple main classes

后端 未结 3 634
别跟我提以往
别跟我提以往 2021-02-02 13:56

I\'d like to have two main classes (or more) with leiningen, and then be able to choose which one at the java command line. For example I have:

(ns abc (:gen-cla         


        
3条回答
  •  后悔当初
    2021-02-02 14:42

    This works at least with leiningen 2.0+

    (defproject my-jar "0.0.1"
     :description "test"
     :dependencies [
     ]
     :profiles {:main-a {:main abc}
               {:main-b {:main def}}
     :aliases {"main-a" ["with-profile" "main-a" "run"]
               "main-b" ["with-profile" "main-b" "run"]})
    

    Then you can run each main like so:

    lein main-a
    lein main-b
    

    Which expands to this:

    lein with-profile main-a run
    lein with-profile main-b run
    

    I'm using this in one of my projects and it works perfectly.

提交回复
热议问题