Reputation: 155
I'm fairly new to version control and am only aware of the surface knowledge of using external libraries, so forgive me if my problem is that of a beginner.
I'm writing plugins for software that requires the use of an external API in Eclipse, and so, in order to gain access to that API, I "add external jars" to the "java build path" in Eclipse.
I'm going to wager a guess that this isn't the preferred method of accomplishing this. When I push the project to git and then pull it on another machine, I need to manually redefine where the external jar is on that machine.
Is this something I can fix by adding Eclipse specific files to .gitignore
?
If so, which ones? I've never played directly with Maven before, is this something it or a similar service can fix?
Upvotes: 1
Views: 1618
Reputation: 347
To understand the solution, you have to understand what is the purpose of .gitignore and maven.
Why .gitignore? Git is used to track changes made to each files in your project. However there can be other files in your project which do not require tracking.For example, .metadata which is created by eclipse to keep information about workspace settings or preferences. Since you are not going to modify it and also it is not required for your project, this metadata file should be placed in .gitignore list . For more information check .gitignore.
Thus .gitignore does not serve your purpose of linking custom external JAR to your project.
Why Maven? Maven is a build management tool. There are various common problems and activities we face during developing an application.
Maven helps easing this process. Along with that maven helps to build,publish and deploy your project. Maven uses XML file called pom.xml contains the configuration settings for a project build. Generally we define the project dependencies (Ex: dependent jar files for a project), maven plugins to execute and project description /version etc. Here is the link for further reading about maven.
To achieve your requirement you have to provide details about external jars in the pom.xml and push your project along with pom.xml. When you pull the repository in another machine, just run maven commands it will automatically download all the required jars in your local machine.
Upvotes: 2
Reputation: 4329
add this in your .gitignore file
/*.jar
Also, I am just curious, why do you want to use external library and which one ? It would be better for you to configure your project with maven so that dependencies can be centrally configured. If you want to create your enterprise local repository then use one of the existing products (i.e. Artifactory, Nexus) rather than using this way. It's just a suggestion.
Upvotes: 0