setting source classpath in eclipse with stupid project structure - eclipse

What do you guys do, when you have huge project built with ant for instance, where the source folders are right bellow the root project folder, for building classpath from source files ?
Putting entire project as a source folder is nonsense.
Putting separate folders as source folders can't be done if they are part of the package hierarchy and the only thing I could think of, is to copy the source folders into a separate folder and add it then as source folder which is weird but I don't know how else to do it.
Having to duplicate sources just because of the eclipse way of making classpath and also because of somebody doing stupid project structure
It's really pain in the ass...because the ant scripts are written for this structure.
Even if it was just one folder, it's a problem anyway. There must be included the upper folder to the source classpath which means it is included with all the crap around and also it means that package explorer is flooded with the packages.
example:
Instead of /project/src/java/utils where we can put src folder into source classpath...
there is project/java/utils + lot of crap like /project/docs is in the project as well.

The trick is:
An Eclipse project root directory is defined by where the .project and .classpath are.
Two options here:
Those Eclipse project files are located in the workspace (and the 'project', the one with 'java/utils' inside, is not)
Then you can make a linked folder within the Eclipse project to reference 'project', calling that linked folder as 'src', using it as your source folder.
The ant script remains right where it originally is (in the 'project' directory, along with all the other sub-directories)
Those Eclipse project files are located directly within the 'project' directory (along with 'java' and 'docs': don't.
Delete that Eclipse project (not its content, only its definition, that will only remove the .eclipse and the .classpath), and recreate anywhere else.
Then go back to 1.

For each source folder in eclipse you can choose which subfolders of it you want to include or exclude as a source folder (you can also use patterns). If I understand correctly, in your situation you can add the project root folder as a source folder and include only those folders that contain source. So in your example only "java" would be included.

Related

Eclipse project shows an unnecessary project folder that cannot be removed

I have a Java project in Eclipse IDE for Enterprise Java Developers 2018-12 (4.10.0) built with Maven.
For some reason the folder src/test shows in Project Explorer as a "project folder" (by that I mean a Eclipse project folder, not a file system folder), besides being shown in the project as a source folder as well. That seems unnecessary and anomalous. For example, the same does not happen with src/main, which appears as a source folder only:
If I try to delete the project folder src/test, Eclipse warns me that it contains source folders which will be deleted along with it. I actually tried it anyway once: made a copy of the files, deleted the src/test project folder, and then replaced the files in the disk, but when I do that, the project folder just pops back.
Why is this happening and how can I clean it up?
src with its subfolder test is shown for reasons
There are regular and source folders. For faster access source folders are displayed compacted on the first level instead of in the regular folder tree. In your case, there are five source folders src/main/java, src/main/resources, src/test/java, src/test/resources and - probably by mistake (see below) - src/main which are not shown in the regular folder tree, but on the first level.
In contrast, src and its subfolder test are regular folders and therefore are shown (even if they are empty except for the source folders) in the regular folder tree. They are shown so they can be selected and the right-click menu can be shown containing commands (which might be contributed by additional installed plug-ins) related to selected folders only. Selecting all source folders contained in src is not the same as selecting the src folder, for instance when doing a file search on the selected folders, a .gitignore file in the src folder would otherwise be missed.
src/main should not be a source folder
To have src/main and its subfolder src/main/java as source folders do not make sense since they are nested. In your case, it is a Maven project so you can right-click the project folder and choose Maven > Update Projects... to derive the source vs. regular folders settings from the pom.xml file and overwrite the settings made manually. These settings are stored in the .classpath file. In Maven projects the .classpath file can be derived from the pom.xml file and therefore it is recommende not be shared or versioned.

How to make a haskell module using EclipseFP?

This may be a dumb question, but I am having trouble creating a haskell module in eclipsefp. I can open the HaskellModule wizard but if I click browse next to source folder there is nothing except my project. My project has folders on it but they do not appear on the dropdown.
You need to define what source folders are in the Cabal file for your project. By default this may be the root folder, this is why you only see your project. In the cabal file say that your source folders are some of your sub folders and you should see them available in the wizard.
Bu default a new EclipseFP project uses src as a source folder, not the root.

Eclipse: Linking source located in multiple subfolders of given folder

I need to add external source code into my Eclipse project.
Project Properties>Java Build Path>"Link Source..." seems to be appropriate.
But it is necessary to add all the "source" folders of the folder that I link. It is a very complicated Folder structure, where "source" folders are located in different parent folders, but form the entire source code together.
I just hate the idea to manually navigate to every folder and add it. "Inclusion patterns" feature in eclipse seems to be suitable for the task, but I can't get its syntax and how to specify inclusion to add all "source" subfolders.

What's the difference between Project Folder and Source Folder in Netbeans?

For me, both things are exactly the same. What's the point of these? Where's the difference between Project Folder and Source Folder?
The Project Folder is where the nbproject folder (Netbeans configuration for the project) is stored. The Source Folder is where your have all your stuff.
They can be different but you need to check the Put NetBeans metadata into a separate directory in the New Project wizard. Afterwards, it can't be changed.
The Project Folder will have have the build and dist folders in it along with the source folder. The source folder only contains your source code where the project folder hold the compiled classes, meta information, test cases, and distribution folder.

Help me understand Eclipse's Java Build Path

I have been moving my Java projects from Jdeveloper over to Eclipse whenever I have to go back and make a change (I only work with Java projects sparingly).
Everytime I try to create a project in Eclipse (3.3.2) I spend quite some time trying to figure out the proper way to configure the source directories in the Java build path dialog.
The biggest problem I'm having is getting the source directories to match up with the package specified in the source files. For Example my project looks like this:
MyProject
DevelopmentBuilds
MainSRC
The MainSRC directory is also the "Root" package so my classes would be defined as:
package MainSRC.Sub1;
If I set my included directory to blank, the files compile but with many errors because the Packages are not in the right place.
How do I tell eclipse to start at MainSRC for the compilation rather than the children of MainSRC?
Or, should I the path up with one src folder with MainSRC as subfolder?
I basically don't understand how this works.
you need to set MainSRC as a 'Source Folder'.
Apparently, you project root are set as Source Folder.
Enter in project properties:
. Right click over your Project root, and select Properties
. Choose Java Build Path
. Remove all source folders
. Click 'Add Folder'
. Select 'MainSRC'
. Click Ok and Ok
Now, your MainSRC are a Source Folder. Some error occurs inside source files. For agile process, right click over package 'Sub1', and press F2. Rename your package for a new, then all your source files will be put in the correct new package.
[]'s,
And Past
You would need to set the source directory to the root MyProject directory. You would have to tell Eclipse to exclude the other directories (such as DevelopmentBuilds) as they are not source code.
You might find you're better off conforming to Eclipse's expectations and creating a source folder which contains your main package folder.