简体   繁体   English

如何在 Maven pom.xml 上构建像 Eclipse Clean 这样的项目

[英]How to build project like Eclipse Clean on Maven pom.xml

I need help on running maven project.我需要运行 Maven 项目的帮助。 I can run the project on Eclipse, and I tried to deploy / run it on Jenkins CI but without success.我可以在 Eclipse 上运行该项目,我尝试在 Jenkins CI 上部署/运行它,但没有成功。

I made a maven project with custom folder structure (not following the default).我使用自定义文件夹结构(不遵循默认值)制作了一个 Maven 项目。

Below is the structure:下面是结构:

结构体

I can run the project successfully through Eclipse by cleaning the project first where I believe Eclipse build all java files for me.通过首先清理项目,我可以通过 Eclipse 成功运行该项目,我相信 Eclipse 会为我构建所有 java 文件。 Below is the 'target' folder looks like after I clean the project through Eclipse (not maven clean)下面是我通过 Eclipse 清理项目后的“目标”文件夹(不是 maven 清理)

在此处输入图片说明

However, when I delete the content of 'target' folder, and run maven -clean and maven -install I received an error like this:但是,当我删除“目标”文件夹的内容并运行 maven -clean 和 maven -install 时,我收到如下错误:

在此处输入图片说明

I believe it's because I did not set anything on the pom.xml about building all java classes.我相信这是因为我没有在 pom.xml 上设置任何关于构建所有 java 类的内容。 However I do not know how to do it ?然而我不知道该怎么做? Can you help me?你能帮助我吗? Changing structure is avoided right now.现在避免改变结构。 Thanks谢谢

Below is the pom.xml下面是 pom.xml

<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>bukalapak</groupId>
<artifactId>bukalapak</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
     <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.46.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>2.46.0</version>
    </dependency>

    <dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.9.4</version>
  <scope>test</scope>
</dependency>
</dependencies>

<build>

<!--  <resources>
<resource>
<directory>src/bukalapak</directory>
</resource>
</resources> -->
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
             <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
            <forkMode>never</forkMode>
                <suiteXmlFiles>
                    <suiteXmlFile>testsuite/TestSuiteBukalapak.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

</project>

You can use maven-compiler-plugin .您可以使用maven-compiler-plugin Example:例子:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

If you don't use the default directory structure, you have to configure the source directory appropriately.如果不使用默认目录结构,则必须适当配置源目录。 In your case, the correct configuration would be:在您的情况下,正确的配置是:

<build>
    <sourceDirectory>src</sourceDirectory>
</build>

Otherwise Maven would look in the default folder structure.否则 Maven 将查看默认文件夹结构。

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

相关问题 Maven项目是通过Eclipse Update Project而不是pom.xml进行编译的? - Maven project is getting compiled by Eclipse Update Project but not by pom.xml? 如何使用pom.xml在github上构建项目 - How to build a project on github with pom.xml IntelliJ中类似于Eclipse的maven pom.xml管理? - Eclipse-like maven pom.xml management in IntelliJ? 在 eclipse 中导入 maven 项目时缺少 pom.xml 文件 - pom.xml file is missing when import maven project in eclipse Maven eclipse:pom.xml的项目配置不是最新的 - Maven eclipse: project configuration is not up to date with pom.xml 在Ubuntu上将Maven项目导入Eclipse 3.5&gt; pom.xml已禁用 - Import maven project to Eclipse 3.5 on Ubuntu > pom.xml is disabled 无法将包装作为pom.xml中的war添加到Eclipse中的Maven项目中 - Unable to add packaging as war in pom.xml to a maven project in eclipse Maven pom.xml 问题(缺少项目构建错误“版本”) - Maven pom.xml Problems (Project Build Error "version" is missing) 如何使用pom.xml / Maven在Eclipse中初始化本地思想站点(App Engine示例)项目? - How to use pom.xml/Maven to initialize a local thoughtsite (App Engine sample) project in Eclipse? 如何将maven pom.xml与Eclipse Plugin项目一起使用(或集成)以进行依赖项管理 - How to use (or integrate) maven pom.xml with an Eclipse Plugin project for dependency management
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM