Publishing OSS library release to jcenter and maven-central - gradle

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.

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.

What are the exact artifact coordinates for the JaCoCo Gradle plugin

I'm in a corporate environment where an artifact repository manager is, unfortunately, still an utopian concept and is currently not possible to on-board to for many projects. This being said, you can probably imagine the amount complexity involved in on-boarding external artifacts. (I'm very familiar with artifact repository managers and how to use them and I'm even the project owner of an OSS one, so need to give me the lecture on archiva, artifactory, sonatype-nexus, strongbox and the likes. I get it, but it's not up to me).
Could somebody please tell me what the exact (Maven) artifact coordinates and/or URL are for the Gradle JaCoCo plugin, so that it could be manually downloaded and approved internally?
The Gradle documentation only defines it as:
plugins {
id 'jacoco'
}
So I'm not quite sure what this maps to as artifact coordinates, in order to look it up on Maven Central, or Bintray.
It's bundled with gradle. So it doesn't have any GAV, because it doesn't exist as a standalone plugin. You won't find it in the Maven repository, because it's part of gradle itself.
Here's its documentation for gradle 4.2: https://docs.gradle.org/4.2/userguide/jacoco_plugin.html and for gradle 4.10: https://docs.gradle.org/4.10/userguide/jacoco_plugin.html.
You should really upgrade. 4.2 and 4.10 are quite old versions.

How to get an artifact in Maven Central show up in JCenter

I have published a small library to Maven Central (it can be downloaded via web UI here). This was done more than a full day ago.
My understanding is that JCenter mirrors Maven Central, but for some reason I cannot find my artifact in JCenter both via web interface and as part of Maven build.
Do I need to take some action to make it appear in JCenter too?
Basically, if you want to make sure that your library will exist in JCenter, you can upload your library to Bintray under Maven repository, and request to add it to JCenter.
Bintray can also save you the trouble of uploading your library to Maven Central, and do it for you.
Enjoy
Two weeks later the artifact is now visible in JCenter. Apparently it just takes some time to appear there.

How can I sync my maven artifacts to jcenter?

I have deploy my fist version to the maven central repository. Now I want sync this to JCenter / Bintray. Is this possible and how can I do this?
Yes, all you need to do is just download your artifacts from JCenter.
On a related note, I'd suggest doing it the other way around - publish to JCenter and sync to Central. It should be easier for you.
I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links.

Gradle compatible Maven repository or alternative for local usage

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.

Resources