Location>code7788 >text

How to submit java private library (jar) to the public service/public repository (central repository) - manual version

Popularity:390 ℃/2024-12-16 22:46:30

How to submit java private library (jar) to the public service/public repository (central repository) - manual version

Reproduced with attribution/funnyzpc/p/18610692

intend

  • GunPG(for asc signatures)
  • Project code (recommendedmavenstructural)
  • sonatypeAccount (/api/auth/login)
  • Maven Helper(IdeaPlug-ins.mavenCommand Shortcut Plugin)
  • githubmaybegiteeAccount (for registration)sonatype(used form a nominal expression)Namespace)

Register sonatype->Namespace

Registration is complete, tap to enterView Namespaces :

point (in space or time)Add namespace If yourgithubThe home page is/funnyzpc If this is the case, then this is the , as shown:

The validation is done according to the generatedVerification Key Create a file under your own github account corresponding to theVerification Key (used form a nominal expression)repository As the chart suggests.

create a good idearepository Remember to click on it afterward.sonatype backstageVerify Namespace must wait for the state to beVerified Only when available!

Key Generation

  • generating
    Use the command:gpg --generate-key
    Then enter the nameReal name and emailEmail address Remember to entero besave (a file etc) (computing)The general inputoAfter that, a password dialog box will pop up, enter a custom password to ~.This password is to be used subsequently!

Suggestion: Name suggestion is related togithubthat the name of the main account is the same as the name of theemailAs well, email needs to be linked to a subsequent project in the (pom(Documentation) in thedevelopers Consistency of label definitions ~

  • Public Key Upload

    • First use the command to view the public keygpg --list-keys:

    • It can be seen above a long list ofpubThat is, the public key to be used for the upload:

    • Execute the upload command

      gpg --keyserver --send-keys [public key]
      gpg --keyserver --send-keys [public key]
      gpg --keyserver --send-keys [public key]
      
    • keyserver There are generally three, see specificallysonatype The official guide suggests that eachserverUpload them all.
      Specifics can be found in:/publish/requirements/gpg/#dealing-with-expired-keys

    It should be noted that this link is only prepared for file signing, and is not directly related to the other, subsequent uploads of theascThe signature file issonatypeThe backend is used to do two-way file authentication from the public key server.

Project Capital Improvement

  • increaseplugin

    • If it is a multi-module project, it is recommended that the module that needs to be uploaded to the public service be added to thepomconfiguration, the specific need to add thepluginFor.
          <plugin>
              <groupId></groupId>
              <artifactId>maven-javadoc-plugin</artifactId>
              <configuration>
                  <additionalOptions>
                      <!-- construct (sth abstract)docIgnore errors in the code whendocWriting Configuration -->
                      <additionalOption>-Xdoclint:none</additionalOption>
                  </additionalOptions>
              </configuration>
              <executions>
                  <execution>
                      <id>attach-javadocs</id>
                      <goals>
                          <goal>jar</goal>
                      </goals>
                  </execution>
              </executions>
          </plugin>
          <plugin>
              <groupId></groupId>
              <artifactId>maven-gpg-plugin</artifactId>
              <version>1.6</version>
              <executions>
                  <execution>
                      <id>sign-artifacts</id>
                      <phase>verify</phase>
                      <goals>
                          <goal>sign</goal>
                      </goals>
                  </execution>
              </executions>
          </plugin>

Remember that it is necessary to configuremaven-javadoc-plugin Otherwise, follow-upgpg Packaging signatures are not generated whenjavadoc ♪ It's a pit ♪

parameters-Xdoclint:none It's to ignorejavadocdefined by throwing an error! , the above code has the famous ~

  • libraries (jar files) to add the central repository (sonatype) There are also some necessary configurations which are required:descriptionurlscmlicensesdevelopers , SpecificxmlThe definition position is the same as theproperties as well asdependencies is at the same level
 <description>A Simplified Excel Operating Library,use POI library.</description>
    <url>/funnyzpc/mee-excel</url>
    <scm>
        <connection>scm:git:git@:funnyzpc/</connection>
        <developerConnection>scm:git:git@:funnyzpc/</developerConnection>
        <tag/>
        <url>/funnyzpc/mee-excel</url>
    </scm>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>/licenses/LICENSE-2.</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <developers>
        <developer>
            <name>funnyzpc</name>
            <email>funnyzpc@</email>
            <timezone>+8</timezone>
            <url>/funnyzpc</url>
        </developer>
    </developers>

Note that the parameters need to be configured according to their own needs, if the above is still missing something, please be specific to theSubsequent uploads You can change the error message to

When the above changes are complete, remember to add themavensmall windowreloadHere's what I'm talking about.

base package (computing)

The three subsequent signatures are all based on these four packages for signatures, and we use the mostmee-excel This library is a reference:/maven2/io/github/funnyzpc/mee-excel/1.0.0/

You can see that the signature has these four packages as signature objects.

  • [artifactId]-[version]- (Documentation)
  • [artifactId]-[version]- (source code)
  • [artifactId]-[version].jar (source code package)
  • [artifactId]-[version].pom (engineering pom)

When we have guessed what is needed to upload the public repository, we now start generating the correspondingascmd5sha1 Signature~

  • Using Commandsmvn package gpg:sign -=true Generate basic packages as well asasc signature file

take note of

  • For multiple modules you need to add command items-pl [module name] Implementation, complete.mvn package gpg:sign -=true -pl [module name]
  • Also note thatgpg:sign The command line must contain thepackage directive in the ideamavenThe small window will not succeed in direct execution!
  • Execution generally results in a pop-upPassword input boxThe input is the key generation linkPassword set

Well, execution success looks roughly like this, with mymee-excel The project is an example:

If you use theMaven Helper plugin then right-click on the specified module and selectpackage gpg:sign -=true Command execution (self-configuration required)Maven helper (not available until after).

  • Build with commandsmd5sha1signature file
    • utilizationwindows cmd command buildmd5sha1signature file (first)cdTo the correspondingtargetCatalog)
    certUtil -hashfile mee-excel-1.0. md5 >> mee-excel-1.0..md5
    certUtil -hashfile mee-excel-1.0. sha1 >> mee-excel-1.0..sha1
    
    certUtil -hashfile mee-excel-1.0. md5 >> mee-excel-1.0..md5
    certUtil -hashfile mee-excel-1.0. sha1 >> mee-excel-1.0..sha1
    
    certUtil -hashfile mee-excel-1.0. md5 >> mee-excel-1.0..md5
    certUtil -hashfile mee-excel-1.0. sha1 >> mee-excel-1.0..sha1
    
    certUtil -hashfile mee-excel-1.0. md5 >> mee-excel-1.0..md5
    certUtil -hashfile mee-excel-1.0. sha1 >> mee-excel-1.0..sha1
    
  • utilizationbashCommand Modificationmd5sha1Documentation, mainly to eliminate useless content

    • existtagetdirectory (in File Manager) right-click and select theGit Bash here orcmdSwitching within the window to thebash: Directbash+ enter (computer key) Ready to go:

    • Execute command.

     sed -i '1d;3d' mee-excel-1.0..md5
     sed -i '1d;3d' mee-excel-1.0..md5
     sed -i '1d;3d' mee-excel-1.0..md5
     sed -i '1d;3d' mee-excel-1.0..md5
    
     sed -i '1d;3d' mee-excel-1.0..sha1
     sed -i '1d;3d' mee-excel-1.0..sha1
     sed -i '1d;3d' mee-excel-1.0..sha1
     sed -i '1d;3d' mee-excel-1.0..sha1
    
    

