Editing existing SBT project folder in Eclipse without copying it to workspace - scala

I have an existing SBT project which I'm primarily working on using Emacs with Ensime; I would like to keep it that way. However, I would also, occasionally, like to edit and refactor (and if possible, compile and run) the same project in Eclipse Scala IDE.
I don't seem to be able to go about doing that without the project folder being copied to a workspace. I've tried both [Import -> Existing Projects into Workspace] as well as [Import -> File System] to no avail—both seem to cause a copy to be made.
If it's something simple and obvious, I apologize; I'm quite a beginner with Eclipse. Also, I did ask Google, but couldn't find anything that is similar enough—usually it's just people moving away from one editor/IDE to Eclipse, so they don't care about the code being copied in the import process.
P.S. I tried opening the containing folder of the existing project as the workspace, but after that, the workspace is still empty.
P.P.S. One might ask, why not just make the Eclipse workspace the primary location of the project and then edit it with Emacs there, but that would mean changing my existing "standard" layout, or moving just one project out to a dedicated Eclipse workspace or smth. So I think it would be nice to just edit an existing folder with Eclipse without having to move or copy it.

OK, got it; it was easier than I'd thought: Just create a new (Scala) project with the path of the existing project (uncheck [Use default location]), and it seems to Just Work.

Related

Separating source and build ouptut in Eclipse

Recently, my work computer was suffering hardware failures so I had the pleasure of migrating data over to a new computer. A project itself is much smaller than the generated output and a significant portion of time was spent moving those generated output.
Currently:
C:\workspace\Project\src\...
C:\workspace\Project\bin\...
Ideally:
C:\workspace\Project\src\...
C:\workspace_output\Project\bin\...
NOTE: For me the source is linked so they don't actually exist within the project.
I was able to change one particular project by following the directions here. However, I have numerous projects and it would be a fairly time-consuming to apply that change to each project (create an "output folder" then point the project to that folder).
Is there a better way to define this behavior within Eclipse? I couldn't find a ${PROJECT_NAME} system variable that I could use (e.g. something like this). I'm fine if the answer is NO as it appears that I have to manually set this for each project. Maybe the next best thing is to write a script to automatically create folders and modify the .project and .classpath.
An alternative like:
Start Eclipse on new machine, point it to the old workspace
Clean projects
Then copy projects onto new machine
Use Eclipse on new machine.
where I can cut out the work of "cleaning" the projects because they are already separate.
In general you'd want to use some kind of version control system or source code management, such as cvs, svn, git, Perforce, Visual SourceSafe, etc. Barring that, you can also use File > Export (or right-click on projects) to export a project or group of projects from Eclipse and it will, by default, exclude any derived content (such as compiled code). Then you can import those projects into another Eclipse workspace.

Use eclipse as svn client

Running OSX.
I have used eclipse for years as a Java developer. I am now messing with all kinds of new technologies but still find myself using svn (don't ask its not my descision). Anyways I don't really like SVN command line as I find it almost impossible to sort through merge conflicts.
With that I was thinking about using eclipse (w/ subclipse plugin) as my SVN client whenever I need to do SVN type things. The one problem that I have found is that eclipse loves to create a .project file. I would never want to check this in as no one else is using eclipse. I know that I can add it to svn:ignore, but that has to actually commit that ignore to SVN as well, which I do not want to do either.
Anyway to create eclipse projects without the .project file. I know sounds dumb because I am sure that eclipse needs the .project file for all its projects. Would be nice just to create an SVN project (not Java project) and have eclipse leave off any other crap.
ideas?
There is no way to create an Eclipse project without the .project file (at least none that I know of), but you can tell Eclipse which files to ignore, as well.
Just go to Preferences -> Team -> Ignored Resources and add the pattern .project.
This setting is purely Eclipse-internal and does neither affect your global svn-ignores (defined in ~/.subversion/config) nor will it add any files to the repository.
Also, when checking out folders from SVN using Eclipse, make sure to create a General Project, not a Java Project, so the .project file is the only file Eclipse creates.
.project is actually not the only file that will be generated - depending on the "project natures" you add to a project.
To really separate the project from the source folders, you'll have to create the project in a separate folder - say the workspace - remove the original source folder and add the source folders as external links - see: Project Settings/Java Build Path/Source.

How to move an eclipse (helios) project to a different workspace?

First, Eclipse is not my native IDE -- I'm barely a n00b with it. I set up a project in a workspace that was actually in the directory of another client's project (I didn't really follow the whole workspace/project thing) and, in fact, now I can't even find the Eclipse workspace file to open it.
What I'd like to do is:
Open my eclipse project (/workspace?) -- I know where all the files are on disk, just not what to open in order to see them in Eclipse -- and
Move my project to a new workspace, which I guess I will put in a generic Eclipse-y place, and have that one workspace reference all my Eclipse projects.
(Is that the right way to do it? Does Eclipse dislike me being a one-project == one-workspace kind of guy?)
Please educate me regarding The Eclipse Way so that I can get back to work writing code.
Thanks!
Roughly a workspace (which is a directory) in Eclipse contains:
configuration (installed JRE, Servers runtimes, code formatting rules, ...)
one or more projects
You can of course have as many workspaces as you want (but only one can be opened at a time) and a project can also be part of different workspaces.
If you know where your sources are and want to move them to a new workspace here is a possible solution:
Start Eclipse and when prompted for a workspace choose where you want the workspace to be created (if directory doesn't exist it will be created). For example you can choose C:/Dev/Workspace/.
If you are not prompted, go to File->Switch workspace->Other
Once you are in your workspace you can import your exisiting project with File->Import then General->Existing Projects into workspace
Navigate to the folder containing your project sources, select your project and click finish
I don't know if it's a best practice or not but what I usually do is the following:
I have one workspace for each of my customer (workspace_cust1, workspace_cust2)
Each workspace references my commons library projects and add client specific projects
This way each time I change my commons library it's up to date in every workspace.
If you want to apply
one workspace = one project
You could to the following:
1) Copy the eclipse desktop shorcut
2) Modify the shortcut by appending "-data workspaceLocation "

Eclipse: how to keep project source files and ant build.xml seperate from eclipse workspace?

I'm trying to re-familiarize my self with the Eclipse environment and ant integration.
Question is: how to keep my sources dir + build.xml separate from the workspace?
What I have is
a small java project and its build.xml file with all the sources placed under a separate
project folder. I then started Eclipse and let it import my project via
New Project -> "Java Project from existing Ant Build File"
All went fine, until when I wanted to build the project from inside Eclipse using build.xml.
Ant starts complaining about not being able to find the source tree. After I examined
the workspace I found that Eclipse had copied the build.xml into the workspace, so it's
obvious that ant couldn't find any sources there. They are still under my project director
and I do want to keep them there, if possible.
so whats the best way so make this setup work? workspace on one side, my project on the other?
Thank!
edit: Is what I want even possible ?
Instead of using "Java Project from Existing Ant Buildfile", just create a simple "Java Project". In the wizard uncheck "use default location" and enter the path (or browse) to the top level directory of your existing project (i.e., where your build.xml is). True, eclipse will create .project and .classpath files in your project directory (if they do not already exist), but the project will remain outside the eclipse workspace.
Case in point, this setup has worked really well in a very particular situation on a standalone system where the source tree resides in a common location but each user has a workspace in a protected location. Using the method described above, each user of this system can create a project in their own eclipse workspace, execute ant targets and subsequently remove the project from their own workspace without affecting other users' workspaces.
What about using links?
Windows Symbolic Links
Linux man page for ln
I do this all the time in C++ projects (no Java, sorry, but I think the concept is portable).
I have my workspaces in ~/workspaces/{workspace_name}. I have a single shared project file in ~/{my_projects, and then the source trees (multiple versions) are in ~/proj1, ~/proj2, etc.
Within each ~/proj* directory, I put a symlink to ~/my_projects/.project and .cproject (required for C++, not used in Java). So each source tree is sharing the single project file. Then in each workspace (one for each source tree), I configure the workspace by importing the project link. For example, ~/workspaces/proj1 imports ~/proj1/.project, but ~/proj1/.project is actually a symlink to ~/my_projects/.project.
So this keeps the source separate from the workspaces. When building, there's no real configuration to do -- I just have Eclipse run make in the appropriate node of the tree -- we already have our own command-oriented build system (we're not using ant, but the same principle should apply).
I source-control the ~/my_projects folder in a private area of the SCM, so other team members don't see it or fiddle with it -- many of them don't use Eclipse at all.
There isn't really any need to try and avoid Ant and Eclipse using the same set of source files. In fact, its probably better that they do use the same set.
Bear in mind, you're not actually mixing anything. There is just one set of source files and then there are two different ways of building it; Ant and Eclipse. These builders are independent of each other, so there is no problem with being coupled to Eclipse. You can even happily commit all the eclipse files (.classpath, .project, .settings) to source control without affecting any developers who use a different IDE.
I do this all of the time (admittedly using maven, not ant), but the same principle applies.
If you have an existing project in Eclipse (with the .project in the source tree), then you can Import Project->Import Existing Project. When the dialog box comes up, you can choose to 'Copy projects into workspace'. Make sure this is unchecked, and them import.
You still store the .project in the original source tree, but thats all.
So now I have
code/xxx (which contains the .java files, which are in SVN)
code/xxx-workspace (which contains the eclipse workspace)

How To Manually Add Project To Eclipse Without Using Eclipse

I'd like to manually create the folders/files on the file system that create a new project in a workspace in eclipse, and show up in the Project Explorer when eclipse is started and the workspace is selected.
What files would need to be created to do this and where would they need to be?
Please understand that I do not want to open eclipse and make a new project using eclipse. I want to make a new project without using eclipse.
I think you will need to do the following
create a .project file and whatever other files needed by your specific type of project (for example java projects need .classpath) in the project folder, you can find out what you need by looking at those files for another project.
In your workspace .metadata folder, this is where eclipse keeps information about the current workspace, I think the plugin responsible for project definition is .metadata/.plugins/org.eclipse.core.resources , you will need to create those files yourself, some of them are binary, so you will need to open up the source of that plugin to see exactly how it writes them. Depending on your project, you will need to write more .metadata plugin information (for maven for example).
There is no easy way of doing this. Each new project modifies many scattered files throughout the eclipse structure (if you want a list, make a new project and find files created/modified most recently, and/or search for the project name.)
Short of writing the files by hand, there's not much you can do. I found these links in my reseach, but they're both pretty old and seem to be dead ends:
http://www.eclipsezone.com/eclipse/forums/t107019.html
http://dev.eclipse.org/newslists/news.eclipse.tools/msg36546.html
Based on the answers of #shipmaster I think this will work.
Go the workspace and create a new folder as your new required project name.
Copy the contents like .project, .classpath, .includepath etc from any existing project and modify the same like project name, source folder, build folder etc in .project. Do the similar changes in .classpath etc as per the new project requirements.
Unfortunately this is not enough to create a project by just doing eclipse restart so we need to do an import project and point it to this folder and we are ready to use the same now and we see the new project created in eclipse!
try archiving the file .. right click on project ---> export --->archive file(in General section) ..after you archive it as a zip you can import it after.
IF you want to manually copy a pre-existing project to a new workspace,
I have a solution for you:
Copy the project folder.
Paste it into the new work space.
File > Import > General > Existing Project Into Workspace
Eclipse will now see the project you cut+pasted manually.
Why I am doing this:
I am doing this so I can build upon my scrum stories while keeping documentation via working files that each successive step was built upon.
E.g. Story #2 is built upon story#1 code. But I don't want to version them because I want to be able to open them up one after another to do a presentation on my work flow.