Skip to content

Latest commit

 

History

History
375 lines (320 loc) · 8.1 KB

README.md

File metadata and controls

375 lines (320 loc) · 8.1 KB

Zi

Zi is a maven plugin for clojure. It does something similar to clojure-maven-plugin, but does so differently.

It uses the maven pom sourceDirectory and testSourceDirectory settings to locate source, which by default means that it uses src/main/clojure and src/test/clojure. The goals should work with a pom.xml generated by leiningen.

From an implementation perspecitve, most of the goals are written in clojure.

Zi requires maven 3.0.4.

Available goals

  • zi:resources
  • zi:testResources
  • zi:compile
  • zi:ritz
  • zi:ritz-nrepl
  • zi:swank-clojure
  • zi:test
  • zi:codox
  • zi:marginalia
  • zi:ring-genfiles

Install

Globally installing the plugin allows you to run the goals without modifying a project's pom file.

To globally enable the zi plugin, you need to add pluginGroup and pluginRepository configuration to your ~/.m2/settings.xml file.

    <pluginGroups>
      <pluginGroup>org.cloudhoist.plugin</pluginGroup>
    </pluginGroups>
    <profiles>
      <profile>
        <id>clojure-dev</id>
        <pluginRepositories>
          <pluginRepository>
            <id>sonatype-snapshots</id>
            <url>http://oss.sonatype.org/content/repositories/releases</url>
          </pluginRepository>
        </pluginRepositories>
      </profile>
    </profiles>

    <activeProfiles>
      <activeProfile>clojure-dev</activeProfile>
    </activeProfiles>

To enable zi in a project pom, without globally enabling the plugin, you will need to add a pluginRepositories entry to your pom:

    <pluginRepositories>
      <pluginRepository>
        <id>sonatype-snapshots</id>
        <url>http://oss.sonatype.org/content/repositories/releases</url>
      </pluginRepository>
    </pluginRepositories>

Configuration

It uses the maven pom sourceDirectory and testSourceDirectory settings to locate source, which by default means that it uses src/main/clojure and src/test/clojure.

Goals

resources

The resources goal copies clojure source to the target. This is probably what you need to make sure that your clj source files end up in your jar file.

    <build>
      <plugins>
        <plugin>
          <groupId>org.cloudhoist.plugin</groupId>
          <artifactId>zi</artifactId>
          <version>0.5.5</version>
          <executions>
            <execution>
              <id>default-resources</id>
              <phase>process-resources</phase>
              <goals>
                <goal>resources</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>

testResources

The testResources goal copies clojure test source to the target. This is probably what you need to make sure that your clj source files end up in your test-jar file.

    <build>
      <plugins>
        <plugin>
          <groupId>org.cloudhoist.plugin</groupId>
          <artifactId>zi</artifactId>
          <version>0.5.5</version>
          <executions>
            <execution>
              <id>default-test-resources</id>
              <phase>process-test-resources</phase>
              <goals>
                <goal>test-resources</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>

compile

The compile goal AOT compiles clojure source.

    <build>
      <plugins>
        <plugin>
          <groupId>org.cloudhoist.plugin</groupId>
          <artifactId>zi</artifactId>
          <version>0.5.5</version>
          <executions>
            <execution>
              <id>default-compile</id>
              <goals>
                <goal>compile</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <excludes>
              <exclude>**/test.clj</exclude>
            </excludes>
          </configuration>
        </plugin>
      </plugins>
    </build>
Property Variable Default Description
includes **/*.clj A set of source patterns to include
excludes A set of source patterns to exclude

ritz

The ritz goal starts a ritz server.

Property Variable Default Description
port clojure.swank.port 4005 The swank server port
encoding clojure.swank.encoding iso-8859-1 The swank encoding to use

The ritz, ritz-nrepl and swank-clojure goals all recognise sub-projects linked in a checkouts directory, and adds their sources and resources to the the classpath.

The ritz and ritz-nrepl goals also adds source jars to the classpath if they are available in the local repository. You can resolve the source jars using mvn dependency:sources.

ritz-nrepl

The ritz-nrepl goal starts a ritz nREPL server.

Property Variable Default Description
port clojure.nrepl.port 4005 The nrepl server port

swank-clojure

The swank-clojure goal starts a swank-clojure server.

Property Variable Default Description
port clojure.swank.port 4005 The swank server port
encoding clojure.swank.encoding iso-8859-1 The swank encoding to use

test

The test goal runs clojure.test tests.

Property Variable Default Description
initScript clojure.initScript A clojure source string that is run before the tests

codox

The codox goal creates codox generated API documentation in the doc directory.

Property Variable Default Description
codoxTargetDirectory ${project.build.directory}/doc The directory where codox should write its output

marginalia

The marginalia goal creates a marginalia annotated source page.

Property Variable Default Description
marginaliaTargetDirectory ${project.build.directory} The directory where marginalia should write uberdoc.html

ring-genfiles

The ring-genfiles goal creates files required for a war packaging. See lein-ring plugin.

Property Default Description
ringServletClass The name of the servlet class
ringServletName The name of the servlet
ringListenerClass The name of the ServletContextListener class
ringHandler The name of the ring handler
ringInit The name of an initialisation hook function
ringDestroy The name of a shutdown hook function
ringUrlPattern The url pattern of the servlet mapping (in web.xml). Defaults to "/*".

Zi, the builder

Zi was a builder in northern mythology.

License

Licensed under EPL

Copyright 2011 Hugo Duncan.