Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload maven pom.xml to Git repository?

I want to publish my Java project on GitHub. I'm not sure if I should upload my pom.xml from Maven in my repository.

I'm using Eclipse without eGit.

On the one hand:

  • the pom.xml is necessary to know which libraries I used.

On the other hand:

  • it's a configuration file which maybe shouldn't made public.
  • it destroys the look of a clean repo, because it's outside of the normal source files.

What should I do best?

like image 712
Ernst Robert Avatar asked Nov 06 '15 20:11

Ernst Robert


People also ask

How do I push a Maven project to GitHub?

Push Artifact to GitHub Using site-maven-plugin Now, we'll execute the mvn deploy command to upload the artifact to GitHub. The main branch will automatically be created if not present. After a successful build, check the repo on GitHub in the browser and under the main branch.

What is POM XML in git?

It is a source file in the sense that Maven only requirement is exactly the presence of this file. It describes how to build your application and declares all of its dependencies. To say it differently: this file is a Maven source file, and as such, should be commited along with the project main source files.

How do I upload a project directly to GitHub?

On GitHub.com, navigate to the main page of the repository. Above the list of files, using the Add file drop-down, click Upload files. Drag and drop the file or folder you'd like to upload to your repository onto the file tree.


1 Answers

  • it's a configuration file which maybe shouldn't made public.

This is wrong. The POM is indeed a configuration file but it is intended for this file to be public. Actually, quoting Maven guide to uploading artifacts to the Central Repository:

Some folks have asked why do we require all this information in the POM for deployed artifacts so here's a small explanation. The POM being deployed with the artifact is part of the process to make transitive dependencies a reality in Maven. The logic for getting transitive dependencies working is really not that hard, the problem is getting the data. The other applications that are made possible by having all the POMs available for artifacts are vast, so by placing them into the repository as part of the process we open up the doors to new ideas that involve unified access to project POMs.

As you see, this file is actually required so that the artifact can be uploaded to Maven Central.

What should not be public is your settings, i.e. the settings.xml file. It is in this file that you should store any sensitive information, like passwords. Again, quoting the Settings Reference (emphasis mine):

The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information.

If you currently store any sensitive information in your POM, you should consider refactoring it to extract this info and put it inside your settings instead.


  • it destroys the look of a clean repo, because it's outside of the normal source files.

It is a source file in the sense that Maven only requirement is exactly the presence of this file. It describes how to build your application and declares all of its dependencies. To say it differently: this file is a Maven source file, and as such, should be commited along with the project main source files. Without it, no-one can build your application and no-one can also package it.

like image 120
Tunaki Avatar answered Sep 24 '22 13:09

Tunaki