Sohaib
Sohaib

Reputation: 4704

Multiple source locations for java project in Eclipse

Can we specify multiple source locations as we can in ant build files in an eclipse java project. For example I have the following directory structure:

src1/com/mycompany/myproject/mypackage/*
src2/com/mycompany/myproject/mypackage/*

Java Files in both src folders have the package name as com.mycompany.myproject.mypackage .java files from src1 use .java files from src2 as well. However when I use my ant build xml file to import the project in eclipse only a single src is found under the project's Properties->Resource->LinkedResources can be found and the other source location is ignored. Is this a bug in eclipse? Or am I doing something wrong?

Upvotes: 2

Views: 2044

Answers (3)

Sohaib
Sohaib

Reputation: 4704

I did find a solution. Even though exporting directly from the ANT build file does not import from two locations we can do the following steps:

Right click project -> Build Path -> Link source -> Provide name and location of linked folder

This allows adding of a second folder with similar package structure and hence allows importing files. Hope this helps anyone with a similar problem.

Upvotes: 1

vempo
vempo

Reputation: 3153

You can add multiple source folders under the Source tab in Java Build Path of an Eclipse project. PROJECT_LOC refers to the location of the entire project, not its source folders. So you can point to the source folders using:

  • ${project_loc}/src1
  • ${project_loc}/src2
  • and so on

Upvotes: 0

Sanjeev
Sanjeev

Reputation: 9946

In Eclipse:

Right Click on your Project -> Build Path -> Configure Build Path.. -> Source Tab -> Add Folder ..

Hope this helps.

Upvotes: 1

Related Questions