maven打包及发布

本地打包

mvn install:install-file -Dfile=D:\program\lib\ojdbc7.jar  -DgroupId=com.github.glory2018 -DartifactId=ojdbc7  -Dversion=12.1.0.2.0 -Dpackaging=jar

添加本地jar

<!--添加本地的jacob.jar包-->
<dependency>
    <groupId>com.jacob</groupId>
    <artifactId>jacob</artifactId>
    <version>1.19</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/resources/lib/jacob.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/resources/lib/ojdbc7.jar</systemPath>
</dependency>

jar发布到中央仓库

注册

https://issues.sonatype.org/secure/Dashboard.jspa

新建

GPG 生成密钥对

下载Gpg4win

https://www.gpg4win.org/download.html

新建密匙对

 

修改全局的setting.xml

<server>
	<id>ossrh</id>
	<username>repouser</username>
	<password>repopwd</password>
</server>

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.glory2018</groupId>
    <artifactId>nexus-oss</artifactId>
    <version>1</version>
    <name>nexus-oss</name>
    <description>nexus-oss</description>
    <url>https://github.com/glory2018/nexus-oss</url>
    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>actable</distribution>
        </license>
    </licenses>
    <developers>
        <developer>
            <name>steve2019frank</name>
            <email>bjfansr@cn.ibm.com</email>
            <organization>ibm</organization>
            <url>https://github.com/glory2018/nexus-oss</url>
        </developer>
    </developers>
    <scm>
        <connection>https://github.com/glory2018/nexus-oss.git</connection>
        <developerConnection>https://github.com/glory2018</developerConnection>
        <url>https://github.com/glory2018/nexus-oss.git</url>
        <tag>1.0</tag>
    </scm>
    <dependencies>
        <!--添加本地的jacob.jar包-->
        <dependency>
            <groupId>com.jacob</groupId>
            <artifactId>jacob</artifactId>
            <version>1.19</version>
            <scope>system</scope>
            <systemPath>${basedir}/src/main/resources/lib/jacob.jar</systemPath>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- Source -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.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>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- GPG -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>
</project>

上传构件到 OSS 中

mvn clean deploy -P release

在OSS 系统中发布构件

 https://oss.sonatype.org

在 Staging Repositories 中查看刚才已上传的构件,状态为 Open,需要勾选它,然后点击 Close 按钮

如果提示Event: Failed: Signature Validation

gpg --keyserver hkp://pool.sks-keyservers.net --send-keys A133E51E7AAD0D32A46E2BE28FFFE02963AB0DCD

重新Close

点击 Release 按钮来发布该构件

从中央仓库中搜索构件

http://search.maven.org/

以后的发布流程:

构件完成后直接使用maven在命令行上传构建;

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值