Проект Maven не проходит тесты после удаления неиспользуемых зависимостей - PullRequest
0 голосов
/ 27 февраля 2019

У меня есть проект maven, в котором я хочу уменьшить количество зависимостей с помощью файла pom.xml, который выглядит следующим образом:

<groupId>com.proj.itt</groupId>
<artifactId>web-app-out</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>        
    <camel.version>2.23.1</camel.version>
    <spring.version>5.1.4</spring.version>
    <spring.kafka.version>2.2.0.RELEASE</spring.kafka.version>
    <kafka.version>1.0.0</kafka.version>
    <avro.version>1.8.2</avro.version>
    <proxy.configurator.version>1.1-SNAPSHOT</proxy.configurator.version>
    <proxy.utilities.version>1.1-SNAPSHOT</proxy.utilities.version>
    <junit.version>4.12</junit.version>
</properties>

<dependencies>
    <!--  PROXY modules -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-javaconfig</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jetty</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-kafka</artifactId>
        <version>${camel.version}</version>
    </dependency>

    <!--Used Undeclared dependency-->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>2.0.0</version>
    </dependency>
    <!--/Used Undeclared dependency-->

    <!--LOGGING-->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
    </dependency>
    <!-- TEST -->
    <!--Used Undeclared dependency-->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <!--/Used Undeclared dependency-->

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>3.3.0</version>
        <scope>test</scope>
    </dependency>

    <!-- INTERNAL KAFKA-->
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
        <version>${spring.kafka.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka-test</artifactId>
        <version>${spring.kafka.version}</version>
    </dependency>
    <!--Used Undeclared dependency-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}.RELEASE</version>
    </dependency>
    <!--/Used Undeclared dependency-->
    <!-- CONFIG -->
    <dependency>
        <groupId>com.typesafe</groupId>
        <artifactId>config</artifactId>
        <version>1.3.3</version>
    </dependency>

    <!-- AVRO -->
    <dependency>
        <groupId>org.apache.avro</groupId>
        <artifactId>avro</artifactId>
        <version>${avro.version}</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.3</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <transformers>
                    <transformer
                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/spring.handlers</resource>
                    </transformer>
                    <transformer
                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/spring.schemas</resource>
                    </transformer>
                </transformers>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M1</version>
            <configuration>
                <systemPropertyVariables>
                </systemPropertyVariables>
                <excludes>
                    <exclude>**/integration/**</exclude>
                </excludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0-M1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <systemPropertyVariables>
                </systemPropertyVariables>
                <includes>
                    <include>**/integration/**</include>
                </includes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro-maven-plugin</artifactId>
            <version>${avro.version}</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>schema</goal>
                    </goals>
                    <configuration>
                        <stringType>String</stringType>
                        <enableDecimalLogicalType>true</enableDecimalLogicalType>
                        <sourceDirectory>${project.basedir}/src/main/resources/avro/</sourceDirectory>
                        <outputDirectory>${project.basedir}/target/generated-sources/java/</outputDirectory>
                        <fieldVisibility>PRIVATE</fieldVisibility>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

После использования цели mvn dependency:analyze Iполучить в результате список неиспользованных объявленных зависимостей:

[WARNING] Unused declared dependencies found:
[WARNING]    org.apache.camel:camel-jetty:jar:2.23.1:compile
[WARNING]    org.apache.camel:camel-kafka:jar:2.23.1:compile
[WARNING]    org.apache.camel:camel-core:test-jar:tests:2.23.1:test
[WARNING]    org.springframework.kafka:spring-kafka:jar:2.2.0.RELEASE:compile
[WARNING]    org.springframework.kafka:spring-kafka-test:jar:2.2.0.RELEASE:compile

Но когда я пытаюсь удалить их, это приводит к сбоям в моем проекте.Почему это происходит?Проверяет ли также maven зависимости, связанные с тестами?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...