[英]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.