Welcome! Please see the About page for a little more info on how this works.

0 votes
in tools.deps by
retagged by

I have some questions about the logic behind the clj -Spom command

  • Why adds a sourceDirectory tag at the top level? Seems an invalid tag, mvn validate complaints with an unrecognized tag error.

  • Every time I re-run clj -Spom a new sourceDirectory tag is created, adding duplicated values, is it intended?

  • Why only the first element in :src is used to populate the sourceDirectory while the rest are ignored?

1 Answer

0 votes

I can't reproduce what you're seeing - it should add at <project>/<build>/<sourceDirectory>. You might double-check that you are using the newest version of clj ( at this moment). If you are still seeing this behavior, please provide your clj version (clj -Sdescribe), java version (java -version) and a deps.edn to repro with.

Regarding your last question, there is only a slot in the pom for a single source directory. There a variety of plugins and configuration setups that can address this but what you do really depends a lot on what you're doing. Rather than make a choice here, -Spom will just skip all dirs after the first one. If you specify other build config it should be left intact.

Thanks for your answer @alexmiller

To reproduce what I described in the first and second point, run `clj -Spom` in a directory with only a `pom.xml` file without `<project>/<build>/<sourceDirectory>`, e.g.:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

I have only the `pom.xml` file in the directory, there are no other files.
Now every time you run `clj -Spom`, a new `<project>/<sourceDirectory>` tag is added.

I tested it with the latest clj version:

clj -Sdescribe:

{:version ""
 :config-files ["/nix/store/9fqcvxrqayhhn1b87ys7lwnlqdv2ja5x-clojure-" "/home/jlle/.clojure/deps.edn" ]
 :config-user "/home/jlle/.clojure/deps.edn"
 :config-project "deps.edn"
 :install-dir "/nix/store/9fqcvxrqayhhn1b87ys7lwnlqdv2ja5x-clojure-"
 :config-dir "/home/jlle/.clojure"
 :cache-dir "/home/jlle/.clojure/.cpcache"
 :force false
 :repro false
 :resolve-aliases ""
 :classpath-aliases ""
 :jvm-aliases ""
 :main-aliases ""
 :all-aliases ""}

java -version:

openjdk version "11.0.6-internal" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6-internal+0-adhoc..jdk11u-jdk-11.0.6-ga)
OpenJDK 64-Bit Server VM (build 11.0.6-internal+0-adhoc..jdk11u-jdk-11.0.6-ga, mixed mode)

I'm not providing a `deps.edn` file because I can reproduce it without any.
Thanks, that helped. Logged as https://clojure.atlassian.net/browse/TDEPS-152 and I'll try to get to it soon.