To isolate local artifacts from downloaded one we create a local equivalent of
~/.m2/repositories
.
mkdir -p ~/.m2/local
Clone, build and install alpha.spec (previously spec-alpha2) to the local repository.
# Version extracted from https://github.com/clojure/spec-alpha2/blob/683e507a9647b65a248a5e00d314f9cfaaa2ce56/pom.xml#L5
VERSION="0.2.177-SNAPSHOT"
git clone https://github.com/clojure/spec-alpha2.git
cd spec-alpha2
mvn package
mvn deploy:deploy-file -Durl=file:\${user.home}/.m2/local \
-Dfile=target/alpha.spec-$VERSION.jar \
-DgroupId=org.clojure -DartifactId=alpha.spec -Dversion=$VERSION
In your project, add alpha.spec as a dependency and refer to its local version.
;;; project.clj
:dependencies [[org.clojure/alpha.spec "0.2.177-SNAPSHOT"]]
:repositories {"local" ~(str "file:" (System/getProperty "user.home") "/.m2/local")}
The artifiact should now be available.
$ lein deps
Retrieving org/clojure/alpha.spec/0.2.177-SNAPSHOT/alpha.spec-0.2.177-20200303.104500-1.pom from local
Retrieving org/clojure/alpha.spec/0.2.177-SNAPSHOT/alpha.spec-0.2.177-20200303.104500-1.jar from local
You can now require the lib in your project.
(ns my.namespace
(:require [clojure.alpha.spec :as s]))
NB: If you want to use the generator (e.g. (gen/sample (s/gen ::some-spec))
)
you will need to add test.gen as a dependency.
:dependencies [[org.clojure/alpha.spec "0.2.177-SNAPSHOT"]
[org.clojure/test.check "0.10.0"]]
$ lein deps
Could not find artifact org.clojure:alpha.spec:jar:0.2.177-SNAPSHOT in clojars (https://repo.clojars.org/)
Could not find artifact org.clojure:alpha.spec:jar:0.2.177-SNAPSHOT in local (file:/home/$USER/.m2/local)
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Check that the files are present in your local repository. In this example it
should be located in ~/.m2/local
and contain the files as listed
below.
$ ls ~/.m2/local/org/clojure/alpha.spec
0.2.177-SNAPSHOT maven-metadata.xml maven-metadata.xml.md5 maven-metadata.xml.sha1
Source https://gist.github.com/stuartsierra/3062743