code.tool

Build, Java, Maven, and measurement tooling.

code.tool groups lower-level development utilities used to build artifacts, inspect Java sources, package Maven outputs, and measure code changes.

1    Motivation

These namespaces are not the primary user API, but they are important for repository operations and release work. They turn project metadata and package manifests into concrete build or measurement tasks.

2    Internal usage

Build tooling uses code.framework.link and code.project to collect package entries and dependencies. Maven tooling converts those manifests into installable or deployable artifacts.

3    Walkthrough

3.1    Maven lifecycle

code.tool.maven wraps packaging, linkage, install, and clean tasks. Most tasks accept a package or site key and a :tag selector.

create deployment linkages

(maven/linkage :all {:tag :all
                     :print {:item false :result false :summary false}})
=> map?

clean interim package files

(maven/clean :all {:tag :all
                   :print {:item false :result false :summary false}})
=> map?

package interim files

(maven/package '[xyz.zcaudate]
               {:tag :all
                :print {:item false :result false :summary false}})
=> map?

3.2    Measuring code

code.tool.measure detects file types and produces complexity and surface metrics from source strings.

detect the language of a filename

(measure/detect-type "src/example.cljs")
=> :cljs

(measure/detect-type "src/example.clj")
=> :clj

generate metrics for a JavaScript snippet

(measure/generate-metrics "function add(a, b) { return a + b; }")
=> (contains {:complexity number?
              :surface number?})

3.3    End-to-end: detect and measure a snippet

Combine detect-type with generate-metrics to classify a file and score its contents in one pass.

classify and measure a JavaScript snippet

(let [code "function hello(x) { if (x) return 1; return 2; }"]
  {:type (measure/detect-type "hello.js")
   :metrics (measure/generate-metrics code)})
=> {:type :js
    :metrics (contains {:complexity number?
                        :surface number?})}

4    API