I used Maven to create several projects in Eclipse, based on Maven archetypes, and ended up with this project structure (a parent project with multiple modules):
Parent project - pom.xml:
<name>backoffice-root</name>
<modules>
<module>backoffice-web</module>
<module>backoffice-ejb-core</module>
<module>backoffice-ws</module>
<module>backoffice-ear</module>
</modules>
Now I want to commit them to a SVN repository using Subclipse.
In my first approach, I added these projects to SVN in a flat hierarchy. The first project that I added was root, otherwise I'd get a warning saying that .svn folders in modules would be deleted:
backoffice-root
backoffice-web
backoffice-ejb-core
backoffice-ws
backoffice-ear
If I try to commit after that I get an error "backoffice-root/backoffice-web is already under version control". I believe this happens because when I added the projects to SVN, a .svn folder was created inside each one of them, but I don't know how can I solve this problem without deleting these folders and losing the information contained within them.
So I tried a second approach: adding root to SVN and then all the others under root (mapping my Maven project structure to SVN repository), creating this structure in the repository:
backoffice-root
backoffice-web
backoffice-ejb-core
backoffice-ws
backoffice-ear
But when I try to commit all of them, I get the same error of approach #1.
The only way that I get things to work is by just adding root to SVN and committing it (it commits all the modules since they are folders inside root). But I want to work on each project and commit them individually. Do I need to structure my Maven projects in a flat layout like explained in this post? How does one work this way with my original layout?
I'm working with the same your layout and everythings work. My project's skeleton is the following:
parent
-model
-util
-services
-web
model,util,services and web are all modules to parent and are placed in parent directory. Then I committed the parent project (that contains all modules) and finally I checked out and importing (In eclipse File->Import->Maven->Existing Maven Project) all modules.
Update1
Try to describe the procedure along some screenshoot:
Step1 I already committed the parent and all modules
After checkout you will wind the following situation:
where only the parent is linked with the svn. Now you have to do (File->Import->Maven->Existing Maven Project and selected all modules. Then automatically you will have all modules linked at the svn
Update2
My parent definition is the following:
<modules>
<module>model</module>
<module>util</module>
<module>services</module>
<module>vaadin-webapp</module>
</modules>
and each module has instead this configuration
<parent>
<groupId>myCompany</groupId>
<artifactId>myProject</artifactId>
<version>2.2.1-SNAPSHOT</version>
</parent>
Related
I would like to add the project files of a brand-new Eclipse project to the root-level of a git repo. I would like it to look like something like this:
./projectrepo/.git
./projectrepo/.project
./projectrepo/src
...
However, the Eclipse Egit wizard provides no obvious way to do that, and insists on creating an undesired subdirectory (screenshots below):
./projectrepo/project/.git
./projectrepo/project/.project
./projectrepo/project/src
...
How can I get Eclipse to add my files at the repository root?
I understand that the Egit manual advises against this, but I do not plan to ever have multiple projects in this repository, so the extra directory is unnecessary (and counts against filesystem path limits on Windows). The fact that it's advised against tells me it must be possible somehow (or the documentation's wrong).
System information:
Windows 7 64-bit
Eclipse Oxygen Java EE (4.7.0 Build id: 20170620-1800)
Eclipse EGit 4.8.0.201706111038-r
Screenshots of Eclipse's current undesired behavior
Configure Git Repository wizard. Most of the things I'd like to change, like Target Location, are uneditable. Path within repository can only be used to add more extra folders. Use or create repository in parent folder of project has a freetext repository path input, but only parent folders will validate and can be used.
Resulting undesired Git repository structure. I would like my project files to be in this directory, not an extra "TestProject" folder:
Try instead to:
import your project into your Eclipse workspace
then use Team/Share project: it should detect the Git repo in it.
That way, you should avoid the double-folder creation.
I am trying to learn how to setup multi-module maven project and share it with colleagues using SVN.
We work with eclipse IDE.
Here is how my project structure looks in SVN.
Each module has its own svn labels and tag trunk, branches, tags etc.
I check out all the modules individually by right clicking on them and choosing check out.
Finally I get the below in my eclipse project explorer:
Here is my pom for the parent project. and this throws errors when I do a mvn clean install
I want to understand how to checkout the projects/ modify my pom to get the build successful.
Thanks
You don't want to check out the root folders of your modules in SVN. All you want is the content of the trunk. So right click on the trunk folder and select Check out as.... Check it out as new projects and enable Maven on those project afterwards. Do this with each of your modules and you should be fine.
If you have Maven SVN connectors installed you have an option called Check out as Maven project. This is very comfortable as it does a few steps for you.
Yesterday and today i converted my eclipse juno project to multi module maven project in eclipse. I have 1 maven project of type 'pom-root' and all my other projects are modules. The modules have the root project as parent. This works correctly.
A few hours ago i did try to add the root project to egit, by simply right clicking the root project and picking share project -> egit.
I first created a new repository in a new directory, the result was that all my module project became empty and all source files were copied to the repository directory. Gladly i did see that and could recover easily by copying the files back.
Next after the failed attempt i tried to create the repository in the parent folder of project. This failed somehow and the root project became corrupt. After a lot of fiddling around i deleted the corrupt root project and created a new one of type 'pom-root', and somehow i managed to get everything running again.
Next i surfed to stackoverflow ( :-) ) and ask my question:
How can i put my multi module maven project in a new local git repository? (without losing or corrupting everything)
Summary: Delete your Eclipse projects (just their metadata, NOT their contents), then re-create them by importing them from the local repo.
Caveat: I'm at the "a little knowledge is a dangerous thing" stage, so treat this with suspicion.
I just went through this, and I think I have a solution/workaround.
The problem, I believe, is that most of Eclipse still doesn't grok projects nested inside other projects. When you shared your root project, EGit moved all of your project's files out of the Eclipse workspace into the local git repo and then updated Eclipse's metadata for the root project to reflect the new location of the files (good), but (since it is clueless about nested projects) that means it treated all the files in your child modules as though they were part of your root project and hence moved them into the git repo (that's OK) but didn't update the Eclipse project metadata for those child modules (that's bad). So Eclipse shows that you now have a bunch of (child) projects that don't have any files (not even a .project file, nor pom.xml). But if you ignore Eclipse and look directly in the working directory of the git repo, they're all sitting there happily (i.e. EGit copied the directory structure and all the files, including the child modules) and from git's perspective they are all currently untracked.
The solution (I believe) is: delete your Eclipse projects. No, really. But very carefully; see below. [Just to be safe, maybe use e.g. zip to take a backup copy of your lovely files that are sitting in the working directory of the repo. If they were already staged or committed this would be moot, but presumably at this point they aren't].
When you select each Eclipse project and right-click Delete, make sure that the "Delete project contents on disk (cannot be undone)" checkbox is NOT checked -- in other words, you are deleting the Eclipse metadata for each project (I did this for all the child modules and even for the root project) but you aren't deleting the files that are sitting in the working directory of the repo.
(I was worried that m2e might be too "helpful" and, as I deleted each child module, it might remove it from the parent's pom.xml, but thankfully that didn't seem to happen).
In the Eclipse Preferences for Team - Git - Projects, I do have "Auto share projects located in a git repository" enabled. That makes life easier but I assume that you could use less automagic approaches if you preferred.
Once all the relevant Eclipse projects have been deleted, use the Git Repositories view to Import Maven Projects; this creates new Eclipse projects (for the root project and for the child modules) with valid metadata that points to the files in the repo. Hallelujah.
I believe this works because one part of Eclipse that isn't clueless about nested projects is the import-maven-projects logic in m2e.
At this point all the files are still untracked, so next you probably want to select the root project and right-click Team --> Add to Index (which will also add all the child modules, I assume because it's oblivious to the nested projects and just treats them as extra files in the root project).
I wondered what would happen if I then added a new child module -- would it "just work" (and be shared in the git repo) or would it require more gyrations? I was pleased to find that (as far as I can see) it "just works": the Eclipse project metadata shows the files in the right place (in the git repo, as a child under the root project) and marks the project as shared in git.
So my guess is that if you or I had a time machine, the easy way to do this would have been to create the root Maven project, share that to EGit, and only then start creating the child Maven modules.
My environment (though it probably doesn't matter):
Eclipse 4.3.1 (Kepler SR1) with the usual versions of its components: m2e 1.4.0, EGit 3.0.3, m2e EGit connector 0.14.0.
When sharing a project as git and trying to make the Eclipse project folder as the git repository, Eclipse says that it is not recommended to do so and that it should be outside the Eclipse workspace.
Why is that?
From Eclipse EGit help pages,
It is probably not a good idea to make a project the root folder of your Repository
The reason is that you will never be able to add another project to this Repository, as the .project file will occupy the root folder; you could still add projects as sub-folders, but this kind of project nesting is known to cause lots of problems all over the place. In order to add another project, you would have to move the project to a sub-folder in the Repository and add the second project as another sub-folder before you could commit this change.
Some more information
It is a good idea to keep your Repository outside of your Eclipse Workspace
There are several reasons for this:
The new Repository will consider the complete folder structure of the Eclipse workspace as (potential) content. This can result in performance issues, for example when calculating the changes before committing (which will scan the complete .metadata folder, for example); more often than not, the workspace will contain dead folders (e.g. deleted projects) which semantically are not relevant for EGit but can not be excluded easily.
The metadata (.git-) folder will be a child of the Eclipse Workspace. It is unclear whether this might cause unwanted folder traversals by Eclipse.
You can easily destroy your Repository by destroying your Eclipse Workspace
While I agree about keeping the repository outside the Eclipse workspace, and I would still make a git repo within an Eclipse project root directory (like in this answer).
Unless your program is composed of lots of little inter-dependent projects, I would limit one git repo to one Eclipse project.
A git repo is about recording the content of a tree structure, and if that tree represents one project, it is easier to manage, tag, branch, merge (as a coherent set of files).
If it represents multiple project, you are not sure anymore about what a tag like "1.0" represents for each of the projects in that Git repo.
Plus, I like to add the .project, .classpath and .settings to the Git repo (as "Does git exclude eclipse project files from a new repo by default?")
I have a problem related to subversion and a maven multimodule project in eclipse.
Right now my project structure is (ignore the errors =)):
Then I upload the parent directory to SVN and make a checkout in another location, thinking that the eclipse directory structure will maintain, but it didn't, and it's a pain in the back to work using folders.
So my question is: how can I upload my project to a svn repository and keep the structure of the picture above?
Thanks
You can avoid this by never creating project inside the eclipse workspace. Always put them somewhere else, and then check them into and out of svn.