Maven pluguin to copy and repackage sources to reduce library dependencies
IMPORTANT NOTE: We strongly recommends to use this plugin only for libraries, for final projects if you want to build a uber-jar maven already has it's shade plugin that works perfectly
To keep the dependency hell away from your projects its important to reduce at minimum the dependencies of each library. But at te same time this can break the code reutilization principle, to avoid this flag the solution comes by copying the source code and repackaging in order to avoid collisions. But this is only necessary when you need ONLY some specific classes, if you need the full library then you should add it as dependency.
Available goals:
- copy-classes: Copy classes to generated-sources
- copy-test-classes: Copy classes to generated-test-sources
IMPORTANT NOTE: We strongly recommends to use this plugin only for libraries, for final projects if you want to build a uber-jar maven already has it's shade plugin that works perfectly
- Add the pluguin to your pom
(...) <build> <plugins> (...) <plugin> <groupId>org.bytemechanics.maven</groupId> <artifactId>copysource-maven-plugin</artifactId> <version>X.X.X</version> </plugin> (...) </plugins> </build> (...)
- Define the execution goal "copy-classes" (the phase it's not necessary, by default uses "generate-sources")
(...) <build> <plugins> (...) <plugin> <groupId>org.bytemechanics.maven</groupId> <artifactId>copysource-maven-plugin</artifactId> <version>X.X.X</version> <executions> <execution> <goals> <goal>copy-classes</goal> </goals> </execution> </executions> </plugin> (...) </plugins> </build> (...)
- Configure it with the copies that you want to do:
(...) <build> <plugins> (...) <plugin> <groupId>org.bytemechanics.maven</groupId> <artifactId>copysource-maven-plugin</artifactId> <version>X.X.X</version> <executions> <execution> <goals> <goal>copy-classes</goal> </goals> <configuration> <copies> <copy> <artifact>[source-groupId]:[source-artifactId]:[source-version]</artifact> <classes> <class>[cannonical-name-of-origin-source. Example:org.bytemechanics.commons.functional.LambdaUnchecker]</class> (...) </classes> <fromPackage>[package-segment-to-replace. Example: org.bytemechanics.commons]</fromPackage> <toPackage>[package-segment-to-replace. Example: org.bytemechanics.standalone.ignite.internal.commons]</toPackage> </copy> </copies> </configuration> </execution> </executions> </plugin> (...) </plugins> </build> (...)
(Please read our Javadoc for further information)