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

+1 vote
in tools.build by
recategorized by

To work appropriately in the Java ecosystem, optional dependencies for libraries can be included with scope 'provided' within a pom.xml file.

deps.edn explicitly does not support including dependencies with a scope of 'provided', in favour of using aliases.

In order to work well as a library within a wider Java ecosystem, it would be very helpful to be able to write out a library jar file with a pom.xml file with additional dependencies that are not included in deps.edn, but with a scope of 'provided' for Java build tools.

An example is cljdoc, which cannot build documentation when a library is built and all dependencies are not included appropriately.

'write-pom' already has an option to include a template 'source' pom.xml, but the dependencies are overwritten with information from the deps.edn file.

There are workarounds - e.g. see thread https://clojurians.slack.com/archives/C8V0BQ0M6/p1680090647156119 which patch the process to include deps with a 'provided' scope - but they are not ideal.


  1. do nothing - we monkey patch tools.build as per Slack thread example, or otherwise alter the generated pom.xml to include additional 'provided' scope deps.

  2. merge existing dependencies from the source (template) pom.xml instead of overwriting [but perhaps a breaking change]

  3. provide an additional parameter to 'write-pom' to include arbitrary deps, a sequence of maps that are converted to XML including :scope which would be :provided for these optional dependencies.

  4. work with cljdoc to support aliases so that documentation builds can be customised by library authors so builds such as this do not fail.

1 Answer

+2 votes
I think I would lean towards #3 on first impression.
By following #3, will it be possible to have something like `:pom-plugins` Leiningen equivalent, that will generate `<plugins><plugin>...</plugin></plugins>` block?

Or is there are better way to add a custom maven blocks? Some maven plugins can add new elements and attributes as well.
For sections other than :dependencies, :repositories, and the few other things we set, it's best to put that info in the template pom.xml.