Eclipse 独立于库在计算机上的位置创建build.xml文件

Eclipse 独立于库在计算机上的位置创建build.xml文件,eclipse,jakarta-ee,ant,build,Eclipse,Jakarta Ee,Ant,Build,为了生成war文件,我通过eclipse创建了一个build.xml文件。 build.xml如下所示: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- WARNING: Eclipse auto-generated file. Any modifications will be overwritten. To include a user speci

为了生成war文件,我通过eclipse创建了一个build.xml文件。 build.xml如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. --><project basedir="." default="build" name="project">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../../Documents/Eclipse EE/eclipse/"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.6"/>
    <property name="source" value="1.6"/>
    <path id="WebLogic System Libraries.libraryclasspath">
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.persistence_1.1.0.0_2-0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.oracle.jpa2support_1.0.0.0_2-1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/wlserver_10.3/server/lib/api.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/glassfish.jstl_1.2.0.1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.jsf_1.1.0.0_1-2.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.ejb_3.0.1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.enterprise.deploy_1.2.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.interceptor_1.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.jms_1.1.1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.jsp_1.3.0.0_2-1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.jws_2.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.activation_1.1.0.0_1-1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.mail_1.1.0.0_1-4-1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.xml.soap_1.3.1.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.xml.rpc_1.2.1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.xml.ws_2.1.1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.management.j2ee_1.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.resource_1.5.1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.servlet_1.0.0.0_2-5.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.transaction_1.0.0.0_1-1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.xml.stream_1.1.1.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.security.jacc_1.0.0.0_1-1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/javax.xml.registry_1.0.0.0_1-0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/wlserver_10.3/server/lib/wls-api.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.apache_1.3.0.1.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.i18n_1.9.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.logging_1.9.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.utils.full_1.10.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.utils.wrapper_1.4.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.utils.classloaders_2.0.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.common.security.providers.env_1.0.0.0_6-2-0-0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.common.security.saml2.manage_1.0.0.0_6-2-0-0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.weblogic.web.api_1.4.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.weblogic.rmi.client_1.11.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.transaction_2.7.1.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.workarea_1.8.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.xml.weblogic.xpath_1.5.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.datasource6_1.10.0.0.jar"/>
        <pathelement location="../../../../../Oracle/Middleware/modules/com.bea.core.weblogic.stax_1.10.0.0.jar"/>
    </path>
    <path id="Web App Libraries.libraryclasspath">
        <pathelement location="WebContent/WEB-INF/lib/log4j-1.2.17.jar"/>
    </path>
    <path id="EAR Libraries.libraryclasspath"/>
    <path id="project.classpath">
        <pathelement location="boum/classes"/>
        <path refid="WebLogic System Libraries.libraryclasspath"/>
        <path refid="Web App Libraries.libraryclasspath"/>
        <path refid="EAR Libraries.libraryclasspath"/>
    </path>
    <path id="run.Test.bootclasspath">
        <fileset dir="${java.home}/lib" includes="*.jar"/>
        <fileset dir="${java.home}/lib/ext" includes="*.jar"/>
        <path refid="WebLogic System Libraries.libraryclasspath"/>
    </path>
    <target name="init">
        <mkdir dir="boum/classes"/>
        <copy includeemptydirs="false" todir="boum/classes">
            <fileset dir="client">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
        <copy includeemptydirs="false" todir="boum/classes">
            <fileset dir="test">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
        <copy includeemptydirs="false" todir="boum/classes">
            <fileset dir="src">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="boum/classes"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="boum/classes" includeantruntime="false" source="${source}" target="${target}">
            <src path="client"/>
            <src path="test"/>
            <src path="src"/>
            <classpath refid="project.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="Test">
        <java classname="Test" failonerror="true" fork="yes">
            <classpath refid="project.classpath"/>
            <bootclasspath>
                <path refid="run.Test.bootclasspath"/>
            </bootclasspath>
        </java>
</target>
 <target name="war" description="Bundles the application as a WAR file" depends="clean, build">
        <mkdir dir="WebContent/WEB-INF/classes"/>
        <copy includeemptydirs="false" todir="WebContent/WEB-INF/classes">
                <fileset dir="boum/classes">
                <include name="**/**"/>
                </fileset>
        </copy>

        <war destfile="boumboum.war"
            basedir="WebContent"
            needxmlfile="false">
        </war>
    </target>
</project>

所以我的问题是:我如何以一种与我的计算机库的位置无关的方式编写这个build.xml文件?
假设我在一台不包含Oracle/Middleware文件夹的计算机上运行此构建文件。在这种情况下,我猜它不会生成war文件。有没有办法让它发挥作用?如果是这样的话,你能给我举个例子或者给我指一些他们做这件事的教程吗。因为我对ant完全陌生

可以存储第三方库

  • 在网络上的共享文件夹中
  • 在源代码管理系统中(git、svn、perforce)
  • 存储库中(artifactory、nexus)

在创建war之前,您应该获取这些库(方法取决于您选择的解决方案),并将它们放在本地

Thx,我想我会把它们放在一个共享的网络中。但我首先想到的解决方案是手动一个接一个地获取它们。你知道我可以使用哪些工具来简化这项任务吗?@coldistric你可以使用ant copy任务(可以展平)或ftp任务。