ok, now the general structure is as follows.

Constructing the target structure

The previous step of the operation must check whether the generated signature file is empty, especially the first operation, and then we think about what kind of package needs to be uploaded above the public service

firstlymee-excel For example, here is the address of the library:/maven2/io/github/funnyzpc/mee-excel/1.0.0/

  • io/github/funnyzpc It's us.sonatype The backend configuration of theNamespace The following are some of the most important features of a module or a project.pomhit the nail on the headgroupId !
  • mee-excel is the module or projectartifactId (pominside)
  • 1.0.0 bepomThe version configured in theversion), with special attention to the fact that the version must not be or contain theSNAPSHOT

Okay, so we'll construct the local folder according to the above directory structure, placing this16 classifier for individual things or people, general, catch-all classifierfilePut it in and leave the rest!

Also see the records I have already uploaded:

For official documentation, see./publish/publish-portal-upload/

Submit for review

Before submitting, package the entire folder of prepared files as azipand in accordance withio directory for packaging, the normal packaged file package should be

  • point (in space or time)sonatype Under Account in the upper right corner of the backendview Deployments
  • Tap the upper right cornerPublish Component
  • Deployment Name It's usually possible to write one at random, and the advice is topomhit the nail on the head[artifactId]-[version] (eg:mee-excel-1.0.0)
  • Description freely
  • Upload Your File Select the compressedzippackage, and then tapPublish Component can immediately (do sth)

Follow-up Audit

Note the review status, the default submission isPENDING Status , Approved YesVALIDATED status, be sure to pay attention to theVALIDATED Not the final state! Be sure to order it.Publish The final state of the release will be after.PUBLISHED !

If it isFAILED status, be sure to refer to the validation information to modify it!

When it's released, it's usually half a day before it's available to the public./maven2 It can be seen on, and is only available one day after release on the I don't know when I'll be able to search for it on AliCloud.

As long as the/maven2 You can only use the corresponding file if the submission is visible on thedependency You can use the address/artifact/[groupId]/[artifactId] (eg: /artifact//mee-excel consult (a document etc)

eg:

  <dependency>
      <groupId></groupId>
      <artifactId>mee-excel</artifactId>
      <version>1.0.0</version>
  </dependency>