Fork me on GitHub
#leiningen
<
2017-03-08
>
xiongtx02:03:53

I’m seeing a problem with a project where: 1. lein clean && lein test works fine 2. lein clean && lein compile && lein trampoline test works fine 3. lein clean && lein trampoline test results in failures in some tests involving types defined using deftype The project.clj contains :aot :all. Removing :aot :all makes the error go away. I suspect what’s happening is that the first JVM compiles the files, then the second JVM loads the files, and now the classes are different somehow…something to do w/ classloaders? I’m certainly not a JVM expert. Has anyone else encountered this issue?

xiongtx03:03:57

Apparently it is due to different classloaders:

Classloader of kafka.serdes.avro_schema.GenericAvroMap:  #object[clojure.lang.DynamicClassLoader 0x7a9c84a5 [email protected]]
Classloader of marshalled value:  #object[sun.misc.Launcher$AppClassLoader 0x4e0e2f2a [email protected]]

timvisher13:03:21

;;; nothing overriden in test profile
;;; lein clean works, with-profile test clean works
(defproject clean-override-lein-bug "0.0.1-SNAPSHOT"
  :description "Is this a bug?"
  :clean-targets ^{:protect false} ["resources"]
  :profiles {:test {;; :clean-targets ^{:protect false} ["resources"]
                    }})

;; $ lein with-profile test clean
;; => 0
;; $ lein clean
;; => 0

;;; clean-targets overridden with metadata in test profile
;;; lein clean works, with-profile test clean fails
(defproject clean-override-lein-bug "0.0.1-SNAPSHOT"
  :description "Is this a bug?"
  :clean-targets ^{:protect false} ["resources"]
  :profiles {:test {:clean-targets ^{:protect false} ["resources"]
                    }})

;; $ lein clean
;; => 0

;; $ lein with-profile test clean
;; Deleting non-target project paths ["resources%s"] is not allowed.
;; Check :clean-targets or override this behavior by adding metadata ->
;;   :clean-targets ^{:protect false} [...targets...]
;; Error encountered performing task 'clean' with profile(s): 'test'
;; Deleting non-target project paths ["resources%s"] is not allowed.
;; Check :clean-targets or override this behavior by adding metadata ->
;;   :clean-targets ^{:protect false} [...targets...]

;;; clean-targets specified at root with no metadata, redefined in test
;;; profile with metadata
;;; lein clean fails, with-profile test clean fails
(defproject clean-override-lein-bug "0.0.1-SNAPSHOT"
  :description "Is this a bug?"
  :clean-targets ["resources"]
  :profiles {:test {:clean-targets ^{:protect false} ["resources"]
                    }})

;; $ lein clean
;; Deleting non-target project paths ["resources%s"] is not allowed.
;; Check :clean-targets or override this behavior by adding metadata ->
;;   :clean-targets ^{:protect false} [...targets...]

;; $ lein with-profile test clean
;; Deleting non-target project paths ["resources%s"] is not allowed.
;; Check :clean-targets or override this behavior by adding metadata ->
;;   :clean-targets ^{:protect false} [...targets...]
;; Error encountered performing task 'clean' with profile(s): 'test'
;; Deleting non-target project paths ["resources%s"] is not allowed.
;; Check :clean-targets or override this behavior by adding metadata ->
;;   :clean-targets ^{:protect false} [...targets...]

;;; metatdata set in root, value overridden in profile.
;;; lein clean works, with-profile test clean fails
(defproject clean-override-lein-bug "0.0.1-SNAPSHOT"
  :description "Is this a bug?"
  :clean-targets ^{:protect false} ["resources"]
  :profiles {:test {:clean-targets ["resources"]}})

;; $ lein clean

;; $ lein with-profile test clean
;; Deleting non-target project paths ["resources%s"] is not allowed.
;; Check :clean-targets or override this behavior by adding metadata ->
;;   :clean-targets ^{:protect false} [...targets...]
;; Error encountered performing task 'clean' with profile(s): 'test'
;; Deleting non-target project paths ["resources%s"] is not allowed.
;; Check :clean-targets or override this behavior by adding metadata ->
;;   :clean-targets ^{:protect false} [...targets...]

timvisher13:03:48

should i be able to use metadata in profiles? am i doing something obviously wrong?