Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Building from source code archive
Building from source code archive [message #1094621] Mon, 26 August 2013 01:36 Go to next message
Howard Spindel is currently offline Howard SpindelFriend
Messages: 8
Registered: August 2013
Junior Member
I have an Eclipse Java project. I have put the source Java files under a source code control system (monotone, but I think that's irrelevant to the question). I also put a select few eclipse files I found into the source control (.project, .classpath, .settings).

If a create a fresh new directory and check out all of the source files and then fire up eclipse with that directory as my workspace, eclipse doesn't know what to do. All of the Java files are there, but eclipse doesn't know that they are organized into a project which could be built.

But if I start eclipse with the original directory as my workspace, in which I created the project, it all works. I do not use any project builder software. Somewhere years ago (I don't remember) I must have told eclipse which files constitute my project.

So, I am missing archiving something that eclipse needs.

What do I need to put into source code control so that I can check out a fresh copy and have eclipse understand how to build it?

Thanks.

Eclipse is kepler if that matters.
Re: Building from source code archive [message #1094662 is a reply to message #1094621] Mon, 26 August 2013 03:13 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On 8/25/2013 8:42 PM, Howard Spindel wrote:
> I have an Eclipse Java project. I have put the source Java files under
> a source code control system (monotone, but I think that's irrelevant to
> the question). I also put a select few eclipse files I found into the
> source control (.project, .classpath, .settings).
>
> If a create a fresh new directory and check out all of the source files
> and then fire up eclipse with that directory as my workspace, eclipse
> doesn't know what to do. All of the Java files are there, but eclipse
> doesn't know that they are organized into a project which could be built.
> But if I start eclipse with the original directory as my workspace, in
> which I created the project, it all works. I do not use any project
> builder software. Somewhere years ago (I don't remember) I must have
> told eclipse which files constitute my project.
>
> So, I am missing archiving something that eclipse needs.
>
> What do I need to put into source code control so that I can check out a
> fresh copy and have eclipse understand how to build it?
>
> Thanks.
>
> Eclipse is kepler if that matters.
You need to import the project into the new workspace using the
File->Import wizard. Your projects don't actually need to reside in the
workspace. You can check the project out and then use the
Import->Existing Project option to add it to the workspace.
Re: Building from source code archive [message #1094692 is a reply to message #1094662] Mon, 26 August 2013 04:18 Go to previous messageGo to next message
Howard Spindel is currently offline Howard SpindelFriend
Messages: 8
Registered: August 2013
Junior Member
Import from what?

The scenario is one in which I want to recover from a system crash. Assume there are no other workspaces available to import from.

I want to check out my code from an sccs into a new directory, and start eclipse using that directory as my workspace.

Project configuration has to be stored in the sccs for this to work.
Re: Building from source code archive [message #1094693 is a reply to message #1094692] Mon, 26 August 2013 04:20 Go to previous messageGo to next message
Howard Spindel is currently offline Howard SpindelFriend
Messages: 8
Registered: August 2013
Junior Member
I forgot to mention that I have tried checking the directory .metadata/.plugins/org.eclipse.core.resource/projects into the sccs as well. This does not solve the issue.
Re: Building from source code archive [message #1094990 is a reply to message #1094693] Mon, 26 August 2013 13:43 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
You import the project from where you checked it out. Projects do not equal workspaces. A workspace is a collection of projects. You can't simply place a project in a workspace folder. You have to tell Eclipse that the project exists.
Re: Building from source code archive [message #1095219 is a reply to message #1094990] Mon, 26 August 2013 19:57 Go to previous messageGo to next message
Howard Spindel is currently offline Howard SpindelFriend
Messages: 8
Registered: August 2013
Junior Member
Yes, I understand all of that, hence the point of my question.

How do I put the information to tell eclipse that the project exists under source control?

You said I import the project information from where I checked it out (I assume you mean where I checked the source out). I have to know what information to put into the archive so that I can check it out again.
Re: Building from source code archive [message #1095241 is a reply to message #1095219] Mon, 26 August 2013 20:38 Go to previous messageGo to next message
Howard Spindel is currently offline Howard SpindelFriend
Messages: 8
Registered: August 2013
Junior Member
Perhaps it would help if I asked the same question a different way.

What file(s) in a workspace does eclipse use to track all of eclipse's knowledge about the projects in that workspace?
Re: Building from source code archive [message #1095252 is a reply to message #1095219] Mon, 26 August 2013 20:57 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 8/26/2013 1:57 PM, Howard Spindel wrote:
> Yes, I understand all of that, hence the point of my question.
>
> How do I put the information to tell eclipse that the project exists
> under source control?
>
> You said I import the project information from where I checked it out (I
> assume you mean where I checked the source out). I have to know what
> information to put into the archive so that I can check it out again.

Let's start over a little bit.

You said you had a project from a version-control repository. David's
point was that, if a real Eclipse project, then you should be able to
launch Eclipse and use File -> Import... -> General -> Existing Projects
into Workspace to get the project into Eclipse.

If instead your project was only source code and you were hoping to add
to it all the Eclipse configuration for the next guy (including
yourself) to have a genuine Eclipse project, which sort of sounds like
what you were doing, then...

0. Do create a new workspace (or use an existing one).

1. Don't save workspace files or subdirectories (like
..metadata/anything) in version control since workspaces aren't portable
between computer hosts.

2a. Do not create a new subdirectory in that workspace corresponding to
the project you want to import. When you import an existing project into
your Eclipse workspace, you will have the choice of copying everything
(including the source code) into the subdirectory that is your
workspace, or leaving it where it started (probably cloned/checked out
from source-code control)--this is what I do (I use Git).

- or -

2b. Do use the Eclipse new project wizard to create a new Eclipse
project if your source has never been in Eclipse before, but just as for
the import, likely you'll tell the wizard where to manage the location
of the project and browse to the location where you cloned/checked out
the already existing source code. This is a lot more complicated and may
cause you either to restructure your project a little or muck with
Eclipse's notion of source folders--right-click parent folder of source
code, choose Build Path -> Use as Source Folder, etc. (You'll likely be
back in this forum asking for help on that.)

4. Do create and include the entire project in source code control once
you've set it up. This would mean:
- .project
- .classpath
- .settings (if a web application project, maybe other types)

5. For version-control (source control), do include subdirectories like
..svn, .git, etc. These are what tell Eclipse, if you're integrating
version-control with Eclipse (I used to for Subversion, I do not for
Git, but I have colleagues that do use eGit).

I hope this helps narrow the gap between you and Eclipse at least a little.

Russ
Re: Building from source code archive [message #1095255 is a reply to message #1095241] Mon, 26 August 2013 21:05 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 8/26/2013 2:38 PM, Howard Spindel wrote:
> Perhaps it would help if I asked the same question a different way.
>
> What file(s) in a workspace does eclipse use to track all of eclipse's
> knowledge about the projects in that workspace?

My other answer sort of included this. To repeat, workspaces are not
considered portable even between computers you've set up to be identical.

Only projects are (and should be) portable.

Moving on...

However, it is indeed possible to render elements of your otherwise
project absolutely non-portable.

For instance, if in Java, you can wreck your .classpath file for use by
others by attaching source or Javadoc to a JAR in use (in Build Path ->
Libraries) on host-specific paths (that won't necessarily exist on your
colleague's hosts).

To avoid this, attach source or Javadoc carefully using Workspace
buttons in the dialog for that making certain that the JARs you attach
for this purpose exist in the project and under version control. You'll
recognize this when you get to doing it (if you get to doing it at all).
Re: Building from source code archive [message #1095281 is a reply to message #1095252] Mon, 26 August 2013 21:58 Go to previous messageGo to next message
Howard Spindel is currently offline Howard SpindelFriend
Messages: 8
Registered: August 2013
Junior Member
Thank you for your reply. Unfortunately, it still does not give the information I want.

I am a single developer working alone.

I have current projects in a current workspace set up in eclipse. It all works fine. The source code for the project is stored in an sccs (monotone). The sccs repository is saved offsite for safety.

Imagine that a fire destroys all my local computers. I buy new computers. Install eclipse. Create a workspace. Populate the workspace with source retrieved from the offsite sccs.

At this point, eclipse still doesn't know anything about the project source files that I just loaded into the workspace. Yes, I could tell it about those files by using the new project wizard, but that's a lot of work to recreate something that should be archiveable. Since this is a brand-new computer, I don't have some previous workspace lying around that I could import projects from.

I'm not asking for a portable workspace. I'm asking for portable projects, which have to include the information that eclipse uses to understand what constitutes that project.



Re: Building from source code archive [message #1095298 is a reply to message #1095281] Mon, 26 August 2013 22:31 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 8/26/2013 3:58 PM, Howard Spindel wrote:
> Thank you for your reply. Unfortunately, it still does not give the
> information I want.
>
> I am a single developer working alone.
>
> I have current projects in a current workspace set up in eclipse. It
> all works fine. The source code for the project is stored in an sccs
> (monotone). The sccs repository is saved offsite for safety.
>
> Imagine that a fire destroys all my local computers. I buy new
> computers. Install eclipse. Create a workspace. Populate the
> workspace with source retrieved from the offsite sccs.
>
> At this point, eclipse still doesn't know anything about the project
> source files that I just loaded into the workspace. Yes, I could tell
> it about those files by using the new project wizard, but that's a lot
> of work to recreate something that should be archiveable. Since this is
> a brand-new computer, I don't have some previous workspace lying around
> that I could import projects from.
>
> I'm not asking for a portable workspace. I'm asking for portable
> projects, which have to include the information that eclipse uses to
> understand what constitutes that project.

Great, this is the simplest scenario. My previous answers were
predicated on not knowing exactly what you wanted to accomplish.

You've created Eclipse projects and monotone is saving them for you
off-site.

A fire destroys your computers.

You purchase a new computer and restore your projects somewhere in your
filesystem.

You install Eclipse and create a new, empty workspace. Note that I'm
assuming you're developing in Java. I don't know how this works for any
other Eclipse-supported languages.

Launch Eclipse, open the workbench to your workspace. Now you do:

1. File -> Import... -> General -> Existing Projects into Workspace.
2. Click Next.
3. Click Browse.
4. Browse to the parent directory of one (or some or all) of your newly
checked-out projects and click Ok.
5. Select the project(s) you want to import, do NOT click "Copy projects
into workspace", and click Finish.

What you have now is...

1. One or more of your Eclipse projects established in the new workspace
on your new computer.
2. The source code to that project (those projects) not under a
subdirectory in the workspace folder, but wherever you checked the
projects out from monotone.
3. The ability to continue working as if nothing happened.

There are no portability issues in this scenario as long as you included
..project, .classpath, .settings per my earlier discussion, and as long
as you didn't screw up .classpath with locally specific paths to source
or Javadoc for the JARs you consume (also per a previous answer).

Hope this helps.
Re: Building from source code archive [message #1095429 is a reply to message #1095298] Tue, 27 August 2013 03:35 Go to previous messageGo to next message
Howard Spindel is currently offline Howard SpindelFriend
Messages: 8
Registered: August 2013
Junior Member
Thank you very much for that excellent response.

I was able to get this to work. Apparently, the key file to include in the archive is the .project file. I also did not understand the point about importing from the newly retrieved archive.

The remaining issue for me is that the Java building configuration is not preserved (all of the project options like what's a warning and what's an error). I am guessing that this is because I have them as workspace preferences instead of enabling per-project preferences. If I were to convert to per-project preferences, is there now an additional file to archive that would preserve them?

Thanks again - your post was extremely clear and helpful.
Re: Building from source code archive [message #1095460 is a reply to message #1095429] Tue, 27 August 2013 04:43 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 08/26/2013 09:35 PM, Howard Spindel wrote:
> Thank you very much for that excellent response.
>
> I was able to get this to work. Apparently, the key file to include in
> the archive is the .project file. I also did not understand the point
> about importing from the newly retrieved archive.
>
> The remaining issue for me is that the Java building configuration is
> not preserved (all of the project options like what's a warning and
> what's an error). I am guessing that this is because I have them as
> workspace preferences instead of enabling per-project preferences. If I
> were to convert to per-project preferences, is there now an additional
> file to archive that would preserve them?
>
> Thanks again - your post was extremely clear and helpful.


There is a separate mechanism, or so I believe--I could be wrong, but
nothing in my 8-odd years in Eclipse leads me to think I am, that you
can use to transfer preferences for various things from one workspace to
another.

The only preferences I carry is an XML file that restores Java code
formatting the way I want to see it (Allman instead of KNF).

I have experimented with saving other preferences and it does work, but
it's more trouble than it's worth (to me). When I create a new
workspace, I don't change much (editor width to 120, draw the right
margin line, substitute spaces for tabs and a couple of Java compiler
settings).

Google for how to save/restore preferences. It's not very hard, in fact
it uses the same import/export mechanism as already discussed. The code
formatting works via a different mechanism.

Glad to be of some help.

Best regards,

Russ
Re: Building from source code archive [message #1095767 is a reply to message #1095429] Tue, 27 August 2013 13:53 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
When you turn on Project Specific preferences, they are saved in a file in the .settings folder in the root of your project. If you check in the .settings folder and the files in that folder, your project specific preferences will be saved with the project.

Once you have the Project settings the way you want them, you should be able to copy the .settings folder to other projects or to new projects to keep things consistent.
Re: Building from source code archive [message #1096039 is a reply to message #1095767] Tue, 27 August 2013 22:23 Go to previous message
Howard Spindel is currently offline Howard SpindelFriend
Messages: 8
Registered: August 2013
Junior Member
Thank you both for the replies about project settings.

What I found worked fine was to use eclipse's export settings feature and place the exported file into the source archive. Import it if the archive is recreated and all my settings come back. Don't know if this works for source formatting options (I don't use them).

Only (minor) drawback is that I have to remember to export a new copy of the settings if I change them. I so rarely change them that it's not much of an issue. Less cumbersome that switching to project-specific settings since all of my projects are set the same way.
Previous Topic:Programatically select System Editor in Open With Menu
Next Topic:Eclipse not lauching
Goto Forum:
  


Current Time: Thu Apr 18 06:38:13 GMT 2024

Powered by FUDForum. Page generated in 0.03006 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top