sonatype准备操作

1. group id 如果你有com域名的所有权可以直接使用,如果不符合可以使用com.github.{账号名来定义}
2. 如果有问题管理员会在下方留言通知你如下文(github所有权验证)

然后等会有类似的通知发出,并按通知进行操作。

When choosing a groupId that reflects your project hosting, in this case, something like io.github.ants-double or com.github.ants-double would be correct. Also, please create a public repo called OSSRH-52139 to verify github account ownership.

然后你就创建对应的公有仓库,等创建成功后在些回复一下,看到如下评论前期准备工作就正式结束了

com.github.ants-double has been prepared, now user(s) antsdouble,Ants-double can:

Deploy snapshot artifacts into repository https://oss.sonatype.org/content/repositories/snapshots
Deploy release artifacts into the staging repository https://oss.sonatype.org/service/local/staging/deploy/maven2
Release staged artifacts into repository 'Releases'
please comment on this ticket when you promoted your first release, thanks

GPG的准备工作

gpg --keyserver http://keys.gnupg.net:11371/ --send-keys [xxxxxxxxx] 其中的[xxxxxxxxx],可用gpg --list-keys显示出来。

```

Maven准备工作

  • 更新setting.xml文件添加仓库

    <server>
    <id>sonatype-nexus-snapshots</id>
    <username>Sonatype账号</username>
    <password>Sonatype密码</password>
    </server>
    <server>
    <id>sonatype-nexus-staging</id>
    <username>Sonatype账号</username>
    <password>Sonatype密码</password>
    </server>
  • 修改pom.xml文件 增加许可协议、SCM信息、开发者信息 (最后附完整的pom.xml文件)

    <licenses>
    <license>
    <name>The Apache Software License, Version 2.0</name>
    <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    <distribution>repo</distribution>
    </license>
    </licenses>
    <scm>
    <tag>master</tag>
    <url>git@github.com:Ants-double/mianhua.git</url>
    <connection>scm:git:git@github.com:Ants-double/mianhua.git</connection>
    <developerConnection>scm:git:git@github.com:Ants-double/mianhua.git</developerConnection>
    </scm>
    <developers>
    <developer>
    <name>ants-double</name>
    <email>ants_double@yeah.net</email>
    <organization>ants-double</organization>
    </developer>
    </developers>
  • 添加相关插件和仓库信息

    <build>
    <plugins>
    <!-- Source -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>2.2.1</version>
    <executions>
    <execution>
    <phase>package</phase>
    <goals>
    <goal>jar-no-fork</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    <!-- Javadoc -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.9.1</version>
    <configuration>
    <encoding>${chartset.UTF8}</encoding>
    <aggregate>true</aggregate>
    <charset>${chartset.UTF8}</charset>
    <docencoding>${chartset.UTF8}</docencoding>
    </configuration>
    <executions>
    <execution>
    <id>attach-javadocs</id>
    <phase>package</phase>
    <goals>
    <goal>jar</goal>
    </goals>
    <configuration>
    <additionalparam>-Xdoclint:none</additionalparam>
    </configuration>
    </execution>
    </executions>
    </plugin>
    <!-- GPG -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-gpg-plugin</artifactId>
    <version>1.5</version>
    <executions>
    <execution>
    <phase>verify</phase>
    <goals>
    <goal>sign</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    <!--Compiler-->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.0</version>
    <configuration>
    <source>1.8</source>
    <target>1.8</target>
    <fork>true</fork>
    <verbose>true</verbose>
    <encoding>UTF-8</encoding>
    <showWarnings>false</showWarnings>
    </configuration>
    </plugin>
    <!--Release-->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.5.1</version>
    </plugin>
    </plugins>
    </build>
    <distributionManagement>
    <snapshotRepository>
    <id>sonatype-nexus-snapshots</id>
    <name>Sonatype Nexus Snapshots</name>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    </snapshotRepository>
    <repository>
    <id>sonatype-nexus-staging</id>
    <name>Nexus Release Repository</name>
    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
    </distributionManagement>

打包发布

  • 使用 命令,一键打包。

    `mvn clean deploy -P <profile-id>`
  • 打包过程中会要求输入gpg密钥的Passphase信息,输入即可

  • 然后到https://oss.sonatype.org/#stagingRepositories 查看,看到如下信息

  • 然后去账号下面去回复评论,大概意思是我弄完了,你处理一下吧

  • 最后在 nexus repository manager中staging repositories选中最新发布的项目,然后执行

    open -> closed
    closed->release
    执行完可以在activity中查看状态以角错误的原因
  • 最后按官网上说的过一会,maven Center可以更久一点就能查到了。

    https://search.maven.org/
    
    https://mvnrepository.com/
  • 附图

完整的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.github.ants-double</groupId>
<artifactId>mainhua</artifactId>
<version>1.0-RELEASE</version> <name>mainhua</name>
<url>https://github.com/Ants-double/mianhua</url>
<description>常用工具集成</description> <properties>
<!-- Environment Settings -->
<java.version>1.8</java.version> <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<chartset.UTF8>UTF-8</chartset.UTF8>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- json-->
<project.fastjson.version>1.2.56</project.fastjson.version>
<lombok.version>1.18.8</lombok.version>
<project.test.version>4.12</project.test.version> </properties> <dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${project.fastjson.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${project.test.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<tag>master</tag>
<url>git@github.com:Ants-double/mianhua.git</url>
<connection>scm:git:git@github.com:Ants-double/mianhua.git</connection>
<developerConnection>scm:git:git@github.com:Ants-double/mianhua.git</developerConnection>
</scm>
<developers>
<developer>
<name>ants-double</name>
<email>ants_double@yeah.net</email>
<organization>ants-double</organization>
</developer>
</developers>
<profiles>
<profile>
<id>Releases</id>
<build>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<encoding>${chartset.UTF8}</encoding>
<aggregate>true</aggregate>
<charset>${chartset.UTF8}</charset>
<docencoding>${chartset.UTF8}</docencoding>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<!--Compiler-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<verbose>true</verbose>
<encoding>UTF-8</encoding>
<showWarnings>false</showWarnings>
</configuration>
</plugin>
<!--Release-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement> </profile>
</profiles>
</project>

出现的问题

  1. java1.8javadoc严格验证

    解决是添加
    <configuration>
    <additionalparam>-Xdoclint:none</additionalparam>
    </configuration>
  2. 项目id不存在,解决是添加命名的项目id

从零开始把项目发布到maven仓库中心的更多相关文章

  1. 从零开始把项目发布到NPM仓库中心

    从零开始把项目发布到NPM仓库中心 前期准备 注册账号 https://www.npmjs.com/signup 网易邮箱注册失败,用QQ邮箱成功 使用npm 命令注册(建议使用网页): npm ad ...

  2. 从零开始把项目发布到Nuget仓库中心

    从零开始把项目发布到Nuget仓库中心 我的项目地址 https://github.com/Ants-double/dasuan ### 前期准备 下载并注册nuget帐号 下载地址 https:// ...

  3. 把自己的项目发布到maven仓库并在maven和gradle中开始使用

    把自己的项目发布到maven仓库并在maven和gradle中开始使用 上一条博客中提到的日志打印项目总算是维护的差不多了, 不过现在使用它还是打成jar包放到其他项目内, 所以决定把项目传到mave ...

  4. maven仓库中心mirrors配置多个下载中心(执行最快的镜像)

    E:\Program FilesApache Software Foundationapache-maven-3.5.4-binconf\settings.xmlmaven仓库中心mirrors配置多 ...

  5. 将Gradle项目公布到maven仓库

    将Gradle项目公布到maven仓库 1 Gradle简单介绍 1.1 Ant.Maven还是Gradle? 1.1.1 Ant和Maven介绍 全称为Apache Maven,是一个软件(特别是J ...

  6. 3.将maven项目jar纳入maven仓库,Mave项目依赖另外一个Maven项目的案例

     1 若想让maven项目依赖另外一个maven项目.被依赖的项目要在maven仓库中有对应的jar包,所以要对依赖的项目运行mvninstall命令. 2 新建第二个项目模块HelloFrien ...

  7. 将项目发布到Maven中央仓库的不完整纪要

    背景 有几个Utils性质的Jar需要跨项目引用,原本想部署私有Maven仓库,后来感觉太麻烦,索性直接发布到中央库,引用时也方便. 发布成功之后,觉得某些细节还是有必要记录一下. 资源 Sonaty ...

  8. 将Gradle项目发布到Maven Central库中

    本文主要介绍如何一个由gradle构建的项目部署到Maven Central. 网上大部分都是介绍如何将由maven构建的项目部署到Maven Central.与Gradle相关的比较少. 申请账号 ...

  9. 如何将项目发布到npm仓库

    有时候,我们希望将项目里的模块提升为公共模块,以便其他项目也能使用.在前端可以将模块发布到npm仓库,这样所有项目都可以通过 npm install youProject 使用模块了. 这个过程很简单 ...

随机推荐

  1. Java基本数据类型转换及运算符

    上次我们说到完了Java中的基本数据类型,今天我们来说说Java中的基本数据类型转换和Java中的运算符 基本数据类型转换 java中可以从任意基本数据类型转型到外的基本数据类型 注意:(boolea ...

  2. 基于SpringBoot + Mybatis实现 MVC 项目

    1.预览: (1)完整项目结构 (2) 创建数据库.数据表: [user.sql] SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- ...

  3. 使用Docker安装FastDFS(分布式文件系统)

    1. 获取镜像 可以利用已有的FastDFS Docker镜像来运行FastDFS. 获取镜像可以通过下载 docker image pull delron/fastdfs 也可是直接使用提前下载的镜 ...

  4. 数据库系统概论——从E-R模型到关系模型

    E-R模型和关系模型都是现实世界抽象的逻辑表示 E-R模型并不被 DBMS直接支持,更适合对现实世界建模 关系模型是 DBMS直接支持的数据模型 基本 E-R图中的元素包括实体集.联系集.属性 椭圆框 ...

  5. python pytesseracct WinError2

    接上一个3步图像识别,本来已经在两台电脑同样的操作3步都可以识别出验证码,但是今天在新电脑同样的步骤却出现了winerror2,泪崩. 一样的配方,不一样的结果. 后来发现是调用不到tesseract ...

  6. 《完美解决系列》Android5.0以上 Implicit intents with startService are not safe

    在Android6.0上,使用了以下代码: Intent intent = new Intent(); intent.setAction("xxx.server"); bindSe ...

  7. ElasticSearch Cardinality Aggregation聚合计算的误差

    使用ES不久,今天发现生产环境数据异常,其使用的ES版本是2.1.2,其它版本也类似.通过使用ES的HTTP API进行查询,发现得到的数据跟javaClient API 查询得到的数据不一致,于是对 ...

  8. php企业微信获取员工userid以及打卡信息

    企业微信可以通过部门列表获取部门下的员工信息,从而获取到员工的userid //首先获取需要的access_token $access_token = json_decode($this->ge ...

  9. 02-15 Logistic回归(鸢尾花分类)

    目录 Logistic回归(鸢尾花分类) 一.导入模块 二.获取数据 三.构建决策边界 四.训练模型 4.1 C参数与权重系数的关系 五.可视化 更新.更全的<机器学习>的更新网站,更有p ...

  10. 03-01 K-Means聚类算法

    目录 K-Means聚类算法 一.K-Means聚类算法学习目标 二.K-Means聚类算法详解 2.1 K-Means聚类算法原理 2.2 K-Means聚类算法和KNN 三.传统的K-Means聚 ...