Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:48:15+00:00 2026-05-30T04:48:15+00:00

I have a Leiningen project that is compiling both Java and Clojure files. The

  • 0

I have a Leiningen project that is compiling both Java and Clojure files. The Java files import some of the classes that are generated from the Clojure files (with gen-class).

When I do lein compile, I get compilation errors on the imports in the Java files (saying it can’t find the classes). If I remove the Java files from the project, do lein compile, add the Java files back, and do lein compile again, everything works fine.

So, it’s like the Clojure files need to be compiled before the Java files.

By the way, I am including the Clojure files that gen classes in the :aot list.

What is going wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:48:18+00:00Added an answer on May 30, 2026 at 4:48 am

    (The code in this answer is untested, although it should hopefully work with Leiningen 1.x (for recent values of x).)

    Leiningen’s compile task runs the javac task automatically if your project.clj specifies a :java-source-path. It does so prior to compiling Clojure sources, because I suppose that’s the usual direction of the dependency.

    To get around this, you could use a hook:

    ;;; in leiningen.hooks.clj_first.clj
    
    (ns leiningen.hooks.clj-first
      (:require [leiningen.compile :as leinc]
                [leiningen.javac :as javac]))
    
    (defn compile-clj-first-hook [compile-task project & args]
      (apply compile-task
             (dissoc project :java-source-path)
             args))
      (javac/javac project))
    
    (add-hook #'leiningen.compile/compile compile-clj-first-hook)
    

    Place this somewhere on your build-time classpath and add

    :hooks [clj-first-hook]
    

    to your project map.

    Note that javac, when called directly, will still not call compile. You could also make it equivalent to compile e.g. by hooking it with the following function:

    (defn javac-hook [javac-task project]
      (if (project ::clj-compiled?)
        (javac/javac project)
        (leinc/compile project)))
    

    The last form of compile-clj-first-hook would then need to be

    (javac/javac (assoc project ::clj-compiled? true))
    

    (Making compile not call javac at all would probably break jar / uberjar.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Clojure and Leiningen, and I've determined that some of what I'll
I'm porting working Clojure code (in a Leiningen project) from 1.2 to 1.3 and
I have a Clojure project that I would like to package and use in
Is it possible to include (import?) other files into the project.clj for a clojure
When you create a Clojure project with leiningen all the *.clj-files are compiled AOT.
I have an existing leiningen project, I was wondering if there is anyway leiningen
It seems that whenever I disconnect from clojure slime session, I cannot reconnect again.
Have a photography site that I want to prevent image copying from. How can
In order to do some multi-platform GUI development, I have just switched from GTK
I have recently started out with clojure, and I am using leiningen to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.