简体   繁体   中英

How can you make leiningen evaluate requires before implements?

This seems to be a bug but I would like to know if there is a way to get around this problem.

I have a class defined as follows

(ns myns.myext.anotherext.client
  (:gen-class 
     :implements [myns.myext.core.client]
     :prefix -
     :init init
     :state state
   )
   (:require [myns.myext.core])
)

I don't know if it is obvious but the myns.myext.core.client is a definterface in myns.myext.core as follows...

(ns myns.myext.core)

(definterface client
  (^void foo [])
)

This is a library that has no main but it will not compile. It is getting a class not found exception because it is trying to compile the myns.myext.core.client before the myns.myext.core . Is there any hack I can use to force liningen to compile these in the correct order? The project definition is using :aot :all . There is no problem with the code because if I comment out the implements in the gen class, compile, uncomment the implements and recompile it works fine. End users can't be expected to be altering code just to get libraries to compile.

Version: Leiningen 2.3.4 on Java 1.7.0_55 Java HotSpot(TM) 64-Bit Server VM

Just write the require before the gen-class. Code should be evaluated in order.

Outside this site I was pointed to a solution which worked. I added the following to my project.clj which is the only thing that solved the problem for me.

  :prep-tasks [["compile" "myns.myext.core"]
               "javac" "compile"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM