lice-comb.maven
Functionality related to combing Maven POMs for license information.
In this namespace abbreviations are used for Maven’s groupId, artifactId, and version concepts. So for example:
GA
means groupId & artifactIdGAV
means groupId, artifactId & version
In function calls where a version isn’t required or provided, the library will determine and use the latest available version, as determined from (in order):
- your local Maven cache (usually ~/.m2/repository)
- remote Maven artifact repositories (e.g. Maven Central, CLojars)
Other/custom Maven artifact repositories are supported via the set-local-maven-repo!
and set-remote-maven-repos!
fns.
default-local-maven-repo
A String
containing a file path for the default local Maven artifact cache that the library uses. Attempts to use this Maven client command to determine this value by default:
mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout
but falls back on a “best guess” if the Maven client isn’t installed or cannot be executed.
default-remote-maven-repos
A map containing the default remote Maven artifact repositories that the library uses. Each key is a String
that’s the short identifier of the repo (e.g. "clojars"
), and each value is the base URL of that artifact repository (e.g. "https://repo.clojars.org"
).
ga->metadata-uri
(ga->metadata-uri {:keys [group-id artifact-id]})
(ga->metadata-uri group-id artifact-id)
Returns a URI
pointing to the maven-metadata.xml
for the given GA, or nil
if one cannot be found. The returned URI
is guaranteed to be resolvable - either to a file that exists in the local Maven cache, or to an HTTP-accessible resource on a remote Maven repository (e.g. Maven Central, Clojars) that resolves.
ga-latest-version
(ga-latest-version group-id artifact-id)
Determines the latest version of the given GA as a String
, or nil
if it cannot be determined.
Note: this could be a SNAPSHOT, RC, alpha, beta, or any other type of pre-release version.
ga-release-version
(ga-release-version group-id artifact-id)
Determines the release version (if any) of the given GA as a String
, or nil
if it cannot be determined or the GA doesn’t have a released version.
gav->expressions
(gav->expressions group-id artifact-id)
(gav->expressions group-id artifact-id version)
Returns a set of SPDX expressions (String
s) for the given GA and optionally V. See gav->expressions-info for details.
gav->expressions-info
(gav->expressions-info group-id artifact-id)
(gav->expressions-info group-id artifact-id version)
Returns an expressions-info map for the given GA and (optionally) V, by looking up the POM for the given GA(V) and calling pom->expressions-info on it.
If version
is not provided, the latest version is looked up (which involves file and potentially also network I/O).
Notes: * despite the name, will always return a singleton map, due to Maven’s rule about multi-licensed POMs (then search that page for ‘licenses/license*’) * throws on XML parsing error
gav->metadata-uri
(gav->metadata-uri {:keys [group-id artifact-id version]})
(gav->metadata-uri group-id artifact-id version)
Returns a URI
pointing to the maven-metadata.xml
for the given GAV, or nil
if one cannot be found. The returned URI is guaranteed to be resolvable - either to a file that exists in the local Maven cache, or to an HTTP-accessible resource on a remote Maven repository (e.g. Maven Central, Clojars) that resolves.
gav->pom-uri
(gav->pom-uri {:keys [group-id artifact-id version]})
(gav->pom-uri group-id artifact-id)
(gav->pom-uri group-id artifact-id version)
Returns a URI
pointing to the POM for the given GAV, or nil
if one cannot be found. The returned URI
is guaranteed to be resolvable - either to a file that exists in the local Maven cache, or to an HTTP-accessible resource on a remote Maven repository (e.g. Maven Central, Clojars) that resolves.
If version is not provided, determines the latest version (which may be a SNAPSHOT, or other pre-release version) and uses that.
init!
(init!)
Initialises this namespace upon first call (and does nothing on subsequent calls), returning nil. Consumers of this namespace are not required to call this fn, as initialisation will occur implicitly anyway; it is provided to allow explicit control of the cost of initialisation to callers who need it.
Note: this method may have a substantial performance cost.
local-maven-repo
(local-maven-repo)
The current local Maven repo in use, as a String
containing a file path.
pom->expressions
(pom->expressions pom)
(pom->expressions pom filepath)
Returns a set of SPDX expressions (String
s) for pom
. See pom->expressions-info for details.
pom->expressions-info
multimethod
(pom->expressions-info pom)
(pom->expressions-info pom filepath)
Returns an expressions-info map for pom
(an InputStream
or something that can have an clojure.java.io/input-stream
opened on it), or nil
if no expressions were found.
If an InputStream
is provided, it is the caller’s responsibility to open and close it, and a filepath associated with the InputStream
must be provided as the second parameter (it is not required for other types of input).
Notes: * despite the name, will always return a singleton map, due to Maven’s rule about multi-licensed POMs (then search that page for ‘licenses/license*’) * throws on XML parsing error
remote-maven-repos
(remote-maven-repos)
The current remote Maven repos in use, as a map in the format described in default-remote-maven-repos.
set-local-maven-repo!
(set-local-maven-repo! dir)
Sets the local Maven repo to use from this point onward. dir
is a String
that must be a readable directory that exists (throws ex-info if these conditions are not met).
set-remote-maven-repos!
(set-remote-maven-repos! repos)
Sets the remote Maven repos to use from this point onward. The argument is a map in the format described in default-remote-maven-repos.
For most use cases you should merge default-remote-maven-repos
with whatever additional repos you wish to provide (the rare exceptions being situations such as a dev environment that contains a custom Maven artifact repository that proxies Maven Central and/or Clojars, and you don’t want lice-comb to attempt to access anything but the proxy).