0
votes

Hi I'm trying to use ant to package my project. I'm unfamilar with it's details and have run into trouble during build.

My project directory structure is shown below:

project directory

When I run the ant script I get the following error:

 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

The build.xml file contains these lines at the start:

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

The warp.xml file contains the following:

 <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"/>

I've searched to no avail, it's probablly obvious and if so please could you kindly point out what the problem may be?

Update: I've added a build-impl.xml file from a same named NetBeans project to the directory. Now when I run the build.xml file I am getting the following error:

 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 file line 225 and 226 are below:

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

Many thanks

2

2 Answers

1
votes

The error is very clear, Ant cannot find this file:

nbproject/build-impl.xml

That folder is not in your directory structure.

1
votes

The solution to this problem is in NetBeans. Create a new Netbeans project and copy its build-impl.xml file into your project. It should work