Как собрать с помощью maven ТОЛЬКО тесты?

Пишу тесты на selenide, это как selenium. Дело в том что я когда собираю проект с помощью maven, появляется jarник, а при запуске говорит no manifest. я этот манифест уже куда только не скопировал (знаю что у idea был такой баг).
структура проекта:
617462600e1a9196010939.png
и в каждом файле мой главный класс (RunCucunberTest) Cannot resolve.

А это pom.xml на всякий случай, то что я закоментировал -- не помогло

<?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>org.example</groupId>
    <artifactId>cucumber_project</artifactId>
    <version>1.0-SNAPSHOT</version>


    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-bom</artifactId>
                <version>7.0.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.8.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>

        <!-- log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <!--        cucumber        -->

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>7.0.0-RC1</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>7.0.0-RC1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.4</version>
        </dependency>

<!--        <dependency>-->
<!--            <groupId>io.cucumber</groupId>-->
<!--            <artifactId>cucumber-junit-platform-engine</artifactId>-->
<!--            <scope>test</scope>-->
<!--        </dependency>-->

<!--        junit       -->


        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>

<!--        selenide        -->
        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>selenide</artifactId>
            <version>5.25.0</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <configuration>
                        <includes>
                            <include>**/RunCucumberTest**.java</include>
                        </includes>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.1.0</version>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <descriptors>
                            <descriptor>src/assembly/descriptor.xml</descriptor>
                        </descriptors>
<!---->
<!--                            <archive>-->
<!--                                <manifest>-->
<!--                                    <mainClass>-->
<!--                                        test.java.RunCucunberTest-->
<!--                                    </mainClass>-->
<!--                                </manifest>-->
<!--                            </archive>-->
<!---->
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>


Если запускать с идеи главный класс, то все запускается
  • Вопрос задан
  • 232 просмотра
Пригласить эксперта
Ответы на вопрос 1
azerphoenix
@azerphoenix Куратор тега Java
Java Software Engineer
Первое. что попадается на глаза - <pluginManagement>. Ваши плагины внутри этого тега. Этот тег позволяет управлять указанными плагинами внутри модулей, но если вы хотите, чтобы они были применены к текущему проекту, то вытащите плагины из этого плагина.
В конфигах плагина maven-assembly-plugin пропишите это и укажите ваш класс
<archive>
        <manifest>
          <mainClass>com.example.Main</mainClass>
        </manifest>
      </archive>


А вообще, если хотите настроить fat jar, то лучше использовать - maven shade plugin
https://stackoverflow.com/questions/16222748/build...
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы