Skip to content

Commit

Permalink
Merge branch 'master' of github.com:clojure/tools.build into merge-up…
Browse files Browse the repository at this point in the history
…stream
  • Loading branch information
borkdude committed Feb 5, 2024
2 parents 15b5f83 + 534e07e commit c4a748f
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 48 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ jobs:
test:
strategy:
matrix:
java-version: ["8", "11", "17"]
java-version: ["8", "11", "17", "21"]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Prepare java
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: ${{ matrix.java-version }}

- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@3.6
uses: DeLaGuardo/setup-clojure@12.1
with:
cli: 1.10.3.1040
cli: 1.11.1.1413

- name: Checkout
uses: actions/checkout@v2-beta
uses: actions/checkout@v4

- name: Run tests not Windows
if: ${{ matrix.os != 'windows-latest' }}
Expand Down
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Changelog
===========

<<<<<<< HEAD
* next
* uber - fix exlcusions and conflict handling when including local deps on windows
* v0.9.6 8e78bcc on Oct 6, 2023
* write-pom - add :pom-data to supply extra pom data when generating a new pom
* uber - fix exclusions and conflict handling when including local deps on windows
* v0.9.5 24f2894 on Aug 11, 2023
* java-command - TBUILD-14 Use :jvm-opts from aliases in basis, if provided
* Update to latest deps
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ Latest release:
As a git dep:

```clojure
io.github.clojure/tools.build {:git/tag "v0.9.5" :git/sha "24f2894"}
io.github.clojure/tools.build {:git/tag "v0.9.6" :git/sha "8e78bcc"}
```

As a Maven dep:

```clojure
io.github.clojure/tools.build {:mvn/version "0.9.5"}
io.github.clojure/tools.build {:mvn/version "0.9.6"}
```

# Developer Information
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

;; Lint the source
;; clj -M:lint
:lint {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.07.13"}}
:lint {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.09.07"}}
:main-opts ["-m" "clj-kondo.main" "--lint" "src"]}
}
}
17 changes: 14 additions & 3 deletions docs/clojure.tools.build.api.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
Use `resolve-path` to resolve relative paths in terms of the *project-root*.
Use `set-project-root!` to override the default for all tasks.</pre></div></div><div class="public anchor" id="var-compile-clj"><h3>compile-clj</h3><div class="usage"><code>(compile-clj params)</code></div><div class="doc"><pre class="plaintext">Compile Clojure source to classes in :class-dir.

Clojure source files are found in :basis paths by default, else in :src-dirs.
Clojure source files are found in :basis :paths by default, or override with :src-dirs.

Namespaces and order of compilation are one of:
* :ns-compile - compile these namespaces, in this order
* :sort - find all namespaces in source dirs and use either :topo (default)
* :sort - find all namespaces in source files and use either :topo (default)
or :bfs to order them for compilation

