leiningen icon indicating copy to clipboard operation
leiningen copied to clipboard

Automatic `clean` before `deploy` can break Cljx lib releases

Open ptaoussanis opened this issue 11 years ago • 4 comments

Hi there!

v2.4.0 introduced the following change: Automatically clean before deploy to avoid AOT in libraries. (Phil Hagelberg). Not sure if this was discussed somewhere - struggling to find the relevant issue?

Anyway, this change can break libraries that use Cljx transforms that output to a clean target path (handy, quite common, and currently recommended by the Cljx docs).

Is this something that was considered? Is there a recommended workaround? Is there a way to disable the new [auto cleaning] behaviour?

Thanks a lot, cheers! :-)

UPDATE: Found the original issue motivating this change: https://github.com/technomancy/leiningen/issues/1512 UPDATE 2: Okay, found the :auto-clean false project.clj option. Will keep digging to understand this better.

ptaoussanis avatar Jul 04 '14 11:07 ptaoussanis

The best way to handle this would be to include whatever's writing to target/classes in :prep-tasks so that it happens after the clean. But if you can't do that for whatever reason, then :auto-clean is the way to go.

technomancy avatar Jul 04 '14 17:07 technomancy

Great, thanks Phil! Appreciate the quick response - cheers :-)

ptaoussanis avatar Jul 04 '14 17:07 ptaoussanis

Unfortunately this is not only about target/classes but everything defined as part of clean-targets. This essentially breaks any task generating sources / tests that should be packaged in the resulting jar. Right now any such project must rely on :auto-clean false. Also I find it pretty unexpected that the clean task can be called automatically part of a task lifecycle.

Maybe just excluding target/classes would be sufficient to address #1512 ?

jeluard avatar Sep 20 '14 19:09 jeluard

AFAICT, just using :prep-tasks is not sufficient to address this, :auto-clean false must also be added. I had to use both in double-check (see referenced commit above) in order to prod Leiningen into actually adding generated sources into the jar to be deployed.

What am I doing wrong here? Reopening so that the thread isn't lost.

Meta: it again seems like the challenges posed by AOT are forcing those of us not using AOT to babysit our builds to restore basic behaviour (in this case "stuff that's in target/classes goes into the jar").

cemerick avatar Dec 11 '14 12:12 cemerick