如何从使用Eclipse进行构建转换为使用Ant

时间:2011-08-16 02:39:01

标签: java eclipse ant eclipse-3.6

我在Eclipse Helios中有一个spring web应用程序。我在其他项目的构建中使用Ant,但我不熟悉最初设置Ant构建文件。是否有一种无痛的方法可以实现从使用Eclipse进行构建,创建Ant构建文件和任何支持文件的过渡?我尝试将基本的Ant构建文件复制到我的应用程序中,但我不确定它是否接近我所需要的。我把它包括在下面。当我运行它时,它给了我这个错误。

BUILD FAILED
C:\..\..\workspace\..\build.xml:21: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.

我的系统JAVA_HOME路径设置为'C:\ Program Files \ Java \ jdk1.7.0 \ bin'

<?xml version="1.0" encoding="UTF-8"?>
<project name="projectName" default="dist" basedir=".">
<description>
    build file
  </description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist"  location="dist"/>

<target name="init">
  <!-- Create the time stamp -->
  <tstamp/>
  <!-- Create the build directory structure used by compile -->
  <mkdir dir="${build}"/>
</target>

<target name="compile" depends="init"
    description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>

<target name="dist" depends="compile"
    description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>

<!-- Put everything in ${build} into the News-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/ProjectName-${DSTAMP}.jar" basedir="${build}"/>
</target>

<target name="clean"
    description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>

1 个答案:

答案 0 :(得分:4)

请勿在{{1​​}}

中加入bin文件夹

试试这个:

JAVA_HOME