Gradle compatible Maven repository or alternative for local usage - maven

The situation:
We have several apps, which use a library developed by ourselves. All app projects as well as the library are under constant development.
Our goal is to have a local maven repository, which allows us to always build the apps with the latest library version, like all those dependencies listet in the Android-Studio dependency chooser here
We donĀ“t want to use the central maven repository, as it makes our code public.
Is there any chance to have a lokal maven repository which is going to be fully compatible with Android Studio and Gradle or is there any other (easy) alternative?

Yes, you can use a local Maven repository manager, which will let you maintain a set of private artifacts for your organization. There's some documentation here: http://maven.apache.org/repository-management.html but the brief explanation is that you can set up a repository that's similar to Maven Central except it's private. There are various repository manager software packages, including Apache Archiva, Artifactory, and Sonatype Nexus.

Related

Bintray, JCenter, Maven, MavenCentral, OSSRH, Sonatype, Nexus, how are they all related?

I have a library shared in JCenter, which I post to through Bintray.
Recently, it is announced JCenter and Bintray are sunsetting, and many advised us to go to MavenCentral. I'm looking to move migrate it over.
Then I notice within the Bintray, it is stated my library is on Maven too, and the user can get my library using
maven {
url "https://dl.bintray.com/elye-project/maven"
}
So I'm confused, does that means I am already in Maven? Is this is just another name for JCenter and will not be available as well?
As I read more, I found an article stating we can publish our library from Bintray to MavenCentral too.
I also read if I need to submit my library to MavenCentral, I need to first create an issue in Sonatype.
Then I saw Sonatype is actually having Nexus Repository Manager. Then I find OSSRH uses Nexus Repository Manager.
I am super confused about what these terms are, and how are they related?
Bintray, JCenter, Maven, MavenCentral, OSSRH, Sonatype, Nexus.
Can someone give a brief description about them, and help to connect the dot for me?
MavenCentral is the place where Java open source artifacts should be published
JCenter was such a place.
Maven is a build system, not a repository. Many repositories have Maven format, which makes them readable from Maven and Gradle.
Sonatype Nexus and JFrog Artifactory are repository managers. You can install them to manage internal and external artifacts on your own server, which is advisable inside a company.

simple local repository manager tool for maven

I am using maven to build java projects. I find difficulty in managing artifacts of maven local repository. so, i need a simple tool for managing local repositories of maven.
I seen the apache-archiva and nexus , but those and big tools.
I also searched the internet but i seen only central repository manager tool. I can't find a tool for managing local repository.
I need to know about the artifacts in my local maven reporitory. I don't want to check each folder of my local repository to see what artifacts are installed.
so, please someone tell me about the tools to manage maven local repository.
As far as I know, there are no tools to manage the local repository.
The local repository is more or less just a cache.
Inside a company, you usually set up a Nexus or Artifactory server to manage external and internal artifacts.

Publishing OSS library release to jcenter and maven-central

I'd like to publish my OSS library to be available in both jcenter and maven-central repositories. I have 2 questions related with this topic:
Should I publish by my own to both repositories, or there is some automated sync between them, so will be enough to publish only to one of them? If there is a sync, which one is the primary source and which when is mirrored?
I'd like to perform publish automatically from gradle, using some gradle plugin. Is there any single plugin, being able to work with both repositories?
JCenter is a super-set of Maven-Central and it syncs automatically with the package published to Maven-Central, so essentially artifacts published to Maven-Central will be automatically synced and available in JCenter as well.
Gradle has two plugins supporting publishing to several repositories types, including Maven-Central and JCenter: (1) A "legacy" maven plugin and (2) a new incubating maven-publish plugin.
For sure you need to publish to only one, and another one should pick it up from there. The question is which one to select?
Although #amnon-shochot's solution works, I'd suggest much easier solution: doing it vice-versa and going with Bintray as a main distribution platform.
Publishing to Bintray is much easier than publishing to Maven Central, and Bintray supports a very easy way to sync whatever you published to Bintray's JCenter to Maven Central.
Also, most of Gradle users already prefer jcenter() over mavenCentral() cause it's faster, more reliable, gives you much more as a publisher and more secure.
You can publish to Bintray from Gradle using Bintray Gradle plugin, which support verity of methods to specify what should be published (configurations, publications, filesets, etc.)
I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links.

github and maven for java collaboration

New maven and relatively new to java...
I would like to collaborate on a project in java with fellow classmates. I would like to manage the build with maven and software configuration with github. After reading a bit about it I have the following impression:
Using the two together is simply a matter of pointing a github repository at my local maven project folder. All builds and dependencies will be handled locally with source changes being committed per the strictures of github. The situation becomes more complicated if I wish for github to do something other than configuration, such as hosting the project as a maven repository.
Is my understanding of the situation correct?
You are best advised to only use github for managing source code. Consider installing a dedicated repository manager like one of the following for sharing binaries:
Nexus
Aritfactory
Archiva
A repository manager is also useful for caching artifacts downloaded from 3rd party repositories like Maven Central. I find it an essential component of my ALM infrastructure.
Update
There was a recent Sonatype blog posting called "Wait... You don't have a repository manager?" which gives some explanation as to why people won't use a repository manager.

How to enable inside glassfish access to maven repository?

I have a following problem. We have a central maven repository hosted on our company server. Our team is working on a project. Everyone here uses that repository to get the required artifacts. If something is missing at the moment and is required for the task that the developer is currently dealing with, he installs this artifact manually to the central repository, so that his commits don't break the automated builds.
Now, each developer also has Glassfish v2 installed on his machine. That is for testing and debugging purposes. Before committing the changes, developer makes the .ear for the project with Maven help. However, after the developer deploys the ear to it's local glassfish, frequent errors arise, because the set of glassfish libraries may not contain all the latest dependencies of the central company repository.
Right now in case of the error the developer simply reads the log and looks what exactly is missing. After that he manually copies the required jar inside his local $GLASSFISH_HOME$/lib dir. But that seems a little bit frustrating. How can this be done automatically?
Right now we are trying to implement the following solution. The developer has to synchronize his local maven repository gathering all the artifacts from the central one that are required by the project. This local repository has to be placed on the java classpath, so that glassfish would also see it. Is that a correct approach? Maybe there is a way to install directly all the required artifacts from the central repository inside $GLASSFISH_HOME$/dir and this can be done automatically during deploy?
About having to install dependencies. If the developers need to install dependencies missing from public maven repositories, take into account that usually maven proxies have the ability to cache public repos. For instance, archiva has a proxying cache. If the dependencies are your own project deliverables you should consider releasing and deploying with maven to your company repo.
About latest versions. You need to specify maven what version of dependencies should use. I would prefer editing my poms manually, anyway there's a variety of ways to achieve that.
The libraries should be part of the project, I think. If not standard libraries of glassfish, they should be included, for instance, in your war file as part of your project. If not standard but not part of your project (not the regular approach) consider managing this glassfish as a project on its own (own git/svn repo, own pom, own versions, own everything).
Good luck.

Resources