In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use OSSRH in the central warehouse of maven". The content in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn how to use OSSRH in the central warehouse of maven.
Why use the central warehouse?
We can use this link to find the jar packages we need, and these jar packages are released by various open source organizations.
The central repository is Apache Maven, the default repository for SBT. At the same time, it can also support the use of Apache Ant/Ivy, Gradle and other build tools.
Now the software world is open source software, more and more people and enterprises are willing to contribute their code on the network, so there is a central repository of the maven community, which makes it convenient for anyone to share and use jar packages.
Preparation before release to the central warehouse
Publishing to the central repository requires permission, and we need to register our project, which is artifacts id, and specify where we need to publish the project.
Sonatype provides a tool called Open Source Software Repository hosting Open Source Software Repository Hosting (OSSRH) to help us easily publish projects to a central repository. It is the main way for project owners and contributors to publish their components to a central repository.
We need to select a domain you own as the groupId. For GitHub groupId (io.github.username), as long as your project URL matches the requested groupId, it will be verified immediately.
For other domain names, you can verify the domain name in one of the following two ways:
Verify with TXT file: create a TXT file that represents OSSRH ticket number under the domain name to verify. GitHub Redirect: sets the redirection of your domain name to the GitHub URL of the managed project.
Use OSSRH
Sonatype OSSRH (OSS repository hosting) uses the Sonatype Nexus repository manager to provide repository hosting services for open source project binaries. OSSRH uses the Maven repository format, and we can deploy the development version of the binaries snapshots, release the binaries in phases, and upgrade the binaries and synchronize them to the central repository.
Create a ticket using Sonatype
Sonatype uses JIRA to manage creation requests, so we need to first create a JIRA account, create an account address: https://issues.sonatype.org/secure/Signup!default.jspa, and then use that account to create a Project ticket and a ticket address: https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134.
Generally speaking, the audit will be conducted within 2 working days.
Component requirements in the central warehouse
Unlike our own private warehouse, there are certain requirements for the format of the components in the central warehouse. We need to follow its format specification.
Provide Javadoc and source code
In addition to the pom file, you also need to provide the javadoc file and the source code file. The purpose is to facilitate direct access and use in IDE.
The naming of these files follows the naming convention of the Maven repository format, using artifactId plus version as the file name, and javadoc or sources as the name based on the type, ending with jar, such as:
Com.example.applicationsexample-application1.4.7
The corresponding javadoc file and source code file are as follows:
Example-application-1.4.7-sources.jarexample-application-1.4.7-javadoc.jar
If you do not have javadoc and source code files, such as the Scala project, you need to create a fake file to pass validation.
Use GPG/PGP to sign files
All files need to be signed with GPG/PGP to generate a file with the .asc suffix, such as the following file:
Example-application-1.4.7.pomexample-application-1.4.7.jarexample-application-1.4.7-sources.jarexample-application-1.4.7-javadoc.jar
Need to generate:
Example-application-1.4.7.pom.ascexample-application-1.4.7.jar.ascexample-application-1.4.7-sources.jar.ascexample-application-1.4.7-javadoc.jar.ascMetadata file
The Metadata file is the pom file that needs to be submitted. This is the Project Object Model file that Apache Maven uses to define the project and its build. When building with other tools, you must assemble it and make sure it contains the following necessary information.
In addition to the necessary information, it is recommended that you include the correct dependencies for the project so that the build tool can use this information to resolve the transitive dependencies correctly and does not require the user to manage the dependencies manually.
Project coordinate information, also known as GAV. Includes groupId, artifactId, and version, as follows:
Com.example.applicationsexample-application1.4.7
In addition, if the project is not a jar package, you also need to contain packaging information. Valid values include: jar, war, ear, pom, maven-plugin, ejb, rar, par, aar and apklib.
Project name, description and URL information:
Example ApplicationA application used as an example on how to set up pushing its components to the Central Repository. http://www.example.com/example-application
You can also use variables to build the project name:
${project.groupId}: ${project.artifactId}
License information
The Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt
Developer information
Manfred Moser manfred@sonatype.com Sonatype http://www.sonatype.com
SCM information
SCM is the address of your project. If you use svn, you can write:
Scm:svn: http://subversion.example.com/svn/project/trunk/ scm:svn: https://subversion.example.com/svn/project/trunk/ http://subversion.example.com/svn/project/trunk/
If you use a github, you can write:
Scm:git:git://github.com/simpligility/ossrh-demo.git scm:git:ssh://github.com:simpligility/ossrh-demo.git http://github.com/simpligility/ossrh-demo/tree/master deployment
The purpose of deployment is to deploy the generated components to the local repository, there are many tools available, the most common is Apache Maven, other build tools such as Apache ant, Gradle, sbt and so on can easily build the project.
Note that OSSRH has a limit on the upload size of a single file, with a maximum of 1024MB. If you need to upload larger components, you need to contact sonatype.
Upload to the central warehouse
Once deployed locally, it can be uploaded to the central warehouse.
You can use Nexus Staging Maven Plugin or Ant Tasks to upload from the command line. You can also upload it by directly accessing https://oss.sonatype.org/ in the browser.
Once released, the components will be released to the central warehouse within 10 minutes and can be searched from the central warehouse within 2 hours.
Let's take browser publishing as an example to take a look at the specific steps.
First log in to https://oss.sonatype.org/ using the user name and password created by JIRA.
After logging in, you can see the Build Promotion option in the lower left corner. If we select Staging Repositories, we will show the warehouse that is currently in the stage state.
Stage repositories created during deployment will have a name that starts with the project's groupId (remove dots from it) with a dash and a 4-digit number. For example. If your project groupId is com.example.applications, the staging profile name will start with comexampleapplications. The serial number starts at 1000 and increases as the deployment increases, such as comexampleapplication-1010.
Select the staging repository, and the panel below the list will display more details about the repository. In addition, you can click the Close and Release buttons.
After deployment, the status will change to Open, and clicking close will trigger the verification of the component. If the verification is successful, you can click the release button to deploy it to the central repository. If you choose to deploy using the Nexus Staging Maven plug-in or the Ant task, you can do it directly on the command line.
Thank you for reading, the above is the content of "how to use OSSRH in the central warehouse of maven". After the study of this article, I believe you have a deeper understanding of how to use OSSRH in the central warehouse of maven, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.