如何使用Jenkins将Java项目实现到maven项目中

时间:2018-01-03 10:49:29

标签: maven jenkins continuous-integration

我是Jenkins和Maven的新用户。 我正在尝试使用Jenkins中的Maven为我的Java项目实现持续集成。

这是我的pom.xml:

http://maven.apache.org/xsd/maven-4.0.0.xsd“>     4.0.0

<groupId>JavaApp</groupId>
<artifactId>JavaApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
    <javaVersion>6</javaVersion>
    <maven.compiler.source>1.${javaVersion}</maven.compiler.source>
    <maven.compiler.target>1.${javaVersion}</maven.compiler.target>
    <project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
    <project.reporting.outputEncoding>Cp1252</project.reporting.outputEncoding>
</properties>  

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.0</version>
        <type>jar</type>
        <scope>test</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.2.GA</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.6.7</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <directory>${project.basedir}/target</directory>
    <outputDirectory>${project.build.directory}/classes</outputDirectory>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <testSourceDirectory>${project.basedir}/test</testSourceDirectory>
    <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
    <resources>
        <resource>
            <directory>resources</directory>
        </resource>
        <resource>
            <directory>WebContent\WEB-INF</directory>
        </resource>
        <resource>
            <directory>WebContent\WEB-INF\lib</directory>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src_JavaKM</source>
                            <source>src_JNotifications</source>
                            <source>src_JARightsAccess</source>
                            <source>src_JACAccountController</source>
                            <source>src_JException</source>
                            <source>src_cmd</source>
                            <source>src_cmeJdn</source>
                            <source>src_KBEConnector</source>
                            <source>src_JACCommon</source>
                            <source>src_jdnWebServices</source>
                            <source>src_JAVGenericDao</source>
                            <source>src_aspect_ordering</source>
                            <source>src_JacLogging</source>
                            <source>src_JacDbrepresentation</source>
                            <source>src_conflicts</source>
                            <source>src_licensing</source>
                            <source>src_rightsAccessCheck</source>
                            <source>src_excel</source>
                            <source>src_validation</source>
                            <source>src_hbSessionOnDemand</source>
                            <source>src_JacFilters</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.3</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <complianceLevel>1.6</complianceLevel>
            </configuration>
            <executions>
                <execution>
                    <phase>process-sources</phase>
                    <goals>
                        <goal>compile</goal>   
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <id>default-testCompile</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>            
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <webXml>${basedir}/WebContent/WEB-INF/web.xml</webXml>        
            </configuration>
        </plugin>
    </plugins>
</build>

正如我们所看到的,这个pom.xml将完成Maven命令的所有阶段到包。

但现在问题是它无法正常工作并且往往会产生如下错误:

[ERROR] ConstraintValidator cannot be resolved to a type
[ERROR] The type java.util.Comparator cannot be resolved. It is indirectly referenced from required .class files

如果有人能查看我的pom.xml,我会很感激吗?并告诉我是否有任何问题?

0 个答案:

没有答案