Options:
Expand Down Expand Up @@ -274,7 +274,18 @@
See: <a href="https://maven.apache.org/pom.html#SCM">https://maven.apache.org/pom.html#SCM</a> for details
:src-dirs - coll of src dirs
:resource-dirs - coll of resource dirs
:repos - map of repo name to repo config, replaces repos from deps.edn</pre></div></div><div class="public anchor" id="var-zip"><h3>zip</h3><div class="usage"><code>(zip params)</code></div><div class="doc"><pre class="plaintext">Create zip file containing contents of src dirs. Returns nil.
:repos - map of repo name to repo config, replaces repos from deps.edn
:pom-data - vector of hiccup-style extra pom top elements to include when
no :src-pom is provided:
[[:licenses
[:license
[:name "Eclipse Public License 1.0"]
[:url "<a href="https://opensource.org/license/epl-1-0/&quot;">https://opensource.org/license/epl-1-0/"</a>;]
[:distribution "repo"]]]
[:organization "Super Corp"]]
The pom-data MUST NOT include:
:modelVersion, :packaging, :groupId, :artifactId, :version, :name,
:deps, :repositories, :build, or :scm</pre></div></div><div class="public anchor" id="var-zip"><h3>zip</h3><div class="usage"><code>(zip params)</code></div><div class="doc"><pre class="plaintext">Create zip file containing contents of src dirs. Returns nil.

Options:
:src-dirs - required, coll of source directories to include in zip
Expand Down
131 changes: 128 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,128 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title> </title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name"></span> <span class="project-version"></span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 current"><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1 "><a href="clojure.tools.build.api.html"><div class="inner"><span>clojure.tools.build.api</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name"></span> <span class="project-version"></span></span></h1><h2>Namespaces</h2><div class="namespace"><h3><a href="clojure.tools.build.api.html">clojure.tools.build.api</a></h3><div class="doc"><pre class="plaintext"></pre></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="clojure.tools.build.api.html#var-*project-root*">*project-root*</a> </li><li> <a href="clojure.tools.build.api.html#var-compile-clj">compile-clj</a> </li><li> <a href="clojure.tools.build.api.html#var-copy-dir">copy-dir</a> </li><li> <a href="clojure.tools.build.api.html#var-copy-file">copy-file</a> </li><li> <a href="clojure.tools.build.api.html#var-create-basis">create-basis</a> </li><li> <a href="clojure.tools.build.api.html#var-delete">delete</a> </li><li> <a href="clojure.tools.build.api.html#var-git-count-revs">git-count-revs</a> </li><li> <a href="clojure.tools.build.api.html#var-git-process">git-process</a> </li><li> <a href="clojure.tools.build.api.html#var-install">install</a> </li><li> <a href="clojure.tools.build.api.html#var-jar">jar</a> </li><li> <a href="clojure.tools.build.api.html#var-java-command">java-command</a> </li><li> <a href="clojure.tools.build.api.html#var-javac">javac</a> </li><li> <a href="clojure.tools.build.api.html#var-pom-path">pom-path</a> </li><li> <a href="clojure.tools.build.api.html#var-process">process</a> </li><li> <a href="clojure.tools.build.api.html#var-resolve-path">resolve-path</a> </li><li> <a href="clojure.tools.build.api.html#var-set-project-root.21">set-project-root!</a> </li><li> <a href="clojure.tools.build.api.html#var-uber">uber</a> </li><li> <a href="clojure.tools.build.api.html#var-unzip">unzip</a> </li><li> <a href="clojure.tools.build.api.html#var-with-project-root">with-project-root</a> </li><li> <a href="clojure.tools.build.api.html#var-write-file">write-file</a> </li><li> <a href="clojure.tools.build.api.html#var-write-pom">write-pom</a> </li><li> <a href="clojure.tools.build.api.html#var-zip">zip</a> </li></ul></div></div></div></body></html>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.clojure</groupId>
<artifactId>tools.build</artifactId>
<version>0.9.7-SNAPSHOT</version>
<name>tools.build</name>

<parent>
<groupId>org.clojure</groupId>
<artifactId>pom.contrib</artifactId>
<version>1.1.0</version>
</parent>

<developers>
<developer>
<id>puredanger</id>
<name>Alex Miller</name>
</developer>
</developers>

<properties>
<!-- used for build -->
<clojure.warnOnReflection>true</clojure.warnOnReflection>
<clojure.version>1.11.1</clojure.version>
</properties>

<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>${clojure.version}</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.deps</artifactId>
<version>0.18.1354</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.namespace</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.36</version>
</dependency>
</dependencies>

<!-- overrides parent pom to set repo to s01 (the "new" repo) -->
<distributionManagement>
<snapshotRepository>
<!-- This id is linked to the key setup on the CI server -->
<id>sonatype-nexus-staging</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<!-- By default, compile everything as a sanity check, but do
not include any AOT-compiled .class files in the
JAR. Projects may override as needed. -->
<groupId>com.theoryinpractise</groupId>
<artifactId>clojure-maven-plugin</artifactId>
<version>1.7.1</version>
<extensions>true</extensions>
<configuration>
<warnOnReflection>${clojure.warnOnReflection}</warnOnReflection>
<temporaryOutputDirectory>true</temporaryOutputDirectory>
</configuration>
<executions>
<execution>
<id>clojure-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>clojure-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- overrides parent pom because new projects are going to different staging repo - s01 -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<!-- The server "id" element from settings to use authentication from -->
<serverId>sonatype-nexus-staging</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>

<scm>
<connection>scm:git:[email protected]:clojure/tools.build.git</connection>
<developerConnection>scm:git:[email protected]:clojure/tools.build.git</developerConnection>
<url>[email protected]:clojure/tools.build.git</url>
<tag>HEAD</tag>
</scm>

<repositories>
<repository>
<id>clojars</id>
<url>https://clojars.org/repo/</url>
</repository>
</repositories>
</project>
20 changes: 16 additions & 4 deletions src/main/clojure/clojure/tools/build/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@
(defn compile-clj
"Compile Clojure source to classes in :class-dir.
Clojure source files are found in :basis paths by default, else in :src-dirs.
Clojure source files are found in :basis :paths by default, or override with :src-dirs.
Namespaces and order of compilation are one of:
* :ns-compile - compile these namespaces, in this order
* :sort - find all namespaces in source dirs and use either :topo (default)
* :sort - find all namespaces in source files and use either :topo (default)
or :bfs to order them for compilation
Options:
Expand Down Expand Up @@ -386,7 +386,18 @@
See: https://maven.apache.org/pom.html#SCM for details
:src-dirs - coll of src dirs
:resource-dirs - coll of resource dirs
:repos - map of repo name to repo config, replaces repos from deps.edn"
:repos - map of repo name to repo config, replaces repos from deps.edn
:pom-data - vector of hiccup-style extra pom top elements to include when
no :src-pom is provided:
[[:licenses
[:license
[:name \"Eclipse Public License 1.0\"]
[:url \"https://opensource.org/license/epl-1-0/\"]
[:distribution \"repo\"]]]
[:organization \"Super Corp\"]]
The pom-data MUST NOT include:
:modelVersion, :packaging, :groupId, :artifactId, :version, :name,
:deps, :repositories, :build, or :scm"
[params]
(assert-required "write-pom" params [:basis :lib :version])
(assert-specs "write-pom" params
Expand All @@ -397,7 +408,8 @@
:version string?
:scm map?
:src-dirs ::specs/paths
:resource-dirs ::specs/paths)
:resource-dirs ::specs/paths
:pom-data vector?)
((requiring-resolve 'clojure.tools.build.tasks.write-pom/write-pom) params))

(defn jar
Expand Down
64 changes: 38 additions & 26 deletions src/main/clojure/clojure/tools/build/tasks/write_pom.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[clojure.data.xml :as xml]
[clojure.data.xml.tree :as tree]
[clojure.data.xml.event :as event]
[clojure.walk :as walk]
[clojure.zip :as zip]
[clojure.tools.deps.util.maven :as maven]
[clojure.tools.deps.util.io :refer [printerrln]]
Expand All @@ -23,6 +24,8 @@
[java.util Date]))

(xml/alias-uri 'pom "http://maven.apache.org/POM/4.0.0")
(def ^:private pom-ns (name (.-name ^clojure.lang.Namespace (get (ns-aliases *ns*) 'pom))))


(defn- to-dep
[[lib {:keys [mvn/version exclusions optional] :as coord}]]
Expand Down Expand Up @@ -88,35 +91,43 @@
[::pom/repositories
(map to-repo repos)])

(defn- pomify
[val]
(if (and (vector? val) (keyword? (first val)))
(into [(keyword pom-ns (name (first val)))] (rest val))
val))

(defn- gen-pom
[{:keys [deps src-paths resource-paths repos group artifact version scm]
[{:keys [deps src-paths resource-paths repos group artifact version scm pom-data]
:or {version "0.1.0"}}]
(let [[path & paths] src-paths
{:keys [connection developerConnection tag url]} scm]
(xml/sexp-as-element
[::pom/project
{:xmlns "http://maven.apache.org/POM/4.0.0"
(keyword "xmlns:xsi") "http://www.w3.org/2001/XMLSchema-instance"
(keyword "xsi:schemaLocation") "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"}
[::pom/modelVersion "4.0.0"]
[::pom/packaging "jar"]
[::pom/groupId group]
[::pom/artifactId artifact]
[::pom/version version]
[::pom/name artifact]
(gen-deps deps)
(when (or path (seq resource-paths))
(when (seq paths) (apply printerrln "Skipping paths:" paths))
[::pom/build
(when path (gen-source-dir path))
(when (seq resource-paths) (gen-resources resource-paths))])
(gen-repos repos)
(when scm
[::pom/scm
(when connection [::pom/connection connection])
(when developerConnection [::pom/developerConnection developerConnection])
(when tag [::pom/tag tag])
(when url [::pom/url url])])])))
(into
[::pom/project
{:xmlns "http://maven.apache.org/POM/4.0.0"
(keyword "xmlns:xsi") "http://www.w3.org/2001/XMLSchema-instance"
(keyword "xsi:schemaLocation") "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"}
[::pom/modelVersion "4.0.0"]
[::pom/packaging "jar"]
[::pom/groupId group]
[::pom/artifactId artifact]
[::pom/version version]
[::pom/name artifact]
(gen-deps deps)
(when (or path (seq resource-paths))
(when (seq paths) (apply printerrln "Skipping paths:" paths))
[::pom/build
(when path (gen-source-dir path))
(when (seq resource-paths) (gen-resources resource-paths))])
(gen-repos repos)
(when scm
[::pom/scm
(when connection [::pom/connection connection])
(when developerConnection [::pom/developerConnection developerConnection])
(when tag [::pom/tag tag])
(when url [::pom/url url])])]
(walk/postwalk pomify pom-data)))))

(defn- make-xml-element
[{:keys [tag attrs] :as node} children]
Expand Down Expand Up @@ -221,7 +232,7 @@

(defn write-pom
[params]
(let [{:keys [basis class-dir target src-pom lib version scm src-dirs resource-dirs repos]} params
(let [{:keys [basis class-dir target src-pom lib version scm src-dirs resource-dirs repos pom-data]} params
{:keys [libs]} basis
root-deps (libs->deps libs)
src-pom-file (api/resolve-path (or src-pom "pom.xml"))
Expand All @@ -246,7 +257,8 @@
:group (namespace lib)
:artifact (name lib)}
version (assoc :version version)
scm (assoc :scm scm))))
scm (assoc :scm scm)
pom-data (assoc :pom-data pom-data))))
pom-dir-file (file/ensure-dir
(cond
class-dir (jio/file (api/resolve-path class-dir) (meta-maven-path {:lib lib}))
Expand Down
Loading

0 comments on commit c4a748f

Please sign in to comment.