0

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?

Fabio Oesch
  • 133
  • 2
  • 9
  • http://stackoverflow.com/questions/12799719/how-to-upload-a-project-to-github – JNL Sep 27 '13 at 13:47
  • 1
    Make it a maven project. Otherwise you dependon the binary form of internal Eclipse workspace files. – Thorbjørn Ravn Andersen Sep 27 '13 at 13:49
  • What is the binary form of workspace files? I worked with exlipse and its .project files looked quite XML. Why converting to maven is better? Why should one stuck to Eclipse entail non-eclipse technology? Might be we should not use Eclipse at all? – Val Sep 27 '13 at 13:56
  • @val as long as the Eclipse files are not 1) dokumented as an API and 2) subtly changes between releases they are for all practical purposes black, binary boxes. Maven is well documented and IDE-agnostic. Eclipse is fine - just don't depend on its internal files. – Thorbjørn Ravn Andersen Sep 27 '13 at 14:05
  • These build guidelines are designed to allow the form of the source files to be appropriate for checking in: http://agiletribe.wordpress.com/2013/07/16/designing-the-build/ if that helps. – AgilePro Sep 27 '13 at 14:10
  • @ThorbjørnRavnAndersen, I remember I had trouble importing this maven project into eclipse. If people need Eclipse, they should learn Eclipse. Learning Maven will not add anything but only overcomplicates the matters. – Val Sep 27 '13 at 14:32
  • Maven is irrelevant... OP - you don't _need_ to learn Maven, but it is recommended to familiarize yourself with build technology sometime – ddavison Sep 27 '13 at 14:53
  • @val if the project accidentally contains Eclipse files, they are intentionally obeyed by m2e. Done right this doesn't happen. Not using a IDE agnostic build format is a technical debt. – Thorbjørn Ravn Andersen Sep 28 '13 at 19:01

2 Answers2

2

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 ;))

ddavison
  • 25,442
  • 12
  • 70
  • 96
0

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.

Nemesis
  • 2,180
  • 1
  • 21
  • 20
  • so you have to manually configure everything? what if you have a team of > 10 people? hell. > 100 – ddavison Sep 27 '13 at 14:17
  • i work with maven project / modules and conf are in special project if needed (weblogic domains etc... ), devs computers are pre-installed with corporate configuration so no manual configuration needed and we are nearly 200 people here. And even if not done what 'manual' conf do you need? plugins? workspaces? VCS urls? I don't see this as an issue as each dev should be able to handle this don't you think? – Nemesis Sep 27 '13 at 14:25
  • .projects and .idea? Are you sure that you are talking eclipse? My version of .Eclipse has .metadata in the `workspace` dir and .project+.classpath in the project folder. You should "cvs" the project files, including those two. This is very useful to set up the environment (e.g. jar files) especially when your project depends on them. – Val Sep 27 '13 at 14:39
  • as said before working with maven removes the need of defining jars as dependences in the project structure (and yes i made a typo on .project folder name my bad). I consider as bad practice nowaday to put those folders in VCS (as puting jars in VCS seems bad too ...). project conf can be generated with mvn eclipse:eclipse command by the way. – Nemesis Sep 27 '13 at 14:58