1

I would like to keep a project close to the clean/approved maven process. I have an active PR for a performance improvement against one of the dependencies that I would like to include.

What is the cleanest/ most approved maven way to reference the code from the PR?

Some thoughts that came to mind:

  • Does maven have a means to reference a PR directly?
  • Or maybe a local patch instead?
WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560

2 Answers2

1

Maven dependencies do not comprise source code but artifacts created by builds. See Maven: The Complete Reference, 3.4. Project Dependencies:

Maven can manage both internal and external dependencies. An external dependency for a Java project might be a library such as Plexus, the Spring Framework, or Log4J. An internal dependency is illustrated by a web application project depending on another project that contains service classes, model objects, or persistence logic.

Hence, a local "patch", i.e. using a local -SNAPSHOT version of a local Maven build of the dependency is one possibility.

UPDATE

Another one is Performing a Snapshot Deployment to Sonatype's snapshots repository. (Thanks to khmarbaise for the hint!)

Community
  • 1
  • 1
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • The intention is to provide a shrink-wrapped deliverable to a client. The local snapshot would not be available to consumers of this project besides myself. – WestCoastProjects Aug 02 '15 at 21:30
  • @javadba If you just `mvn install` it resides just in your local repository (Default: `${user.home}/.m2/repository`). If you `mvn deploy` to a [remote repository used as _Internal Repository_](https://maven.apache.org/guides/introduction/introduction-to-repositories.html#Internal_Repositories) it's available for others, too. – Gerold Broser Aug 02 '15 at 21:37
  • We do not have a common/shared "internal" repository with the client - so it would not seem to be a workable solution. What both sides may access : the patched fork of the github repo containing the performance fixes. Is there a way to reference that fork from maven? – WestCoastProjects Aug 02 '15 at 21:38
  • @javadba Re _"shrink-wrapped deliverable"_: Are you aware of the [Maven Assembly Plugin](https://maven.apache.org/plugins/maven-assembly-plugin/)? – Gerold Broser Aug 02 '15 at 21:40
  • What would be residence/location of the source of the code used by the assembly plugin to create the final uber-jar? The client needs to be able to build the uber jar on their site - which requires that the performance patch be incorporated on their site as well. – WestCoastProjects Aug 02 '15 at 21:44
  • @javadba The client has to clone the patched fork repository and build the dependency artifact locally. Then it can be assembled in the uber-jar, together with the other project artifacts. – Gerold Broser Aug 02 '15 at 21:53
  • Yes that is *possible* but not preferred: requires manual steps by the client that would be better not to require. I did find out there is a way to host our own repo via github. http://stackoverflow.com/questions/14013644/hosting-a-maven-repository-on-github. – WestCoastProjects Aug 02 '15 at 21:56
  • What about deploy it to Maven Central or Bintray? – khmarbaise Aug 03 '15 at 16:55
  • @khmarbaise You're right. I've never used Central for SNAPSHOTs but it's possible [Performing a Snapshot Deployment](http://central.sonatype.org/pages/apache-maven.html#performing-a-snapshot-deployment). I'm going to update my answer accordingly. – Gerold Broser Aug 03 '15 at 17:04
  • I have upvoted this answer as having provided some useful options. But the most direct answer is to use jitpack - and I provided that answer separately. – WestCoastProjects Nov 21 '15 at 20:43
1

My solution ended up being using jitpack, https://jitpack.io/

as described in an answer on this SOF:

Can I use a GitHub project directly in Maven?

Add repository first
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
Add dependency
<dependency>
    <groupId>com.github.User</groupId>
    <artifactId>Repo name</artifactId>
    <version>Release tag</version>
</dependency>
Community
  • 1
  • 1
WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560