could somebody help me out figure out why I'm getting Could not load template, require of after publishing the latest template for Kit?
it looks like the template is up https://clojars.org/io.github.kit-clj/deps-template
but running clojure -Tclj-new create :template io.github.kit-clj :name yourname/guestbook gives an error that template can't be loaded?
@seancorfield any tips?
I see both jars in my .m2 repo locally, and as far as I can tell everything looks fine there, the only change I made in my build was to add a pom.xml template with a license https://github.com/kit-clj/kit/commit/8ff7b5a21ed48ec3c42374e0261c24455a3a622a
If you run it with :verbose 3 (per the suggested output I see from that command), you should see this failure:
Caused by: java.io.FileNotFoundException: Could not locate io/github/kit_clj/deps_template/helpers__init.class, io/github/kit_clj/deps_template/helpers.clj or io/github/kit_clj/deps_template/helpers.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.Trying that in a REPL certainly seems to work tho'...
yeah I saw the trace there, but I'm not sure why it's not finding it
it's this file here https://github.com/kit-clj/kit/blob/master/libs/deps-template/src/io/github/kit_clj/deps_template/helpers.clj
and I see the file in the jar in the m2 repo locally
(in a meeting, will dig in shortly)
thanks, much appreciated, I got kind of stumped on this
It seems that is trying to load that other ns so maybe it isn't on the classpath for your Leiningen template when it runs?
I haven't changed anything in the template though, and this used to work
the lein template explicitly references the deps template as a dependency
https://github.com/kit-clj/kit/blob/master/libs/lein-template/deps.edn#L4
That version doesn't work tho':
(~/clojure)-(!2007)-> clj -Sdeps '{:deps {io.github.kit-clj/deps-template {:mvn/version "0.1.51"}}}'
Downloading: io/github/kit-clj/deps-template/0.1.51/deps-template-0.1.51.pom from clojars
Downloading: io/github/kit-clj/deps-template/0.1.51/deps-template-0.1.51.jar from clojars
Clojure 1.12.0-alpha5
user=> (require 'io.github.kit-clj.deps-template.helpers)
Execution error (FileNotFoundException) at io.github.kit-clj.deps-template.helpers/eval140$loading (helpers.clj:1).
Could not locate selmer/parser__init.class, selmer/parser.clj or selmer/parser.cljc on classpath.
user=>right, and I don't see why
(I was trying the earlier version, which worked)
the jar for the new version looks fine to me
Oh, I bet you didn't update the pom.xml with dependencies
shouldn't it be generated though?
here's the build step https://github.com/kit-clj/kit/blob/master/build.clj#L51
the template pom has
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation=" ">
<licenses>
<license>
<name>MIT License</name>
<url> </url>
</license>
</licenses>
</project> (~/clojure)-(!2009)-> clj -Sdeps '{:deps {io.github.kit-clj/deps-template {:mvn/version "0.1.51"}}}' -Stree
org.clojure/clojure 1.12.0-alpha5
. org.clojure/spec.alpha 0.3.218
. org.clojure/core.specs.alpha 0.2.62
io.github.kit-clj/deps-template 0.1.51
Wed Jan 03 13:22:22
(~/clojure)-(!2010)-> clj -Sdeps '{:deps {io.github.kit-clj/deps-template {:mvn/version "0.1.47"}}}' -Stree
org.clojure/clojure 1.12.0-alpha5
. org.clojure/spec.alpha 0.3.218
. org.clojure/core.specs.alpha 0.2.62
io.github.kit-clj/deps-template 0.1.47
. selmer/selmer 1.12.50
. babashka/fs 0.1.6so why is this happening?
You've got a lot going on in that build.clj that I don't have time to debug right now but I would recommend not putting a template pom.xml at the top-level of the repo -- it'll mess up tooling that tries to analyze your project.
(see the http://clojure-doc.org tools.build cookbook for information about that)
I was actually tried to use :pom-data at first, but that seemed to have no effect
I'll try moving the pom out of the root folder see what happens
although the pom for each library does get generated in its own folder
this still doesn't make sense to me to be honest
Your tools.build is too old for :pom-data. Needs to be 0.9.6
because the template pom doesn't contain any dependencies
I looked in the 0.1.51 JAR and the pom has
<dependencies>
<dependency>
<groupId>selmer</groupId>
<artifactId>selmer</artifactId>
<version>1.12.50</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.11.1</version>
</dependency>
<dependency>
<groupId>babashka</groupId>
<artifactId>fs</artifactId>
<version>0.1.6</version>
</dependency>
</dependencies>oh I see, let me try switch to using that
So I'm a bit puzzled.
right, the jar that gets built seems fine
but yeah let me try bump up tools.build, that might be an issue with it being so old
The only difference I can see in the 0.1.51 and 0.1.47 pom.xml files is that 0.1.47 has <modelVersion>4.0.0</modelVersion> and <packaging>jar</packaging> but 0.1.51 does not. The Maven spec says the former is required (but I think the latter is a default).
ok that worked, I bumped up to 0.9.6 and switched to using pom-data
and maybe that trips up some check in the pom parser?
Ah, if modelVersion and packaging are not in the src-pom, tools.deps does not add them -- but if you do not provide a src-pom, it does add them!
thanks for the help debugging, I always forget to think about updating the dependencies before going down a rabbit hole 🙂
ah ok that makes sense, so I guess with the providing a template pom file, just have to add more defaults to it
I bet if you use pom-data instead, you get modelVersion and packaging
yeah looks that way
I could've saved myself a lot of time if I just thought of bumping up tools.build version
You don't have any scm stuff in there either -- so http://cljdoc.org fails to import anything: https://cljdoc.org/d/io.github.kit-clj/deps-template/0.1.51
https://clojure-doc.org/articles/cookbooks/cli_build_projects/#the-generated-pomxml-file shows all the stuff you want in there for pom-data -- in the pom-template function
ah yeah that's handy, I think pom-data makes more sense in my case
and thanks again for the help!
Glad we got to the bottom of it. That was a weird one.
Esp. that there was no error from omitting modelVersion...
indeed, it might actually be worth adding an explicit section on the cookbook to contrast using pom.xml vs pom-data in terms of defaults
it's easy to miss, but tricky to debug
https://github.com/clojure-doc/clojure-doc.github.io/issues/67
now I'm wondering if the behavior in tools.build is intentional or accidental, it would be nice if both ways worked consistently
The docs are pretty clear about what it replaces or adds if you provide a src-pom but I think they are less clear about what it creates by default.
right, and the general intent with both src-pom and pom-data appears to be the same, so adding consistent set of defaults in both cases would be a lot less error prone
I would say they are not the same.
src-pom is intended to provide a fully-fleshed pom.xml that tools.deps only updates/adds specific items to. pom-data is purely additive, so you are telling tools.deps to create its pom.xml as usual but also add the top-level data you provide.
yeah I guess it's where the process starts is the key difference
with one you're working off a template and injecting into it
and with the other you synthesize the pom and add stuff to it after
There's a bunch of stuff I used to have in my template pom.xml file -- licenses, developers, scm, etc. It was a full pom.xml except for dependencies and the version.
now I have a bit better understanding of what's happening with the poms 🙂