2015-06-25 152 views
0

嗨我想用螞蟻來打包我的項目。我對它的細節並不感興趣,並在構建過程中遇到了麻煩。Java項目螞蟻生成錯誤

我的項目目錄結構如下所示:

project directory

當我運行Ant腳本我得到以下錯誤:

Buildfile: C:\Users\Trip Admin\Documents\Eclipse Projects\QuizServer\build.xml 

BUILD FAILED 
C:\Users\Trip Admin\Documents\Eclipse Projects\QuizServer\build.xml:12:  
Cannot find C:\Users\Trip Admin\Documents\Eclipse Projects\QuizServer\nbproject\build-impl.xml 
imported from C:\Users\Trip Admin\Documents\Eclipse Projects\QuizServer\build.xml 

build.xml文件包含這些行的開始:

<project name="QuizServer" default="default" basedir="."> 
<description>Builds, tests, and runs the project QuizServer.</description> 
<import file="nbproject/build-impl.xml"/> 

warp.xml文件co ntains如下:

<project name="quizserver" basedir="." default="main"> 

<property name="src.dir"  value="src"/> 
<property name="build.dir" value="build"/> 
<property name="classes.dir" value="${build.dir}/classes"/> 
<property name="jar.dir"  value="${build.dir}/jar"/> 
<property name="main-class" value="quizserver.QuizServer"/> 
<property name="lib.dir"  value="libs"/> 

<path id="classpath"> 
    <fileset dir="${lib.dir}" includes="**/*.jar"/> 
</path> 


<target name="clean"> 
    <delete dir="${build.dir}"/> 
</target> 

<target name="compile"> 
    <mkdir dir="${classes.dir}"/> 
    <javac srcdir="${src.dir}" includeantruntime = "false" source = "1.7" target = "1.7" fork="true" destdir="${classes.dir}" classpathref="classpath" compiler="classic" /> 
</target> 

<target name="jar" depends="compile"> 
    <mkdir dir="${jar.dir}"/> 
    <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}"> 
     <manifest> 
      <attribute name="Main-Class" value="${main-class}"/> 
     </manifest> 
    </jar> 
</target> 

<target name="run" depends="jar"> 
    <java fork="true" classname="${main-class}"> 
     <classpath> 
      <path refid="classpath"/> 
      <path location="${jar.dir}/${ant.project.name}.jar"/> 
     </classpath> 
     <jvmarg value="-Xmx512m"/> 
     <jvmarg value="-Xmx512m"/> 
    </java> 
</target> 

<target name="clean-build" depends="clean,jar"/> 

<target name="main" depends="clean,run"/> 

我已經搜查無果,這是probablly明顯,如果是的話,請你能親切地指出問題可能是什麼?

更新:我已經將一個名爲NetBeans項目的build-impl.xml文件添加到目錄中。現在,當我跑我收到以下錯誤build.xml文件:

Buildfile: C:\Users\Trip Admin\Documents\Eclipse Projects\QuizServer\build.xml 
-pre-init: 
-init-private: 
-init-user: 
-init-project: 
-init-macrodef-property: 
-do-init: 
-post-init: 
-init-check: 

BUILD FAILED 
C:\Users\Trip Admin\Documents\Eclipse Projects\QuizServer\build-impl.xml:226: Must set src.dir 

build-impl.xml中文件的行225和226都低於:

<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check"> 
    <fail unless="src.dir">Must set src.dir</fail> 

非常感謝

回答

1

的錯誤非常清楚,螞蟻找不到此文件:

nbproject/build-impl.xml 

該文件夾不在您的目錄結構中。

1

此問題的解決方案在NetBeans中。創建一個新的Netbeans項目並將其build-impl.xml文件複製到您的項目中。它應該工作

+0

我已經複製了該文件,但現在出現以下錯誤:BUILD FAILED C:\ Users \ Trip Admin \ Documents \ Eclipse Projects \ QuizServer \ build-impl.xml:226:必須設置src。 DIR ...? – TripVoltage

+0

將你的項目視圖設置爲文件 - >然後轉到文件'build-impl.xml',右鍵單擊它並選擇乾淨。 – cjds