BEFORE_4
BEFORE_4
2019-02-26 16:19
采纳率: 100%
浏览 604
已采纳

linux环境ant编译打包无效?

使用的xml语言如下。在windows下可以编译生成class文件,但是在linux下无法生成class文件,是哪儿配置问题吗

<?xml version="1.0" encoding="UTF-8"?>
<!-- We build this project for ensure there is no compile issue only, so 
    we do not create any jar file now. -->
<project name="boardservice" basedir="." default="war">
    <property name="src.dir" value="src/main/java" />
    <property name="build.dir" value="${basedir}/build" />
    <property name="classes.dir" value="${build.dir}" />
    <property name="lib.dir" value="${basedir}/lib" />
    <property name="dist.dir" value="dist" />
    <property name="webapp.dir" value="src/main/webapp" />
    <property name="webapp.lib.dir" value="${webapp.dir}/WEB-INF/lib" />
    <property name="target.classes" value="${webapp.dir}/WEB-INF/classes" />

    <tstamp>
        <format property="buildtime" pattern="yyyy-MM-DD HH:mm:ss" locale='zh-cn' />
    </tstamp>
    <target name="clean" description="--> clean the project">
        <delete dir="${dist.dir}"/>
        <delete dir="${build.dir}" />
        <delete dir="${webapp.lib.dir}"/>
        <delete dir="${target.classes}"/>
        <delete dir="${build.dir}"/>
        <delete dir="${build.dir}"   failonerror="false"/>
        <delete dir="${classes.dir}" failonerror="false"/>
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${dist.dir}"/>
        <mkdir dir="${classes.dir}"/>
    </target>
    <path id="project.classpath"  >
        <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
        </fileset>
        <pathelement location="${build.dir}" />
    </path>

    <tstamp>
        <format property="DSTAMP" pattern="yyyyMMddHHmmss" />
    </tstamp>

    <!-- Compile java source -->
    <target name="compile" depends="clean"  description="Compile main source tree java files to class files">
        <echo message="compile java src..." />
        <javac  srcdir="${src.dir}" destdir="${classes.dir}"  source="1.6" target="1.6" encoding="UTF-8" debug="true"  failonerror="false" includeantruntime="false">
            <compilerarg value="-Xlint:unchecked"/>
            <src path="${src.dir}" />
            <classpath refid="project.classpath" />
        </javac>
    </target>
    <!-- Package War -->
    <target name="war" depends="compile" description="Build the web application archive">
        <copy todir="${target.classes}" overwrite="true" includeemptydirs="false">
            <fileset dir="${build.dir}">
                <include name="/**/*.xml" />
                <include name="/**/*.class" />
                <include name="/**/*.properties" />
                <exclude name="beanstest/**/*" />
                <exclude name="beans/common/datasource.xml" />
                <exclude name="/**/application.properties" />
            </fileset>
        </copy>
        <echo message="war begin..." />
        <war warfile="${dist.dir}/${ant.project.name}.war" basedir="${webapp.dir}" webxml="${webapp.dir}/WEB-INF/web.xml">
            <include name="**/*" />
            <exclude name="page/**/*" />
        </war>
        <echo message="war completed..." />
    </target>
</project>

这个在windows下一切正常,但是linux下无法复制${build.dir}的内容到${target.classes}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • BEFORE_4
    BEFORE_4 2019-02-28 11:11
    已采纳

    问题解决了。是因为代码

    <fileset dir="${build.dir}">
                    <include name="/**/*.xml" />
                    <include name="/**/*.class" />
                    <include name="/**/*.properties" />
                    <exclude name="beanstest/**/*" />
                    <exclude name="beans/common/datasource.xml" />
                    <exclude name="/**/application.properties" />
                </fileset>
    
    

    里面这些路径前面加了/,在linux下面必须把

    <include name="/**/*.xml" />
    

    更改为

    <include name="**/*.xml" />
    

    把前面的/去掉

    点赞 评论

相关推荐