eclipse + svn: how to manage whole workspace with svn - eclipse

I have a workspace with several projects that are build using maven.
I know that i can add each project separate to the svn, but how can i add my super-pom?
My super-pom is in the workspace directory and therefore not visible.
Can i configure eclipse to add the whole workspace directory to my svn?
Best regards

This is not exactly what you asked for, but I have used following pattern with svn-eclipse-maven combo quite successfully.
/pom.xml
- contains only referenced projects
/parent/pom.xml
- contains dependencies common to all projects, <dependencyManagement>, properties..
- the stuff you would normally put in root pom
/procject(X|Y|Z|...)/pom.xml
- normal project pom.xml:s
This way you only need to commit /pom.xml outside eclipse when you add or remove a project (witch is relatively rare). With this configuration parent and project:s are visible in eclipse and only root/reactor pom is not visible in eclipse.

Related

Importing multimodule maven project from Git into Eclipse/STS

I have been desperately trying to import a multimodule maven project from GIT into my (freshly installed) STS 3.9.4.
During the last hours I tried lots of solutions that were posted on stack overflow, but none of them worked for me.
These are the steps I did:
git cloned the repo from the command line (intentionally, because it didn't work either when I used the GIT integration of STS)
imported the project via File / Import / Maven / Existing Maven Projects
After the project was imported, it looks like this:
(please ignore the red icon at the top left, the problems persists even when this icon is not there)
I can Run As / Maven Install any pom.xml, but when I try to edit java sourcecode Eclipse tells me The resource is not on the build path of a Java project.
To fix this I tried:
convert to faceted form
added Java nature
Configure Build Path / Set as source folder
add buildcommand org.eclipse.jdt.core.javabuilder to .project
Being able to build is fine, but editing sourcecode without support for Organize Imports, Format Source, and so on is a real pain.
From your screenshot I assume the modules are nested within the directory of the reactor pom(=parent pom) and you have imported all of them as projects (reactor and modules).
Don't add a java builder to the "reactor" project.
Make sure not to open the java files from the projects corresponding to the reactor pom, but from src folder within the corresponding module projects.
The solution to this problem was somehow hidden, but in the end I have to say the reason was clear.
After I checked with a different multimodule project (https://github.com/Activiti/Activiti.git), I was sure that my STS and other components don't suffer from a generic problem. So the cause must be located in the project itself.
The multimodule project was setup correctly on the pom.xml level. But the topmost pom.xml was modified: most of the modules had been commented out:
The developer who introduced that change didn't experience any problems because he kept his already existing workspace. And the problem only occurs when a new workspace gets created and maven scans the pom files.

Eclipse adding the project overrides maven dependency

I have a maven project that uses other small projects. And I added them to master's pom file.
So my Eclipse project properties looks like following:
>Master project
>Java Resources
>Libraries
>JRE System Library
>Maven dependencies
>smallProj1.jar
>smallProj2.jar
The thing is I do not have the all code for smallProj1 and smallProj2 and whenever add them to my workspace Eclipse overrides the maven dependencies and simply calls the two projects instead the jar files from my local maven repository and then I have all over the code those red underlines. Project properties in Eclipse looks as following after I add them to my workspace:
>Master project
>smallProj1
>smallProj2
>Java Resources
>Libraries
>JRE System Library
>Maven dependencies
>smallProj1 (not jar anymore - folder)
>smallProj2 (not jar anymore - folder)
Since I also want to have a look to smallProj1 and smallProj2 code while I am coding, I want to keep them both in my workspace. But I want my Master project to use the jar files that I provided, not the small projects in the workspace.
Any ideas on that?
You could right click on a project and set "Maven" -> "Disable Workspace Resolution". This will let Maven find the dependencies from Maven and not within the workspace. I don't think it is possible to do this on a dependency basis.
But I think in your case it would be better to fix the broken smallProjX in your workspace (as they exactly contain the code you need), so that the master project could be build correctly.

Eclipse m2e multi-module project checkout and convert to maven

I have recently had need to checkout an apache project to do some fact-finding/debugging (specifically maven-surefire-plugin, see this question). This, like most other apache projects, is a maven multi-module project. So, in eclipse, I open up the SVN Repositories browswer, add a new repository, find the project and right-click->Checkout.... In the wizard, I click Checkout as a project in the workspace and type in the name of the project.
I have the project, now I need to let eclipse know its a maven project, so right-click->Configure->Convert to Maven Project. Now the parent project is a maven project. I can right-click->Run As->Maven Build and it works. But, all the modules are just folders. Eclipse doesn't know anything about where the source code is or even if it has any. In a single module project it would have set the source folder, build folder and other configuration automatically. Further more, if you are creating a multi-module project from scratch, you start by creating the parent project, then, when you add modules to it, they each show up as individual projects in eclipse with the physical directory living under the parent project folder as needed by the default maven build process.
So now, knowing how its done when creating new projects I can File->New->Project..., choose General->Project, give the project a name (I match it to the module name), uncheck Use default location and set Location: to the path on to the module inside of the parent project folder. After clicking Finish, and repeating the process for each other module I have something that looks similar to what I would expect. I now need to convert every individual module to a maven module in the same fashion as the parent project. Great, they are all maven projects, right?
So then I open them up, and the source folder is not set.
Argh... Then I go to each project, twist it open, and on the src folder I right-click->Build Path->Use as Source Folder. Lather, rinse, repeat... Once done on all the projects, it really looks and feels like I started this project from scratch. Things function.
My question is, is it really this hard? Am I missing a shortcut? Wouldn't it make sense if Configure->Convert to Maven Project on the parent pom realized it was a multi-module project and did all the work for me? This is a very painful process for apache projects as they all seem to have many, many, modules... Anyone know of a better process?
You could try to pull all the code down outside of Eclipse, import the parent project as an existing Maven project (right-click -> Import... -> Existing Maven Projects), and see if it all comes in the way you expect. Then right-click -> Team -> Share Project... on the parent project.

.launch files in maven or gradle

What is the "correct"/better place to put eclipse's .launch files in a maven/gradle project? I want to commit my run configurations but I don't know where to put the files
I know maven and gradle are always about standarization so I rather ask than put them in a random folder and then get in trouble with some plugin
After creating a launcher on each maven module now I have each launcher appearing twice in eclipse. This is due to the fact that when I check out my multi-module project it creates an eclipse project for the top POM as well as for each child POM and all the files are "duplicated" in the Navigator view, once for the top and once for each module. This to me means that either I have some problem in my maven organization or that I am putting the launcher in the wrong place
Edit
Since I asked this question I learned of a new way to solve this. Enable an experimental feature in eclipse which will prevent the subprojects to appear in the top project. The setting is under windows/preferences/maven/Hide folders of physically nested modules
The standard location in Eclipse is in the project's root directory, that's where I always save them (and commit to SVN). Maven will ignore them there by default, so they will not show up in your artifacts.
One additional thing to keep in mind (since you mentioned that you want to commit the launch configurations to SCM and possibly share them with others): Avoid absolute paths in the launch configurations, since they will probably not work for other people. Try to use relative paths or Eclipse variables pointing to your local resources.
Edit: moved comment that answers the question
In this case you might consider moving them to a sub-directory (launch?). It should be one that is ignored by Maven by default (so not src/main/java or src/main/resources. On the other hand, I'm not sure whether Eclipse will pick up the files from a sub-directory... I've always kept them in the project root.

Eclipse treating all the files in a project as Derived

I have created a Dynamic Web Project in my Eclipse workspace. It is also a Maven project, and under SVN control. But in "Open Resource" (Ctrl+Alt+R) no file from this project appears, unless I check from the window's options (top right drop-down) "Show Derived Resources".
I have checked on some of the project's folders and they are not marked as "Derived".
I have two more (plain Java) projects in the workspace, and all the files from them are visible in "Open Resource".
Do you know what might be wrong with either Eclipse, the Maven plugin or Subclipse (the SVN plugin)?
I experienced a similar issue in Eclipse (Ganymede), when using the Maven and Subclipse plugins. I have not determined which plugin caused this problem, but I suspect that it is related to my pom.xml containing nested modules (ie. a <modules><module>main-module</module><module>integration-test</module>). These appear in Eclipse as nested folders with their own pom.xml files (I did not use the Multiple Projects plugin although I have installed it).
I assume that one of the plug-ins has incorrectly set the derived flag on these folders when I checked out the project by SVN and then updated the MVN dependencies and project settings.
When I right click->properties on the top-level nested module directories I can see the Derived flag is checked. By unchecking the derive flag on the module directories (and checking the derive flag on the target directories within each sub-module instead), it fixed the Open Resource functionality.
As the derived flag is inherited from directories, you may need to check all of your directories in the hierarchy to find the 'culprit'.
If it helps the plug-in authors, my top level module directories contain a hyphen '-' in their names. Maybe that is throwing out one of the plugins.
I think it is the maven plugin:
Jira issue
See also the notes for July 31, 2008 at the New and Noteworthy page for m2eclipse.
Several other nice links deleted because of restrictions of stackoverflow.
In fact, I think that somehow this is eclipse in its own right, as I don't have m2eclipse or using maven for this.
By default, eclipse uses /bin as the target directory. My situation is similar to having maven in the project in that the target directory was changed to lib/classes to accommodate an existing project.
I started seeing issues similar to what is reported here, and while searching for the problem, came across this solution. Eclipse somehow didn't "uncheck" the bin directory as no longer derived, so I ran into the same issues. I tried replicating it, but I couldn't.