如何包括战争文件Maven的依赖库使用Ant构建 [英] How to include maven dependency libraries in war file using Ant build

查看:166
本文介绍了如何包括战争文件Maven的依赖库使用Ant构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想包括通过Maven的蚂蚁依赖而构建WAR文件的文件。下面是pom.xml中。我尝试过多种解决方案,包括处决等,但没有任何工程。

I'm trying to include the maven dependencies files while build WAR file through ant. Here is the pom.xml. I've tried multiple solutions including executions etc but nothing works.

<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>CustomerPortal</groupId>
<artifactId>CustomerPortal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
        <resource>
            <directory>src</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>

        <!-- <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> 
            <configuration> <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes> 
            </configuration> </plugin> -->

    </plugins>
</build>
<repositories>
    <repository>
        <id>ZK CE</id>
        <name>ZK CE Repository</name>
        <url>http://mavensync.zkoss.org/maven2</url>
    </repository>
</repositories>
<dependencies>

    <!-- Log4j starts -->

    <!-- <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> 
        <version>2.0.2</version> </dependency> -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-1.2-api</artifactId>
        <version>2.0.2</version>
    </dependency>

    <!-- Log4j ends -->

    <!-- ZK starts -->

    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zkplus</artifactId>
        <version>7.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zhtml</artifactId>
        <version>7.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zkbind</artifactId>
        <version>7.0.2</version>
    </dependency>
    <!-- <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkmax</artifactId> 
        <version>6.5.2</version> </dependency> -->
    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zul</artifactId>
        <version>7.0.2</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.1</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.4</version>
    </dependency>

    <!-- ZK ends -->

    <!-- Hibernate starts -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.2.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>4.0.1.Final</version>
        <classifier>tests</classifier>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.1.0.CR2</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>2.5.1</version>
    </dependency>
    <!-- Hibernate end -->

    <!-- Email Api starts -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4</version>
    </dependency>
    <!-- Email Api ends -->
    <!-- Time API starts -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.3</version>
    </dependency>
    <!-- Time API ends -->

    <!-- BeanUtils Api starts -->
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.7.0</version>
    </dependency>
    <!-- BeanUtils Api ends -->


    <!-- MYSQL Driver starts -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
    <!-- MYSQL Driver ends -->




</dependencies>

下面是我的build.xml文件。每一件事情是工作的罚款,但我想在我的WAR文件的所有依赖文件

Here is my build.xml file. Every thing is working fine but I want all dependencies file in my WAR file

    <?xml version="1.0" encoding="UTF-8"?>
<project name="MedGulfCustomerPortal" default="war" basedir=".">

    <property name="project-name" value="${ant.project.name}" />
    <property name="war-file-name" value="${project-name}.war" />
    <property name="source-directory" value="src" />
    <property name="main-web-directory" value="WebContent" />
    <property name="web-directory" value="WebContent/WEB-INF" />
    <property name="web-xml-file" value="WebContent/WEB-INF/web.xml" />
    <property name="build-directory" value="build" />
    <property name="dir.classes" value="WebContent/WEB-INF/classes" />

    <tstamp prefix="build-info">
        <format property="current-date" pattern="d-MMMM-yyyy" locale="en" />
        <format property="current-time" pattern="hh:mm:ss a z" locale="en" />
    </tstamp>
    <path id="maven-ant-tasks.classpath" path="WebContent/WEB-INF/lib/maven-ant-tasks-2.1.3.jar" />
    <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />


    <!-- <javac debug="on" srcdir="${source-directory}" destdir="${dir.classes}" includes="**/*" includeantruntime="false">
            <classpath refid="maven-ant-tasks.classpath" />
        </javac>
    -->
    <target name="war" depends="">
        <mkdir dir="${build-directory}" />
        <delete file="${build-directory}/${war-file-name}" />
        <war warfile="${build-directory}/${war-file-name}" webxml="${web-xml-file}">
            <zipfileset dir="${main-web-directory}" includes="**/*zul" />
            <zipfileset dir="${web-directory}" includes="**" prefix="WEB-INF" />
            <zipfileset dir="${source-directory}" includes="**/*java" prefix="WEB-INF/classes" />
            <manifest>
                <attribute name="Built-By" value="${builder}" />
                <attribute name="Built-On" value="${build-info.current-date}" />
                <attribute name="Built-At" value="${build-info.current-time}" />
            </manifest>

        </war>
    </target>

</project>

任何帮助高度AP preciated。

Any help highly appreciated.

推荐答案

搜索后我发现,如果我把我的文件夹的依赖性在web部署大会。它会从那里复制库。

After searching I found that if I put my dependency folder in on web deployment assembly. It will copy the libraries from there.

这篇关于如何包括战争文件Maven的依赖库使用Ant构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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