Creating a single-layer jar from a project with several maven modules - including test classes

I am in a situation where I need to build a thick jar from a project with several maven modules. The project is based on the Selenium / oucumber API.

The 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 tried different ways to create "acme_test.jar", which includes core_module + acme_module. But not one of them helped me.

It is very important to understand how to solve this.

thanks

+6
source share
2 answers

@MariuszS, , Unit , (= / ) 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

, acme_module core_module .

, acme_module :

<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>

core_module, include

+3

acme_module - .

core_module acme_module .

src/test/java src/main/java, . (, junit), test, main.

+4

Source: https://habr.com/ru/post/1014906/


All Articles