Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 142967

Summary: Import project from build.xml doesn't get directories right for building.
Product: [Eclipse Project] Platform Reporter: Ricky Clarkson <ricky_clarkson>
Component: AntAssignee: Platform-Ant-Inbox <platform-ant-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Ricky Clarkson CLA 2006-05-22 07:34:25 EDT
After importing a project from build.xml, build using ant, as described below, and get an error pointing to missing files from a directory inside the workspace.  I think the working directory for ant should be set to the project directory, not anywhere inside the workspace.

Here are some steps to reproduce the problem.

Outside Eclipse:

mkdir testproject
mkdir testproject/src
cd testproject
vi src/Main.java

enter:

class Main
{
        public static void main(String[] args)
        {
                System.out.println("Hello World");
        }
}

vi build.xml

enter:

<project name="Test" default="main">
        <target name="main">
                <mkdir dir="build"/>
                <javac destdir="build">
                        <src path="src"/>
                </javac>
        </target>
</project>

ant

You should see:

Buildfile: build.xml

main:
    [mkdir] Created dir: /directory/testproject/build
    [javac] Compiling 1 source file to /directory/testproject/build

BUILD SUCCESSFUL
Total time: 2 seconds

In Eclipse:

Go to File->New->Project.
Select "Java Project from Existing Ant Buildfile".
Select build.xml in the textfield "Ant Buildfile".
Click Finish.
Double-click on build.xml in the Navigator View.
Right-click on the target 'main' in the Outline View (default: right hand side).
Select Run As->1. Ant Build.

Output:

Buildfile: /directory/.eclipse_workspace/Test/build.xml
main:

BUILD FAILED
/directory/.eclipse_workspace/Test/build.xml:4: srcdir "/directory/.eclipse_workspace/Test/src" does not exist!

Total time: 345 milliseconds
Comment 1 Ricky Clarkson CLA 2006-05-22 08:04:02 EDT
I fixed the immediate symptom by setting a base directory for the build.xml:

Right-click on build.xml, Run As, External Tools...
Select the Base Directory in that dialog.

However, the other files that Eclipse doesn't know or care about from my project directory don't appear.

For example, my 'unittests' task outputs unittest_output and unittest_error, which I cannot see inside Eclipse, because Eclipse is looking at /directory/.workspace/Test instead of /directory/Test.
Comment 2 Darin Swanson CLA 2007-02-27 09:47:21 EST
This will be solved with the fix to allow the buildfile to be linked to the original location in the filesystem instead of being imported into the workspace.

*** This bug has been marked as a duplicate of bug 147337 ***