Maven Central Repository Artifact Source Code / Project URL / License Identification - maven

I'm new to working with Java and have questions regarding the Maven Central Repository. I am much more familiar with Python and PyPI, so I will provide the equivalent in PyPI that I would like to find in Maven.
How can I find the source code for the artifacts in Maven Central? Typically, I see the JAR file and prefer not to decompile these files. Typically, PyPI packages have the source file type in the "Download files" tab.
How can I find the associated project URL to a maven artifact? In PyPI, the package page has a set of project links and generally provides a repository link (e.g., Github, Bitbucket)
How can I identify open-source projects in the Maven central repository? The license for PyPI projects is tagged directly in the meta-reference on the sidebar of a project page.
I appreciate any insight into these questions. Thanks!

When a distributor decides to provide them, you can find -sources.jar and a -javadoc.jar files in the artifacts folder. (common IDE's are aware of that&provide buttons/menus, "Maven>Download XXX";)
like e.g. here
Artifact javadoc (for the sophisticated ones, javadoc and sources refers to the (common) "classifier" of the artifact)
how (easy) to produce them
In the pom:
project.url tag provides:
The project's home page.
project.scm element provides (should provide!) "source control" related (multiple) urls (read-only, contributer, public-browsing).
besides that many other things(and sub-things) can have url in a maven project/pom (distributionManagement(i.e repository), organisation, developer,...).
project.licenses element!
You can be sure to find all of these three (- four) in all (at least latest) artifacts in maven central, due to:
Their Publishing Requirements!;

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.

bintray - publishing multi-module Gradle artifacts to JCenter

my project is organized as a Gradle multi-project build with five Java modules/sub-projects. When building them, it results in five different JAR artifacts.
Four of those artifacts contain helper classes or small, isolated portions of code doing very specific things (for example efficient graph search that is optimised towards my specific use case domain). Only one project is the "main" artifiact that makes sense to use in a standalone way, but all five artifacts are required for it to run.
I would like to make this core artifact available to users, and I have been successful in uploading all five artifacts to a Bintray account. When mirroring to JCenter, I have two concerns:
Do I have to actively link all 5 projects to JCenter, or is there a way to only expose the "core" artifact to the general public?
What does the "Is Pom Project" checkbox do? As I understand it, Gradle creates POM files for every Maven publication artifact, so this box should always be checked for Maven-style builds. Is this correct?
(potential duplicate that does not contain a solution apart from "I work at Bintray and I fixed it for you in our system!": Linking Bintray Package to JCenter)
Thanks!
- Gregor
I hope I can answer all.
Do I have to actively link all 5 projects to JCenter, or is there a way to only expose the "core" artifact to the general public?
As the other answer you have attached says, it is linked on path level, this means that if you include org/worldcubeassociation/tnoodle/lib-scrambles/ as the path, then only those modules will be linked to Jcenter.
What does the "Is Pom Project" checkbox do? As I understand it, Gradle creates POM files for every Maven publication artifact, so this box should always be checked for Maven-style builds. Is this correct?
Yes, you are correct. The POM file is created and uploaded. You can see the POM file in your path.
For more information you can always check the central repositories guide.

Maven Central is which exactly repository?

Are https://mvnrepository.com/repos/central and http://central.maven.org/maven2/ the same maven repository (called Maven Central)?
Also there is https://repo.maven.apache.org/maven2/ which also calles itself a Central Repository.
I use mvnrepository.com as I find it more convenient, but many referencies to Maven Central in Internet lead to http://central.maven.org
Besides both sites above are for Maven2, right?
What are the analogues for Maven3?
Besides is Maven3 widely used?
As far as I know, mvnrepository is just a search site that is not maintained by the maven people directly. It's a search site as I see it. It has been around for a while. Since it contains multiple repository source to search in and lets you select which one you work with its pretty transparent and I don't see any harm there.
If you execute mvn help:effective-settings you should be able to determine what repositories are used, in case some changes where made. The current central default in maven seems to be https://repo.maven.apache.org/maven2/ - the official search interface being https://search.maven.org/
You can also look into the maven sources of the pom what config you running on.
The /maven2/ part in the Uri only means what repository format is used within. This has not changed for maven 3 (it was different for maven 1). So it's the correct and current one today, there is no maven 3 repository format. Everything new could be added to the maven 2 format (for example some search index files or checksum files).

What should be stored in a maven repository?

Should I store artifacts that are final products, not to be used as a dependency of another project within a maven repository? i.e. EAR, WAR, zip, tar, etc.
I've been unable to find any documents that explicitly state whether this is the proper usage or not but I see that there are EAR/WAR/zip/tar files in Maven Central: http://search.maven.org/#search%7Cga%7C1%7Cp%3A%22war%22
Is anyone aware of any documentation to support either position?

Modern Maven Pom Templates

Every time I make a new proper project using Maven hosted on Github I have to go look at either one of my own old projects and copy the pom file or I go find a project that I think does a good job and copy there POM file. Then I have to go search and replace things like project name... etc.
Now Maven has a solution to this through archetypes but I have yet to see one that is modern enough such that it:
Uses the release plugin and deploys to SonaType Central Maven reop.
Connects to Github (meaning the scm connections and release plugin work do the right thing)
Makes all three jar artifacts (sources, javadoc, and regular jar)
I have contemplated make some giter8 templates but was hoping somebody already did something like this (most of the g8 templates are for sbt).
You can use com.jcabi:parent:pom which does exactly what you need and many more. It deploys to Sonatype, defines common dependencies with versions, pre-configures most popular plugins, and defines a few useful profiles.
This article explains more: Don't Repeat Yourself in Maven POMs; Use Jcabi-Parent
You could have a look at the parent pom released by Sonatype. It's intended to be used as a parent pom for projects that deploy to oss.sonatype.org (which may or may not be promoted to Maven Central).
When the sonatype-oss-release profile is enabled, it will ensure that sources and javadocs are built. It also includes an example of the <scm> pom element.
It turns out its incredible easy to create your own maven archetype.
Just make a generic project with stuff you like to use
In the project directory run mvn archetype:create-from-project
Generally Maven guesses the right things to make variable but if not you just edit the Velocity templates.
Install your archetype locally with mvn install
To use your new archetype: mvn archetype:generate -DarchetypeGroupId=com.mygroup -DarchetypeArtifactId=my-archetype
Now the only caveat is that there is not very good doc on the web that I could find on the archetype system. Like its unclear what variables you have available to you for Velocity (although most of them are obvious).
http://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html

Resources