Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All dependencies get packaged into jar #90

Open
georgewfraser opened this issue Oct 27, 2014 · 8 comments
Open

All dependencies get packaged into jar #90

georgewfraser opened this issue Oct 27, 2014 · 8 comments

Comments

@georgewfraser
Copy link

All the classes from dependencies end up in the packaged jar. This is different than the default of maven, and not what you want when you intend to publish the project to a maven repository and consume it in another project.

Minimal pom.xml that reproduces the error:

<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.fivetran</groupId>
    <artifactId>clojure-sandbox</artifactId>
    <version>1.0-SNAPSHOT</version>

    <packaging>clojure</packaging>

    <dependencies>
        <!-- Clojure language runtime -->
        <dependency>
            <groupId>org.clojure</groupId>
            <artifactId>clojure</artifactId>
            <version>1.6.0</version>
        </dependency>

        <!-- Fancy clojure JSON / Jackson wrapper -->
        <dependency>
            <groupId>cheshire</groupId>
            <artifactId>cheshire</artifactId>
            <version>5.3.1</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>

        <testSourceDirectory>test</testSourceDirectory>

        <plugins>
            <!-- Teach maven about clojure -->
            <plugin>
                <groupId>com.theoryinpractise</groupId>
                <artifactId>clojure-maven-plugin</artifactId>
                <version>1.3.20</version>
                <extensions>true</extensions>

                <configuration>
                    <sourceDirectories>
                        <sourceDirectory>src</sourceDirectory>
                    </sourceDirectories>

                    <testSourceDirectories>
                        <testSourceDirectory>test</testSourceDirectory>
                    </testSourceDirectories>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
@talios
Copy link
Owner

talios commented Oct 28, 2014

This is a long long LONG standing bug/issue in clojure itself - it will write out ALL namespaces it compiles to the output directory ( http://dev.clojure.org/jira/browse/CLJ-322 ).

I thought we'd had a work-around inplace to delete the foreign namespaces but it looks like we don't. Shouldn't be hard to add tho. I wonder how other people get around this currently.

@anthcourtney
Copy link

Are there any suggested (i.e. tried and tested) workarounds for this behaviour?

@talios
Copy link
Owner

talios commented Dec 8, 2014

I keep meaning to put some time aside to update the plugin to have a "delete undiscovered namespaces" option which, after compilation will simply delete the any .class files it doesn't know about ( or more, to be a good citazen, compile to a temporary folder, and then copy only the .class files related to the discovered namespaces ).

As yet I've not had the time - pull requests welcome tho.

@talios
Copy link
Owner

talios commented Dec 18, 2014

Hopefully I can find some time to put aside whilst on Xmas holidays to look at this...

@laurentpetit
Copy link
Contributor

Please note that for libraries, it is not recommended to AOT compile, anyway.
For final projects, to the contrary, it may be interesting to have all classes, including dependencies, AOT compiled and included.

@laurentpetit
Copy link
Contributor

However, there may still be the need to remove some namespace aot classes (for instance, some namespaces are so dynamic that they can't work if they're aot compiled, but they may be aot compiled transitively and must then be removed after the fact).

@laurentpetit
Copy link
Contributor

I have this problem with cider-nrepl and CCW.
I'm working on a patch for clojure-maven-plugin which does just the following: if a cleanAOTNamespaces configuration parameter is set to true - it's false by default -, then the <namespaces> regexes are used to remove undesired classes

@laurentpetit
Copy link
Contributor

The PR has been published: #98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants