I can't figure out an appropriate way to structure git repositories to handle library dependencies between git repositiories.
I have a number of Java projects that rely on another, frequently updated project that's included in them as a .jar library. I now want to migrate them all to github.
Can I set up the projects in github so that whenever I push project A, then all other projects can pull the new version of projectA.jar automagically? They don't rely on any source files, they just need the latest libraray jar. Currently it's done by an ant script that tries to copy the latest jar from the other project at each build.
Changing your project over to Maven may be a big help; .jar files would no longer be stored in version control.
You would need to open project A, run 'mvn install' to produce the library files on your PC, and then you could use project A's libraries from project B.
Another alternative is to run your own Maven artifacts server, such as Artifactory, Nexus, etc... Project B would look at the artifacts server to see if project A's files are available.
Related
Looking for the best option, or a solution I am unaware of:
(probably unnecessary context) I developed "project A", a 1990's RPG video game ported to Java. Currently starting on "project B", a server to co-ordinate project A to run as a MMORPG.
Project A, lives in gitHub, compiles in maven and has no dependencies on project B.
Project B, (will) live in gitHub, has dependencies on "project A", and aspires to compile in maven
I would like both to sit in separate github repositories
I would like project B's pom.xml to specify the version of 'project A' needed.
No preference if this is achieved via specifying a git branch/version or maven artifactId/version.
I would like running maven for project B to find either:
(if available) Project A's last local build of specified version.
(fallback) Projects A's latest version on gitHub
I would prefer not to host project A Jars in some url (or git repo from project A, or B), as they will become large due to graphics. Also that type of thing rubs me the wrong way.
I would like "project B" to "just work" via a 'git clone ...', followed by a 'mvn package'.
There seems to be a multitude of approaches:
via 3rd party: eg jitpack
via maven reactor / modules (with what appear to be several sub approaches)
running 'mvn install' from project A
nexus, artifactory
via git submodules
I would like both to sit in separate github repositories
that's trivial
I would like project B's pom.xml to specify the version of 'project A' needed.
you can use version to distinguish your jars
I would like running maven for project B to find either:
(if available) Project A's last local build of specified version.
(fallback) Projects A's latest version on gitHub
that's maven by design
I would prefer not to host project A Jars in some url (or git repo from project A, or B), as they will become large due to graphics. Also that type of thing rubs me the wrong way.
have you consider to separate resources from core? ie put them in separate project given that they least likely to change
now solution, in my opionion what you need is remote maven repository (by remote i mean opposite to local which will be accessable whenever you want to work on your project. personally i would recommend nexus, but i might be biased here, given that i have most experience with it.
other solution might be maven repository on github. never tried it, but it looks ok
You can
check out both projects on your computer, build project A with version x.y.z and then build B against A with that version. This works through the local Maven repository on your computer.
put both B and A into a multi-module project so that you can build everything at once. This means that both projects have to be in subdirectories of some parent directory.
Use your own Nexus/Artifactory. Then you can mvn deploy B in a version to this repository and resolve it in A through the same one. Works more or less like the local repository, but is much more convenient to use and search in.
Currently, I have a maven project that has a server running (using Jersey REST API). I also have a java project, I need to move all the contents of the java project into the maven project. The maven project is a subset of the java project. However, the maven project only displays the parts of the java project. However, I want a project that allows me to use maven and displays all of the other details from the java project.
I would've copied and pasted however I'm using git so I want to also preserve history.
I was thinking it would be easier to nest the maven project inside the java project but I don't know if that's possible.
Here's a picture of my package explorer to help explain everything.
Package explorer showing the maven project being a subset of the java project.
What I've tried is converting the java project into a maven project and then updating the pom.xml but then it doesn't link to the web.xml. Also, it tries to run the server with the name of the project name TeamProject. When infact it should run the url with the name client_server
I was considering just copying and pasting all the code into the maven project (from the Teamproject java project).
Actually nesting the java project inside the Maven project makes more sense, as it is the purpose of Maven to handle a project lifecycle. (also by default Maven will look for sources in the src/ folder which should ease the task of putting your Java project inside Maven's hands)
There are several possibilities I would see:
Copy your java project in the src/ of your client project and update maven accordingly (within the pom.xml)
Make your Java project a Maven project and aggregate the two projects in a parent pom (see Multi module maven project example)
Make your Java project a Maven project, and decide of a "Master" project between it and the client and compose one with the other (not sure that's a great solution)
Nesting your Maven project inside the Java project would not be so great because Maven could only handle the client and not your Java project, and then you'd miss on numerous functionalities offered by Maven (just look at how simple it is to get dependencies compared to downloading a jar and including it on the build path manually)
I have two gradle projects: the larger system and the smaller pre-existing (our internal code, nontheless) connector library, which I want to use in it. Both have their own git repos on bitbucket, but there's no artifactory to just pull the library as a dependancy. I've tried using git sumbodule, but couldn't get it quite right: I don't want to mix two projects' src folders, but without that I can't import submodule classes. How do I do this using gradle and/or git?
I'm converting an existing Eclipse-based web project to a Maven-managed one.
Since the project has lots of dependencies, many of which are custom (they're either internally made or they've been taken from sources that have no public repository), is there some 'magic' Maven POM setting that will let me load every jar from WebContent/WEB-INF/lib and make the project work as before right now, so that I can configure each dependency and do the necessary refactoring to turn it to a proper Maven project with a little more time and care?
I have already seen this question, but the project must continue to compile inside Eclipse, so - or at least I guess - it is not just a matter of using the Maven war plugin
What you want to do is called "installing" your non-mavenized JARs into your maven repository. This can be a local or remote repo that you host.
The command to install to your local repo is something like this: mvn install:install-file -Dfile=My-lib.jar -DgroupId=com.mycompany -DartifactId=My-lib -Dversion=1.2.3 -Dpackaging=jar
You'll want to review the various options for install to suit your project.
Once the non-mavenized dependencies are installed to your repo you can add them to your pom like any other maven dependency. They will be fetched from your local repo.
You will have to set up your own remote repo (like Artifactory) or install each plugin for every developer and CI server in your environment for others on your team to build the project. I strongly reccomend Artifactory, it makes it easy on your and your team to use maven and get dependencies.
I have a project that devided into three pieces, PCommon, PWebapp and PAdminConsole. PWebapp and PAdminConsole are dynamic web project in eclipse, PCommon is java project, and both two web project will use the api in PCommon as a jar file in lib folder.
In the past,I added import project in build path, I used Ant to compile and build PWebapp and PAdminConsole and in both build.xml file there is
<ant antfile="${common}/../build.xml" inheritAll="false"></ant>
to make PCommon into a jar file.
Now I will change all my projects to Maven Project. But I don't know how to make two web projects contain one public module, and how to package my PCommon into a jar file automaticlly when I run package maven command to package one web project.
Now I always deploy my PCommon.jar on nexus server. and then add dependcy in pom.xml in web projects. But I think there is no sense to deploy the jar on the public server, so I think it isn't the right way to archieve this goal. Is there any way that is more convenient?
I know I can make a parent project with a parent pom.xml. But I have two web project need the module, the pom.xml in PCommon can only extends one parent, can't it?
The common way to resolve dependencies in Maven is using a repository. The first time a dependency is needed, it is downloaded from your repository and installed in the repository on your local machine. If a dependency is not available in the remote repository it has to be installed to your local one in some other way. There are a few other ways to resolve depenencies without using the repositories but I wouldn't suggest to use the.
To make this a little more convenient, you can use a proper IDE. I use Eclipse with the m2e plugin. It supports something called "workspace resolution", which should be enabled by default. It scans your workspace for other Maven projects before falling back to the repository lookup. This has the advantage that every change you make in your common project is immediatly available in the other projects. I think it also gets installed to your local repository in the background but I'm not sure. Anyway you don't have to worry about it yourself.
Something similar works with IntelliJ IDEA but I don't have that much experience with it. I'm sure Netbeans has some kind of Maven support too.