I'm not an experienced programmer and I'm mostly self taught. I never really learned how to manage dependencies and I'm having some trouble finding the information I need, which I think it's pretty basic actually.
I have a GitHub project that has dependencies on my own libraries and also third-party libraries. The way I did it was:
- Downloaded the needed library files from other GitHub projects
- Placed the files in myAppFolder/libraries
- Imported them in my code
Is this the right approach?
Also, now I have the following problem: how do I keep these dependencies up to date? Do I have to manually update every file every time there's a new version of the library? Is there a way to automate this?
I tried using git submodules, but they download every file from the repository (including README.md, docs, tests, examples etc), while I only need the actual library files.
In general... no.
A source control system like Git is made to track changes in source code, not binaries (like libraries).
A library is a binary artifact, which needs to be published ("deploy"/"push") to a repository artifact manager like Nexus or Artifactory.
That enables a declarative approach, where you include in your project only a small text file stating what you need (exact version) and where you need it from.
For instance:
pom.xmlin a Maven project.go.modin a Go projectrequirements.txtin a Python projectYour repository only include text files, and your build tool will fetch for your your dependencies.