簡體   English   中英

Maven 不生成目標測試類文件

[英]Maven does not generate target test-classes file

我們公司有自己的 maven 存儲庫,我們從那里下載 maven 依賴項。 當我在命令行上運行 maven 清潔測試時,它不會從 java 文件生成目標類和測試類。

問題:

  1. target > test-classes 沒有運行 mvn clean test 時生成的 .class 文件。

請幫忙。 謝謝。

<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>Automation-Framework</groupId>
  <artifactId>Automation-Framework</artifactId>
  <version>1.0.0-SNAPSHOT</version>


  <properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
  </properties>

  <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M3</version>
                <configuration>
                    <includes>
                        <include>ChromeTestManager.java</include>

                    </includes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
        </plugin>

        </plugins>


    </pluginManagement>
  </build>

命令行 Output:

    [INFO] Scanning for projects [INFO] Deleting target folder 
    [INFO] --- maven-clean-plugin:2.6:resources (Default resources) @ Automation Framework 
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent 
    [INFO] --- maven-compiler-plugin:3.1:compile 
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent 
    [INFO] --- maven-resources-plugin:2.6:testResources [INFO] Copying 0 resource [INFO] --- maven-compiler-plugin:3.1testCompile [INFO] Nothing to compile - all classess up to date 
    [INFO] --- maven-surefire-plugin:3.0.0.-M3:test (default-test) @ Automation-Framework 
    [Info] Build Success

您可以在您粘貼的命令行 Output 中看到

[INFO] --- maven-resources-plugin:2.6:testResources [INFO] Copying 0 resource [INFO] --- maven-compiler-plugin:3.1testCompile [INFO] Nothing to compile - all classess up to date

您在構建配置中缺少maven-resources-plugin

將以下內容添加到您的<build><plguins> </plugins></build>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/resources</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

資源文件從src/main/resources復制到target/classes

編輯:它沒有幫助。 有 0 個資源復制。 生成目標 - 類,但不生成目標 - 測試類。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM