skuzzle/restrict-imports-enforcer-rule

Use maven-shade plugin to eventually resolve classloading issue?

Closed this issue · 4 comments

The following pom snippet relocates all guava classes into a new package. That would resolve classloading issues as in #20 or #21.
However, this grows the final jar's size from 70kb to 2800kb which are quite some numbers.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <artifactSet>
                        <includes>
                            <include>com.google.guava:guava</include>
                        </includes>
                    </artifactSet>
                    <relocations>
                        <relocation>
                            <pattern>com.google.common</pattern>
                            <shadedPattern>com.shaded.google.common</shadedPattern>
                        </relocation>
                    </relocations>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Maybe I should just get rid of the whole guava dependency...? I think we're only using some little helpers that could be re-implemented using just a few lines.

I'm not a big fan of shading as this opens up for further different problems (besides the increase in size)

I've now removed the guava dependency altogether. Will be released as of 1.4.0

Might be a good idea to revisit whether it makes sense to shade/shadow the dependencies now that there is a Gradle plugin

Will be shipped with 2.5.0