构建是成功但没有编译源 [英] Build is Success but No sources to compile

查看:134
本文介绍了构建是成功但没有编译源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Eclipse控制台中的Maven测试输出:

  [INFO]扫描项目... 
[警告]
[警告]为Mabi构建有效模型时遇到了一些问题:Mabi:jar:0.0.1-SNAPSHOT
[警告]'dependencies.dependency。(groupId:artifactId:type:classifier) '必须是唯一的:org.seleniumhq.selenium:selenium-java:jar - >重复声明版本2.45.0 @第20行,第21列
[警告]'build.plugins.plugin。(groupId:artifactId)'必须是唯一的,但发现重复的插件声明org.apache.maven.plugins: maven-surefire-plugin @第74行,第10列
[警告]
[警告]强烈建议修复这些问题,因为它们会威胁构建的稳定性。
[警告]
[警告]因此,未来的Maven版本可能不再支持构建此类格式错误的项目。
[警告]
[INFO]
[INFO] ----------------------------- -------------------------------------------
[INFO]建造Mabi 0.0.1-SNAPSHOT
[INFO] ------------------------------------ ------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:资源(默认资源)@ Mabi ---
[警告]使用平台编码(实际上是Cp1252)来复制过滤后的资源,即构建依赖于平台!
[INFO]跳过不存在的resourceDirectory E:\ workspace \Mabi \src \ com.TestCase
[INFO]
[INFO] --- maven-compiler-plugin: 3.5:compile(default-compile)@ Mabi ---
[INFO]检测到更改 - 重新编译模块!
[警告]尚未使用平台编码Cp1252设置文件编码,即构建依赖于平台!
[INFO]将166个源文件编译为E:\ workspace \ Marti \target \classes
[INFO]
[INFO] --- maven-resources-plugin:2.6 :testResources(default-testResources)@ Mabi ---
[警告]使用平台编码(实际上是Cp1252)来复制过滤后的资源,即构建依赖于平台!
[INFO]跳过不存在的resourceDirectory E:\ workspace \ Martini \ src \ test \ resources
[INFO]
[INFO] --- maven-compiler-plugin :3.5:testCompile(default-testCompile)@ Mabi ---
[INFO]没有来源可以编译
[INFO]
[INFO] --- maven-surefire-plugin:2.19。 1:测试(默认测试)@ Mabi ---
[INFO]没有测试运行。
[INFO] ------------------------------------------- -----------------------------
[INFO]建立成功
[INFO] ----- -------------------------------------------------- -----------------
[INFO]总时间:7.287 s
[INFO]完成时间:2016-03-23T11:32:40 + 05 :30
[INFO]最终记忆:21M / 283M
[INFO] ---------------------------- --------------------------------------------



上图显示了我项目的目录,但是当我通过Maven运行项目时,它给出了上述结果而没有运行测试。期待一些准确的解决方案。



这就是我的POM.XML文件的样子:

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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> Mabi< / groupId>
< artifactId> Mabi< / artifactId>
< version> 0.0.1-SNAPSHOT< / version>
< dependencies>
< dependency>
< groupId> com.relevantcodes< / groupId>
< artifactId> extentreports< / artifactId>
< version> 2.40.2< / version>

< / dependency>
< dependency>
< groupId> org.seleniumhq.selenium< / groupId>
< artifactId> selenium-java< / artifactId>
< version> 2.45.0< / version>
< / dependency>
< dependency>
< groupId> org.testng< / groupId>
< artifactId> testng< / artifactId>
< version> 6.8< / version>
< / dependency>
< / dependencies>

< build>
< sourceDirectory> src< / sourceDirectory>

< resources>
< resource>
< directory> src / com.TestCase< / directory>
< includes>
< include> ** / com。* TestCase.java< / include>
< / includes>
< / resource>
< / resources>

< plugins>
< plugin>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 3.5< / version>
< configuration>
< source />
< target />
< / configuration>
< / plugin>
< plugin>


< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-surefire-plugin< / artifactId>
< version> 2.19.1< / version>
< inherited> true< / inherited>
< configuration>
< suiteXmlFile> testng.xml< / suiteXmlFile>
< / configuration>
< / plugin>
< / plugins>

< / build>
< / project>


解决方案

Maven完全是关于


Maven test output in the Eclipse console:

[INFO] Scanning for projects...
    [WARNING] 
    [WARNING] Some problems were encountered while building the effective model for Mabi:Mabi:jar:0.0.1-SNAPSHOT
    [WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.seleniumhq.selenium:selenium-java:jar -> duplicate declaration of version 2.45.0 @ line 20, column 21
    [WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-surefire-plugin @ line 74, column 10
    [WARNING] 
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING] 
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    [WARNING] 
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Mabi 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Mabi ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory E:\workspace\Mabi\src\com.TestCase
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ Mabi ---
    [INFO] Changes detected - recompiling the module!
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 166 source files to E:\workspace\Mabi\target\classes
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Mabi ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory E:\workspace\Mabi\src\test\resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.5:testCompile (default-testCompile) @ Mabi ---
    [INFO] No sources to compile
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ Mabi ---
    [INFO] No tests to run.
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 7.287 s
    [INFO] Finished at: 2016-03-23T11:32:40+05:30
    [INFO] Final Memory: 21M/283M
    [INFO] ------------------------------------------------------------------------

Above image shows the directory of my project but when I run the project via Maven it gives me the above result without running the test. Looking forward for some accurate solutions.

And this is what my POM.XML file looks like:

<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>Mabi</groupId>
  <artifactId>Mabi</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
    <groupId>com.relevantcodes</groupId>
    <artifactId>extentreports</artifactId>
    <version>2.40.2</version>

    </dependency>             
        <dependency>              
            <groupId>org.seleniumhq.selenium</groupId>                              
            <artifactId>selenium-java</artifactId>                              
            <version>2.45.0</version>                               
        </dependency>                          
        <dependency>              
            <groupId>org.testng</groupId>                               
            <artifactId>testng</artifactId>                             
            <version>6.8</version>                                                                   
       </dependency>              
</dependencies>

  <build>
    <sourceDirectory>src</sourceDirectory>

    <resources>
      <resource>
        <directory>src/com.TestCase</directory>
        <includes>
        <include>**/com.*TestCase.java</include>
        </includes>
        </resource>    
     </resources>

    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5</version>
        <configuration>
          <source/>
          <target/>
        </configuration>
      </plugin>
     <plugin>


        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
                <inherited>true</inherited>
            <configuration>
                <suiteXmlFile>testng.xml</suiteXmlFile>
            </configuration>
    </plugin>
 </plugins>

</build>
</project>

解决方案

Maven is all about "convention over configuration" idiom. In order that maven-surefire-plugin will run your testcases it expects to find it under src/test/java, hence, you should follow the maven's standard directory layout and put all your test cases under src/test/java.

这篇关于构建是成功但没有编译源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