0

我正在尝试使用下面的 ant build XML 文件来构建 WAR 文件。但是,在执行构建命令时,获取 java 包不存在。这个xml有什么问题?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="mdm">
    <property environment="env"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.8"/>
    <property name="source" value="1.8"/>
    <property name="build.properties.file" value="build.properties"/>

    <path id="mdm.classpath">
        <pathelement location="WebContent/WEB-INF/classes"/>
                <pathelement location="lib/ebx-addons.jar"/>
                <pathelement location="lib/ebx.jar"/>
                <pathelement location="lib/proton-j-0.22.0.jar"/>
                <pathelement location="lib/commons-cli-1.4.jar"/>
                <pathelement location="WebContent/WEB-INF/lib/servlet-api.jar"/>
                <pathelement location="WebContent/WEB-INF/lib/adminpermissionsutil.jar"/>
                <pathelement location="../EBX Server/shared/lib/commons-collections4-4.4.jar"/>
                <pathelement location="../EBX Server/shared/lib/commons-lang3-3.3.2.jar"/>
                <pathelement location="WebContent/WEB-INF/lib/javax.mail.jar"/>
                <pathelement location="../EBX Server/shared/lib/poi-4.1.1.jar"/>
                <pathelement location="../EBX Server/shared/lib/poi-ooxml-4.1.1.jar"/>
                <pathelement location="../EBX Server/shared/lib/poi-ooxml-schemas-4.1.1.jar"/>
                <pathelement location="../EBX Server/shared/lib/activemq-all-5.15.2.jar"/>
                <pathelement location="../EBX Server/shared/lib/servlet-api.jar"/>
                <pathelement location="../EBX Server/shared/lib/xmlbeans-3.0.2.jar"/>
                <pathelement location="../EBX Server/shared/lib/ps-mdm.jar"/>
                <pathelement location="../EBX Server/shared/lib/json-simple-1.1.jar"/>
        
    </path>
    <target name="init">
        <mkdir dir="WebContent/WEB-INF/classes"/>
        <copy includeemptydirs="false" todir="WebContent/WEB-INF/classes">
            <fileset dir="src/main/resources">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
        <copy includeemptydirs="false" todir="WebContent/WEB-INF/classes">
            <fileset dir="src/main/java">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="WebContent/WEB-INF/classes"/>
        <delete dir="build"/>
    </target>
    <target depends="build-project,build-war" name="build"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="WebContent/WEB-INF/classes" includeantruntime="false" source="${source}" target="${target}">
            <src path="src/main/resources"/>
            <src path="src/main/java"/>
            <classpath refid="mdm.classpath"/>
        </javac>
    </target>
    
    <target name="createJar" depends="build-project, updateBuildProperties" description="Create the Survivorship jar file">
                <property file="${build.properties.file}" />
                <echo level="info" message="Building ${app.id}.jar - ${app.name} (Build ${build.number} ${build.timestamp})"/>
                <jar jarfile="WebContent/WEB-INF/lib/${ant.project.name}.jar" basedir="WebContent/WEB-INF/classes" includes="**/*.class">
                    <manifest>
                        <attribute name="Implementation-Title" value="${app.name}"/>
                        <attribute name="Implementation-Version" value="${app.version} (Build ${build.number})"/>
                        <attribute name="Built-By" value="${build.user}"/>
                        <attribute name="Build-Date" value="${build.timestamp}"/>
                    </manifest>
                </jar>
            <jar jarfile="../EBX Server/shared/lib/SurvivorshipFunction.jar" basedir="WebContent/WEB-INF/classes" includes="com/mdm/survivorship/*.class">
            </jar>
        </target>
        
    <target  depends="build-project" name="updateBuildProperties" description="Maintain the build properties file">
            <propertyfile file="${build.properties.file}" comment="MDM build properties">
                <entry key="build.number" type="int" default="0100" operation="+" pattern="0000" />
                <entry key="build.timestamp" type="date" value="now" pattern="yyyy-MM-dd HH:m:ss" />
                <entry key="build.user" type="string" value="${user.name}" />
            </propertyfile>
    </target>

    
    
    
    <target depends="createJar" description="build WAR file" name="build-war">
        <property file="${build.properties.file}" />
        <mkdir dir="build"/>
        <war destfile="build/${ant.project.name}.war" webxml="WebContent/WEB-INF/web.xml">
            
            <fileset dir="WebContent">
                <include name="**/*.*"/>
                <exclude name="WEB-INF/classes/*/**"/>
            </fileset>
            <fileset dir=".">
                <include name="artifacts/*"/>
                <include name="artifacts/**/*"/>
                <exclude name="**/.gitkeep"/>


            </fileset>
            <manifest>
                <attribute name="Implementation-Title" value="${app.name}"/>
                <attribute name="Implementation-Version" value="${app.version} (Build ${build.number})"/>
                <attribute name="Built-By" value="${build.user}"/>
                <attribute name="Build-Date" value="${build.timestamp}"/>
            </manifest>
        </war>
    </target>
    <target name="import-dev-artifacts">
        <input message="    [input] Enter the EBX Admin Username: " addproperty="username">
            <handler classname="org.apache.tools.ant.input.SecureInputHandler"/>
        </input>
        <input message="    [input] Enter the EBX Admin Password: " addproperty="password">
            <handler classname="org.apache.tools.ant.input.SecureInputHandler"/>    
        </input>
        <input message="Enter the Dev Artifacts Import Mode:" addproperty="mode" validargs="copy,replace" defaultvalue="copy"/>
        <java classname="test.com">
            <arg value="import"/>
            <arg value="http://localhost:8080"/>
            <arg value="${username}"/>
            <arg value="${password}"/>
            <arg value="-${mode}"/>
            <classpath refid="mdm.classpath"/>
        </java>
        <input message="Press ENTER to continue..."/>
    </target>
    <target name="export-dev-artifacts">
        <input message="    [input] Enter the EBX Admin Username: " addproperty="username">
            <handler classname="org.apache.tools.ant.input.SecureInputHandler"/>
        </input>
        <input message="    [input] Enter the EBX Admin Password: " addproperty="password">
            <handler classname="org.apache.tools.ant.input.SecureInputHandler"/>    
        </input>
        <java classname="test.com">
            <arg value="export"/>
            <arg value="http://localhost:8080"/>
            <arg value="${username}"/>
            <arg value="${password}"/>
            <arg value="-copy"/>
            <classpath refid="mdm.classpath"/>
        </java>
        <java classname="test.com">
            <arg value="export"/>
            <arg value="http://localhost:8080"/>
            <arg value="${username}"/>
            <arg value="${password}"/>
            <arg value="-replace"/>
            <classpath refid="mdm.classpath"/>
        </java>
        <input message="Press ENTER to continue..."/>
    </target>
</project>

错误:

包 org.apache.commons.lang3 不存在 [javac] 导入 o​​rg.apache.commons.lang3.StringUtils;

大约有 100 个类似于上述错误消息的错误。

4

0 回答 0