I'm in a situation where I need to build a fat jar from a multi module maven project. The project is built based on Selenium/cucumber API's.
Structure of my project is as follows
Parent -- pom | |__core_module src/main/java --> helper classes for selenium | |__acme_module src/main/test --> Test Classes for acme project
I have tried different ways to build a "acme_test.jar" which includes core_module+acme_module.But none of them helped me.
Much appreciate any clue to solve this .
Thanks
2 Answers
Answers 1
Configure acme_module
as fat module - this module should produce executable fat jar with all dependencies.
Add core_module
to acme_module
as dependency.
Move your test classes from src/test/java
to src/main/java
, because this class should be executable. If you have tests (like junit), then leave this classes inside test
directory, but executable part should stay in main
.
Answers 2
As @MariuszS mentions, first restructure your project so that you separate any Unit tests or integration tests for the actual classes that test (=drive/verify navigation for) Acme.
Parent -- pom | |__core_module src/main/java --> helper classes for selenium | |__acme_module src/main/java --> Classes specific for navigating acme | |__acme_module src/test/java--> (Unit etc) Test Classes for acme project
Then, you need acme_module to contain core_module as dependency.
Finally, in acme_module, put this in your build plugins section:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.4.3</version> <executions> <execution> <id>create-fat-jar</id> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <!-- add Main-Class to manifest file --> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>your.main.class</mainClass> </transformer> </transformers> <finalName>YourJarName</finalName> </configuration> </execution> </executions> </plugin>
You can also explicitly include the core_module by adding an include filter in the plugin configuration section
0 comments:
Post a Comment