How do i manage workspace.xml in Intellij with git - java

I started a new project with my team. We are using Intellij + Java + git for developing the software.
The problem I have is that I made a .gitignore file for git auto-generated by gitignore.io. The file ignores the workspace.xml and the Project.iml files in my Project, which is good, because they cause merging conflicts later.
The thing is when I push the project on bitbucket.org and my collegues want to clone it so they can work on it, they have no workspace.xml. So Intellij can't open it up as a project.
Is there any way they can generate the missing Files or any Import option to make it a project again?

workspace.xml is not required for opening an IntelliJ IDEA project. On the other hand, the .iml file is a required part of the project and needs to be shared in the version control system if you want to share your project with colleagues.

Related

jar libraries not updated in eclipse with git

I am developing java projects in eclipse and version controlling with git.
What I found today was that the jars of user library was not being updated after pulling a project from git server to another repository/directory. The newly exported jars after adding new classes or functions were not recognized.
So I removed the user library with the problematic jars. The eclipse java project still has access to the jars.
Create a dir.
Git init
Create an empty java project
Pull from git server
The above is the steps that caused this problem. I didnt commit the empty project before pulling.
Thanks~
Have you tried refreshing the project? (Right click on your project and then select Refresh)
Your changes done to the file system (pulling stuff from git) are not known to to Eclipse, so you have to explicitly tell Eclipse that it has to refresh its idea of what are on the file system.

Eclipse not recognizing files from SourceTree

My partner made a BitBucket git repository, and uploaded a Java project from Eclipse via SourceTree. I made my own project in Eclipse on my computer, and using SourceTree I pulled all the files from BitBucket. While these files show in Windows Explorer, they don't show in the Eclipse workspace. Is there a way to continue using SourceTree and Eclipse without using EGit, or is there no solution?
Could be because .classpath and .project files are registered in .gitignore so they didn't get checked in to git (that is right as well)
Your eclipse needs to regenerate those file based on your project type

What is the correct way to have a Java Project with Eclipse on GitHub

I am working on a Java Project with Eclipse which we want to put on GitHub so that it is accessible for the public. But we are not entirly certain what is the correct way to put a Java Project onto GitHub. We have already made a GitHub and uploaded a Java Project. But when checked it out, with EGit, to my computer all the folders are now packages.
Is there any way how this can be avoided? How are you uploading a Java Project to GitHub? Are there any difficulties which we are not aware of right now?
A good example I like to use, is my getting started with selenium project.
This is a Maven enabled Java Project that is hosted on github.
But when checked it out, with EGit, to my computer all the folders are now packages.
This is because of your .classpath. If a source folder is added, (like src/main/java) any subsequent folders will be "packages".
How are you uploading a Java Project to GitHub?
Just as you see in the project above. Upload everything, except binaries, and jar dependencies. (which is why i use Maven)
Are there any difficulties which we are not aware of right now?
Where I work, we use a process in which our projects on github are entire java projects. I've heard that it's bad to upload eclipse specific things like .project, but even individuals who use IntelliJ IDEA, it doesn't seem to be an issue, because they can just upload their .file.
One thing to keep in mind, is your .gitignore. Make sure that /target/classes/* and other java specific compilations are avoided as you want your repo to be only source code. (one thing i DID forget to do on that project above.. will fix ;))
I'd rather not upload .projects or .idea files while uploading projects to VCS system (git or not).
I add these folders to my .gitignore file (wich i upload to VCS)
Regards.

Eclipse setup for git project

There are quite a few questions on this topic, but there are no satisfactory answers unitl now, e.g this.
I'm using Eclipse Kepler (20130529-2219), with ME2 (1.4.0.20130601-0317) and Eclipse Git Team Provider (Java implementation of GIT 3.0.0.201306040240-rc3). So I started with great expectations after reading how great git is.
Firstly, I opened an existing project and removed all the .svn rubbish and commited it to a local git repository. Perfect - now it is time to push the files to a remote repository. After having some problems creating the known_hosts file on Windows the push was successful.
Now the problems started: I wanted to pull changes for the repository, but "... not configured for pull". OK, here it was discussed that this is a common issue, and you have to delete the project and then reimport it from a remote server to allow pulling.
Hence, I set up everything again and pulled the project. Until now I was always told that .project files should not be commit to version control, therefore I didn't include them. The "import -> import from git -> local"-menu does not recognize the files in the repo as a Java project. I can therefore only import the project as a general project or use the project wizzard and set up a new Maven project, which is stupid because all information already exists in the POM.xml. If I do a plain project import, Eclipse does not know that it is a Java or Maven project and throws tonnes of errors.
Question (skip detailed problem): Is there some less awkward way to import a Maven and Java project from a remote git repo when no .project file exists?
Easiest solution: do include the .project (as in this answer) in your git repo.
And do include also the .classpath, since you now can reference relative paths in it, instead of absolute path: see ".classpath and .project - check into version control or not?"
I found an alternative to keep .project file out of Git version control. As you said the pom.xml file should be enough for IDEs to figure out that a maven project it´s in place (and it is).
Let's say you have pushed your project into Git (without .project file) and now you want to import that project into Eclipse.
Make sure you have the Git repo added into Git perspective
Go to J2EE Perspective and double click on an empty space on Navigation View. Import -> Existing Maven Projects
Browse to your Git repo location and voila! Eclipse should catch all pom.xml files and determinate they are independent Maven projects
In my case this worked to pull multiple projects located at one same Git repo, each of them only storing pom.xml file (and no .project at all)

How to correctly version control (svn:ignore) a Java project (Maven, Spring)?

i was on a 2-day training introducing as to Java EE. We used there Java EE, Spring Framework, Maven, Springsource Tool Suite (Eclipse), Tomcat.
I took the Eclipse workspace we created there and run it on my work PC. I had, if i remember correctly, only to configure Tomcat properly, and it worked on my PC.
Now i want to save the created Eclipse workspace containing 5 "sub"-projects in subversion so that my work colleagues can checkout this to them and run it on their computers.
How to do this correctly? I found somewhere a svn:ignore rule:
.classpath
.project
.settings
target
Using tortoiseSVN i added to the folder with the workspace this ignore rule, but the found out that the underlying folders target were'nt deleted so i deleted them manually and "added to ignore list". But after that the project in spring source tool suite does not see the mevan dependencies (i think so) because the imports are broken. STS underlines org. in the imports and says it can not resolve this.
How do i correctly version control such a project?
In my project we are using Maven and Eclipse (Helios, currently) and the Maven plugins for Eclipse:
Maven Integration for Eclipse
Maven Integration for WTP
We only have the pom.xml file and the src/ directory tree in our version control system. We make sure not to add the eclipse files there. Then when a new developer starts in the project they do Import -> Maven -> Existing Maven Projects. The Maven plugins for Eclipse then set up perfect build paths, settings and so on.
This way it is also very easy to re-import your projects into Eclipse as needed.
So, my tip is to leave the Eclipse files out of SVN and make sure you can setup the project correctly automatically simply by importing a Maven project.
If I understand your problem the right way, you need to configure Eclipse in order to be able to launch tomcat from it. The key, here, is not maven anymore, but Eclipse, I think. As you've made modifications in your workspace that can't be put in your maven configuration file (the pom.xml), you become "Eclipse dependant".
The key here is that, as you're Eclipse dependant, you need the Eclipse configuration files to work. Consequently, I'm afraid you need to add back .classpath, .project, .settings to your versioning tool... It's not generic, because you force people who work on your project to use Eclipse. But if everybody in your team do so, it shouldn't be a problem.
As I don't use Eclipse anymore, I don't know if versioning theses files can lead to problems. However, I hope this answer will help you to configure your project back...
EDIT : to be more accurate... and maybe give a better answer.
When using a version control system, the main goal is often (always ?) to give all the keys to use the sources, and develop from them. Consequently, you need to put in your VCS your sources, and all the configurations needed to use them efficiently.
In your specific case, the key is that you've become Eclipse dependant through its Springsource Tool Suite plugin. Consequently, it becomes essential to add the configuration files for this tool, because they can't work without them, and if they can't work, you can't work.
I can tell you my way of subversioning maven eclipse projects. First, when you create the project structure you have to commit the .setting, .classpath, .project files into the subversion repository. If you can't do this the other colleagues will can not use the project structure after checkout. After you commit the project structure, the best way is not to commit these files except only when you change something important eclipse or build path settings, because the others will have conflicts due to the system dependent informations. Never commit the maven target directory. Sorry for my english. Hope it helps.

Categories