无法编译maven项目



我正在使用一个maven项目(v3.1.1),用于硒自动化。我已经在Jenkins(本地主机)中托管了我的项目,并试图从Jenkins本身编译该项目。

com.eh.base
com.eh.pageobjects
com.eh.tests

[我没有使用src\main\resource]这样的结构

Jenkins中的maven插件将实现编译过程。我尝试使用maven插件2.2.1和3.1.1,并以编译为目标,但没有成功。为了在eclipse级别中复制这一点。我尝试使用mvn-cleanmvn-compile命令从命令提示符编译maven项目。

构建结果

D:ShawShawProjectsBranchMyProject>mvn compile
[INFO] Scanning for projects...

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MyProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:ShawShawProjectsBranchMyProjectsrcmainresources
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MyProject ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.352s
[INFO] Finished at: Thu Feb 13 01:36:23 IST 2014
[INFO] Final Memory: 10M/108M
[INFO] ------------------------------------------------------------------------

由此,我希望它能编译并生成/target/classes中的类文件。但这并没有做到。既然我的项目使用自定义包,我想我应该尝试maven原型。请提供建议。

如果我错过了什么,请告诉我。

POM文件:

<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>MyProject</artifactId>
<groupId>com.eh</groupId>
<version>1.0</version>
<packaging>jar</packaging>
<name>MyProject</name>
<description>A sample Maven project that demonstrates how to integrate Sauce OnDemand with WebDriver tests that run using JUnit
</description>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-xml</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-xml.jar</systemPath>
</dependency>
<dependency>
<groupId>BaseLibrary</groupId>
<artifactId>BaseLibrary</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/BaseLibrary.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-examples</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-examples.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-greplog</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-greplog.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-jdbc</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-jdbc.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-nblr</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-nblr.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-nbp</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-nbp.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-swing</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-swing.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-wadl</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-wadl.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-xmldog</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-xmldog.jar</systemPath>
</dependency>
<dependency>
<groupId>TestNGFileGenerator</groupId>
<artifactId>TestNGFileGenerator</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/TestNGFileGenerator.jar</systemPath>
</dependency>
<dependency>
<groupId>jlibs</groupId>
<artifactId>jlibs-core</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jlibs-core.jar</systemPath>
</dependency>
<dependency>
<groupId>SauceREST</groupId>
<artifactId>SauceREST</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/SauceREST.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.33.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<properties>
:
<property>
<name>org.uncommons.reportng.escape-output</name>
<value>false</value>
</property>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.14</version>
<configuration>
<showSuccess>false</showSuccess>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>test</phase>
<configuration>
<tasks>
<zip destfile="${project.basedir}/target/surefire-reports/reports.zip"
basedir="${project.basedir}/target/surefire-reports/"
includes="**/*.html,**/*.xml,**/*.css"
/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>sauce-eh</id>
<name>sauce_quickstart</name>
<url>file://${project.basedir}/lib</url>
</repository>
<repository>
<id>java-net</id>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>saucelabs-repository</id>
<url>https://repository-saucelabs.forge.cloudbees.com/release</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

我强烈建议您遵循Maven的默认文件夹布局。那会让你的生活更轻松。

src/
├── main
│   ├── java
│   └── resources
└── test
├── java
└── resources

不建议修改Maven项目的默认文件夹结构。看起来你已经完全摆脱了main/srctest。我不确定您是如何、在哪里或是否存储测试类的。从长远来看,对代码不进行测试可能代价高昂。

无论如何,如果你决定坚持你的非标准项目结构,你将不得不设置源代码的路径如下:

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

这将通知Maven您的源代码在src而不是src/main/java下。如果您也有资源文件,如XML或属性文件,则必须使用build/resources标记将它们的位置传递给Maven。

最新更新