Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with lein-cljsbuild and lein-monolith #465

Closed
chrisbetz opened this issue Jun 13, 2017 · 9 comments
Closed

Problem with lein-cljsbuild and lein-monolith #465

chrisbetz opened this issue Jun 13, 2017 · 9 comments

Comments

@chrisbetz
Copy link

Hi,

we're trying to use lein-monolith for building our Clojure/ClojureScript application. Unfortunately, lein-monolith does clash with lein-cljsbuild.

You can see this using the example repo from our fork.

Running

DEBUG=1 lein monolith each :in app-b do clean, cljsbuild once

from project root (monolith-path) is compiling clojurescript, but does not produce a result (as you can see in the output: there is no line like this
Compiling "js/compiled/app.js" from ["src/cljs"].... (see below for full output).

Same is true if we're using hooks to run cljs compiler on regular leiningen tasks.

I also opened an issue on the lein-monolith repo, but I'm just not sure where the problem is located.

I would be very grateful for any hints on this. :)


Build from monolith project

~/Projects/lein-monolith/example   master  DEBUG=1 lein monolith each :in app-b do clean, cljsbuild once
Leiningen's classpath: :/usr/local/Cellar/leiningen/2.6.1/libexec/leiningen-2.6.1-standalone.jar
Applying task monolith to [each :in app-b do clean, cljsbuild once]
Elapsed: find-monolith => 0,065 ms
Found monolith project rooted at /Users/cb/Projects/lein-monolith/example
Reading subproject definition from /Users/cb/Projects/lein-monolith/example/apps/app-a/project.clj
Reading subproject definition from /Users/cb/Projects/lein-monolith/example/apps/app-b/project.clj
Reading subproject definition from /Users/cb/Projects/lein-monolith/example/libs/lib-a/project.clj
Reading subproject definition from /Users/cb/Projects/lein-monolith/example/libs/lib-b/project.clj
Elapsed: read-subprojects! => 17,266 ms
Applying do clean, cljsbuild once to 1 subprojects...

Applying to example/app-b
Elapsed: init-subproject => 99,754 ms
Applying task do to [clean, cljsbuild once]
Applying task clean to []
Applying task cljsbuild to [once]
Compiling ClojureScript...
Elapsed: apply-task => 6217,942 ms
Completed example/app-b (1/1) in 0:06.320

SUCCESS: Applied do clean, cljsbuild once to 1 projects in 0:06.477

Build from sub-project

(not what I was trying to achieve, just for showing the actual correctness of our configuration)

 ~/Projects/lein-monolith/example   master ●  cd apps/app-b 
 cb@chris  ~/Projects/lein-monolith/example/apps/app-b   master ●  DEBUG=1 lein do clean, cljsbuild once
Leiningen's classpath: :/usr/local/Cellar/leiningen/2.6.1/libexec/leiningen-2.6.1-standalone.jar
Applying task do to [clean, cljsbuild once]
Applying task clean to []
Applying task cljsbuild to [once]
Compiling ClojureScript...
Compiling "js/compiled/app.js" from ["src/cljs"]...
Successfully compiled "js/compiled/app.js" in 15.613 seconds.
@chrisbetz
Copy link
Author

BTW: lein version -> Leiningen 2.6.1 on Java 1.8.0_66 Java HotSpot(TM) 64-Bit Server VM

@mneise
Copy link
Collaborator

mneise commented Jul 5, 2017

Thank you for the detailed description and for the example repo. Much appreciated 👍

I was able to reproduce your results. It seems that the build process is started (there is a Compiling ClojureScript... line in the output), but is terminated before producing a result. But that is just a first guess. I would need to do some further digging into how lein-monolith works.

@chrisbetz
Copy link
Author

:) If you need any further help, info, anything, just let me know.

BTW: My guess is the "location" of the source folder is not found - as the build process is started, but doesn't really compile a thing. However, if started from the sub-project dir, everything is in place as cljsbuild expects it. Just my two cents.

@mneise
Copy link
Collaborator

mneise commented Jul 6, 2017

Yes, you are right 👍 It looks for the source files in the directory where the build command was executed in, so for your example it looks in lein-monolith/example instead of lein-monolith/example/apps/app-b. (https://github.com/emezeske/lein-cljsbuild/blob/1.1.6/support/src/cljsbuild/compiler.clj#L139)

Seems like Leiningen passes a :root property in the project description, e.g. :root ~/Projects/lein-monolith/example/apps/app-b, which I can hopefully use for fixing this.

mneise added a commit that referenced this issue Jul 13, 2017
The working directory is usually the project's home directory, except
when using lein-monolith. If lein-monolith is used we need to adjust the
source-paths to be relative to the current working directory, so that
the compiler can find the source files.
@mneise
Copy link
Collaborator

mneise commented Jul 13, 2017

@chrisbetz Just pushed a first version of the fix to master and deployed it as 1.1.7-SNAPSHOT. cljsbuild finds the files now and builds the project, but outputs the result to the current working directory, so still need to fix this part 😉

@chrisbetz
Copy link
Author

@mneise That's gorgeous. I'm happy to hear you found a possibility to fix things. Really looking forward. We're in the middle of a new release of our software, so I won't be able to check today or next monday, but I will try to look into 1.1.7-SNAPSHOT on tuesday to see if I can provide you with feedback on things (if you like). Really, really appreciating your work :) Thanx!

@mneise
Copy link
Collaborator

mneise commented Jul 15, 2017

@chrisbetz I found a better fix for this.

Cljsbuild creates a new subprocess to run the compiler and the working directory for the subprocess wasn't set correctly, since cljsbuild didn't include the :root key in the project map. It should find the files now and also output the result to the right place.

Let me know if you run into any more problems 😉

@thron7
Copy link

thron7 commented Jul 19, 2017

@mneise Hi Maria, which version contains your latest fix for this?

@mneise
Copy link
Collaborator

mneise commented Jul 19, 2017

@thron7 You can try it out using 1.1.7-SNAPSHOT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants