简体   繁体   English

Maven 不生成目标测试类文件

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

Our company has its own maven repository and we download maven dependencies from there.我们公司有自己的 maven 存储库,我们从那里下载 maven 依赖项。 When i run maven clean test on command line, it does not generate target classes and test classes from java file.当我在命令行上运行 maven 清洁测试时,它不会从 java 文件生成目标类和测试类。

Questions:问题:

  1. The target > test-classes does not have the.class file generated when running mvn clean test. target > test-classes 没有运行 mvn clean test 时生成的 .class 文件。

Please help.请帮忙。 Thanks.谢谢。

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

Commandline Output:命令行 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

You could see in the Commandline Output you have pasted which says您可以在您粘贴的命令行 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

You are missing the maven-resources-plugin in your build conifguration.您在构建配置中缺少maven-resources-plugin

Add following to your <build><plguins> </plugins></build>将以下内容添加到您的<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>

The resources files are copied from src/main/resources to target/classes .资源文件从src/main/resources复制到target/classes

EDIT: It doesnot help.编辑:它没有帮助。 There is 0 resources copying.有 0 个资源复制。 The target - classess is generated but not target - test-classes.生成目标 - 类,但不生成目标 - 测试类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM