Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - push java .classpath file?

I have a small java project on which I work together with a friend. We both use eclipse with the egit plugin and github for version management.

Besides the JRE library, we use the javafx and an RXTX library. As we both need the libraries, we put them in a lib folder in our project. Then we set up the .classpath to reference the libraries in our project and pushed the .classpath to github.

At that point, we realized, that different computers need different libraries and that it may be a bad idea to have the .classpath file in the CVS.

So my Question is, what is the best practice here? Having the .classpath file commited seems like a bad idea, however I want to have control over the libraries which are used in the project, therefore It might be a good Idea to provide the library jars with the other project files; someone who pulls the project can then easily add the jar for his system to the classpath. However, consequently I would have to provide the javafx and RXTX library for every system (win32, win64, linux, ...) , and that also does not seem like the best thing to do.

I feel like this may have been asked already, however I could not find a satisfying question/answer for my problem.

like image 975
quantumbyte Avatar asked Mar 01 '14 10:03

quantumbyte


2 Answers

To answer your question "what is the best practice here?":

The binary files (jars) do not belong to source code management. To handle this, developers usually use some build tool with dependecy management which will download the jars from remote repositories. Most popular in Java world are:

Maven - http://maven.apache.org

Gradle - http://www.gradle.org

SBT - http://www.scala-sbt.org/ (primarily for Scala, but works for Java as well)

Ant - http://ant.apache.org

The .classpath file is IDE specific (eclipse) "project" descriptor, the practice might differ from team to team, but the most common is probably to list these files in .gitignore and not to commit them. These files might contain developer specific settings that are not to be shared within a team, or developers might use different IDEs and the repository would get polluted with these files.

like image 171
František Hartman Avatar answered Sep 20 '22 12:09

František Hartman


You could try Maven for organising and installing your dependencies: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

like image 28
indivisible Avatar answered Sep 21 '22 12:09

indivisible