0
votes

I'm trying to compile some Clojure code into a jar, using Maven and the clojure-maven-plugin.

The generated jar includes the source *.clj files, i would like to exclude these files from the final jar, and include only the AOT compiled files.

My pom file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<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">

    <artifactId>clojure-interop</artifactId>
    <groupId>com.testing.clojure</groupId>
    <version>1.0.0</version>

    <modelVersion>4.0.0</modelVersion>

    <packaging>jar</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>com.theoryinpractise</groupId>
                <artifactId>clojure-maven-plugin</artifactId>
                <version>1.3.13</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>compile-clojure</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-clojure</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>clojars</id>
            <url>http://clojars.org/repo/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.clojure</groupId>
            <artifactId>clojure</artifactId>
            <version>1.5.0</version>
        </dependency>
    </dependencies>

</project>

Can someone point me in the right direction?

1

1 Answers

1
votes

It is possible to configure clojure-maven-plugin to exclude some source files from the jar using a combination of copiedNamespaces, copyDeclaredNamespaceOnly, and copyAllCompiledNamespaces configration properties. In order to exclude all source files from the jar use:

  <plugin>
    <groupId>com.theoryinpractise</groupId>
    <artifactId>clojure-maven-plugin</artifactId>
    <version>1.3.15</version>
    <extensions>true</extensions>
    <configuration>
      <copiedNamespaces>
        <copiedNamespace>!.*</copiedNamespace>
      </copiedNamespaces>
    </configuration>
   ......
  </plugin>

More information is available here