NutzCN Logo
精华 将项目上传到maven公共仓库的问题
发布于 454天前 作者 enilu 690 次浏览 复制 上一个帖子 下一个帖子
标签:

为了nutzwk插件使用方便,想着把它上传到maven公共仓库。没想到折腾起来辣么费劲。
目前已经将项目上传到snapshots仓库:https://oss.sonatype.org/content/repositories/snapshots
接着上传到releases仓库的时候出现问题了。
下面是我的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>cn.enilu.tools</groupId>
    <artifactId>nutzwk-code-generator</artifactId>
    <packaging>jar</packaging>
    <name>nutzwk-code-generator</name>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <java-version>1.7</java-version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <nutz-version>1.r.56.r3</nutz-version>
        <javax.validation-version>1.1.0.Final</javax.validation-version>
        <evo-inflector-version>1.0.1</evo-inflector-version>
        <guava-version>18.0</guava-version>
        <velocity-version>1.7</velocity-version>
        <druid-version>1.0.20</druid-version>
        <mysql-driver-version>5.1.39</mysql-driver-version>
        <commons-cli-version>1.2</commons-cli-version>
    </properties>
    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>
    <developers>
        <developer>
            <id>enilu</id>
            <name>enilu</name>
            <email>eniluzt@qq.com</email>
            <url>http://www.enilu.cn</url>
        </developer>
    </developers>
    <scm>
        <connection>scm:git:git@github.com:enilu/nutzwk-code-generator.git</connection>
        <developerConnection>scm:git:git@github.com:enilu/nutzwk-code-generator.git</developerConnection>
        <url>git@github.com:enilu/nutzwk-code-generator.git</url>
      <tag>nutzwk-code-generator-1.0</tag>
  </scm>
    <dependencies>
        <!--代码生成单独需要的依赖-->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>${javax.validation-version}</version>
        </dependency>
        <dependency>
            <groupId>org.atteo</groupId>
            <artifactId>evo-inflector</artifactId>
            <version>${evo-inflector-version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava-version}</version>
        </dependency>

        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>${commons-cli-version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>${velocity-version}</version>
        </dependency>

        <!--nutzwx 中具备的依赖-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>${druid-version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.alibaba</groupId>
                    <artifactId>jconsole</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.alibaba</groupId>
                    <artifactId>tools</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql-driver-version}</version>
        </dependency>
        <dependency>
            <groupId>org.nutz</groupId>
            <artifactId>nutz</artifactId>
            <version>${nutz-version}</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5</version>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <preparationGoals>clean install</preparationGoals>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>Sonatype Nexus snapshot repository</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>

        <repository>
            <id>nexus-releases</id>
            <name>Sonatype Nexus release repository</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
    </distributionManagement>
</project>

我使用mvn clean deploy 上传snapshots仓库,接下来使用命令mvn release:clean release:prepare release:perform 往releases仓库上传的时候报错了。报错内容为(为了方便代码全部粘贴出来,报错内容在最后面):

[root@zhangtao nutzwk-code-generator]# mvn release:clean release:prepare release:perform
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building nutzwk-code-generator 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.5.3:clean (default-cli) @ nutzwk-code-generator ---
[INFO] Cleaning up after release...
[INFO] 
[INFO] --- maven-release-plugin:2.5.3:prepare (default-cli) @ nutzwk-code-generator ---
[INFO] Verifying that there are no local modifications...
[INFO]   ignoring changes on: **/pom.xml.backup, **/release.properties, **/pom.xml.branch, **/pom.xml.next, **/pom.xml.releaseBackup, **/pom.xml.tag
[INFO] Executing: /bin/sh -c cd /home/public/workspace/git/nutzws/nutzwk-code-generator && git rev-parse --show-toplevel
[INFO] Working directory: /home/public/workspace/git/nutzws/nutzwk-code-generator
[INFO] Executing: /bin/sh -c cd /home/public/workspace/git/nutzws/nutzwk-code-generator && git status --porcelain .
[INFO] Working directory: /home/public/workspace/git/nutzws/nutzwk-code-generator
[INFO] Checking dependencies and plugins for snapshots ...
What is the release version for "nutzwk-code-generator"? (cn.enilu.tools:nutzwk-code-generator) 1.0: : 
What is SCM release tag or label for "nutzwk-code-generator"? (cn.enilu.tools:nutzwk-code-generator) nutzwk-code-generator-1.0: : 
What is the new development version for "nutzwk-code-generator"? (cn.enilu.tools:nutzwk-code-generator) 1.1-SNAPSHOT: : 
[INFO] Transforming 'nutzwk-code-generator'...
[INFO] Not generating release POMs
[INFO] Executing goals 'clean install'...
[WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] [INFO] Scanning for projects...
[INFO] [INFO]                                                                         
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building nutzwk-code-generator 1.0
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ nutzwk-code-generator ---
[INFO] [INFO] Deleting /home/public/workspace/git/nutzws/nutzwk-code-generator/target
[INFO] [INFO] 
[INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ nutzwk-code-generator ---
[INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [INFO] Copying 8 resources
[INFO] [INFO] 
[INFO] [INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ nutzwk-code-generator ---
[INFO] [INFO] Changes detected - recompiling the module!
[INFO] [INFO] Compiling 6 source files to /home/public/workspace/git/nutzws/nutzwk-code-generator/target/classes
[INFO] [INFO] /home/public/workspace/git/nutzws/nutzwk-code-generator/src/main/java/cn/enilu/common/code/TableDescLoader.java: /home/public/workspace/git/nutzws/nutzwk-code-generator/src/main/java/cn/enilu/common/code/TableDescLoader.java使用了未经检查或不安全的操作。
[INFO] [INFO] /home/public/workspace/git/nutzws/nutzwk-code-generator/src/main/java/cn/enilu/common/code/TableDescLoader.java: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
[INFO] [INFO] 
[INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ nutzwk-code-generator ---
[INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [INFO] skip non existing resourceDirectory /home/public/workspace/git/nutzws/nutzwk-code-generator/src/test/resources
[INFO] [INFO] 
[INFO] [INFO] --- maven-compiler-plugin:3.5:testCompile (default-testCompile) @ nutzwk-code-generator ---
[INFO] [INFO] No sources to compile
[INFO] [INFO] 
[INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ nutzwk-code-generator ---
[INFO] [INFO] No tests to run.
[INFO] [INFO] 
[INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ nutzwk-code-generator ---
[INFO] [INFO] Building jar: /home/public/workspace/git/nutzws/nutzwk-code-generator/target/nutzwk-code-generator-1.0.jar
[INFO] [INFO] 
[INFO] [INFO] --- maven-gpg-plugin:1.5:sign (sign-artifacts) @ nutzwk-code-generator ---

您需要输入密码,才能解开这个用户的私钥:“enilu <eniluzt@qq.com>”
2048 位的 RSA 密钥,钥匙号 E7019D3A,建立于 2016-07-26

[INFO] can't connect to `/root/.gnupg/S.gpg-agent': 没有那个文件或目录
[INFO] 
[INFO] (pinentry-gtk-2:10145): GLib-GObject-CRITICAL **: Object class GtkSecureEntry doesn't implement property 'editing-canceled' from interface 'GtkCellEditable'

您需要输入密码,才能解开这个用户的私钥:“enilu <eniluzt@qq.com>”
2048 位的 RSA 密钥,钥匙号 E7019D3A,建立于 2016-07-26

[INFO] can't connect to `/root/.gnupg/S.gpg-agent': 没有那个文件或目录
[INFO] 
[INFO] (pinentry-gtk-2:10153): GLib-GObject-CRITICAL **: Object class GtkSecureEntry doesn't implement property 'editing-canceled' from interface 'GtkCellEditable'
[INFO] [INFO] 
[INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ nutzwk-code-generator ---
[INFO] [INFO] Installing /home/public/workspace/git/nutzws/nutzwk-code-generator/target/nutzwk-code-generator-1.0.jar to /home/public/repository/cn/enilu/tools/nutzwk-code-generator/1.0/nutzwk-code-generator-1.0.jar
[INFO] [INFO] Installing /home/public/workspace/git/nutzws/nutzwk-code-generator/pom.xml to /home/public/repository/cn/enilu/tools/nutzwk-code-generator/1.0/nutzwk-code-generator-1.0.pom
[INFO] [INFO] Installing /home/public/workspace/git/nutzws/nutzwk-code-generator/target/nutzwk-code-generator-1.0.jar.asc to /home/public/repository/cn/enilu/tools/nutzwk-code-generator/1.0/nutzwk-code-generator-1.0.jar.asc
[INFO] [INFO] Installing /home/public/workspace/git/nutzws/nutzwk-code-generator/target/nutzwk-code-generator-1.0.pom.asc to /home/public/repository/cn/enilu/tools/nutzwk-code-generator/1.0/nutzwk-code-generator-1.0.pom.asc
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 12.567 s
[INFO] [INFO] Finished at: 2016-07-26T23:48:28+08:00
[INFO] [INFO] Final Memory: 17M/205M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /home/public/workspace/git/nutzws/nutzwk-code-generator && git add -- pom.xml
[INFO] Working directory: /home/public/workspace/git/nutzws/nutzwk-code-generator
[INFO] Executing: /bin/sh -c cd /home/public/workspace/git/nutzws/nutzwk-code-generator && git rev-parse --show-toplevel
[INFO] Working directory: /home/public/workspace/git/nutzws/nutzwk-code-generator
[INFO] Executing: /bin/sh -c cd /home/public/workspace/git/nutzws/nutzwk-code-generator && git status --porcelain .
[INFO] Working directory: /home/public/workspace/git/nutzws/nutzwk-code-generator
[INFO] Executing: /bin/sh -c cd /home/public/workspace/git/nutzws/nutzwk-code-generator && git commit --verbose -F /tmp/maven-scm-1740693310.commit pom.xml
[INFO] Working directory: /home/public/workspace/git/nutzws/nutzwk-code-generator
[INFO] Executing: /bin/sh -c cd /home/public/workspace/git/nutzws/nutzwk-code-generator && git symbolic-ref HEAD
[INFO] Working directory: /home/public/workspace/git/nutzws/nutzwk-code-generator
[INFO] Executing: /bin/sh -c cd /home/public/workspace/git/nutzws/nutzwk-code-generator && git push git@github.com:enilu/nutzwk-code-generator.git refs/heads/master:refs/heads/master
[INFO] Working directory: /home/public/workspace/git/nutzws/nutzwk-code-generator
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.174 s
[INFO] Finished at: 2016-07-26T23:48:33+08:00
[INFO] Final Memory: 12M/205M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project nutzwk-code-generator: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR] 
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

貌似github相关配置不正确?但是应该怎么配置呢

19 回复

release的版本号不能带snapshot

来自炫酷的 NutzCN

貌似,我不带snapshot的时候报错了,然后我加上了,我执行mvn release:clean release:prepare release:perform
命令的时候,会自动把pom.xml备份为一个pom.xml.releaseBackup。然后自动吧pom.xml中的snapshot去掉。

我再试试去掉snapshot

我把snapshot去掉后再执行是报错这个:

[root@zhangtao nutzwk-code-generator]# mvn release:clean release:prepare release:perform
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building nutzwk-code-generator 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.5.3:clean (default-cli) @ nutzwk-code-generator ---
[INFO] Cleaning up after release...
[INFO] 
[INFO] --- maven-release-plugin:2.5.3:prepare (default-cli) @ nutzwk-code-generator ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.866 s
[INFO] Finished at: 2016-07-26T23:58:05+08:00
[INFO] Final Memory: 12M/205M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project nutzwk-code-generator: You don't have a SNAPSHOT project in the reactor projects list. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

去掉snapshot然后执行

mvn clean package javadoc:jar source:jar gpg:sign deploy

来自炫酷的 NutzCN

貌似成功了,接下来,我点击close?
maven1_png

是的, 然后刷新,刷新,再刷新, release

刷新中,好鸡冻,貌似我昨晚也上传成功了,不过,我一直不停的点击close,点出了5,6个close

貌似close失败:maven2_png

看到右边有报错信息:
Invalid POM: /cn/enilu/tools/nutzwk-code-generator/1.0/nutzwk-code-generator-1.0.pom: Project description missing, Project URL missing

description和URL是必须的?

重新上传了下,貌似成功了:
https://oss.sonatype.org/content/groups/public/cn/enilu/tools/nutzwk-code-generator/1.0/
但是我同事竟然下载不下来,我再看看
谢谢兽总,帮大忙了。

同步到maven中央库是需要1小时以内的时间的.

酱紫哦,明白,谢谢。

补充下过程,备忘:
执行命令: mvn clean package javadoc:jar source:jar gpg:sign deploy 上传release版本的时候,会提示输入gpg 密码,提示很多次,输入就是了。刚开始是我以为我密码错误呢,每次上传都是输十几次密码。不知道为什么。不过可以过去。

不知道为什么,知道的可以解释下

gpg agent不存在的原因. 在什么系统? windows? 别用git bash执行, 直接控制台的话, 是可以的.

我系统centos6.5 ;我就是在系统控制台执行的。

这是控制台输出内容

[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ nutzwk-code-generator ---
[INFO] 
[INFO] --- maven-gpg-plugin:1.5:sign (sign-artifacts) @ nutzwk-code-generator ---

您需要输入密码,才能解开这个用户的私钥:“enilu <eniluzt@qq.com>”
2048 位的 RSA 密钥,钥匙号 E7019D3A,建立于 2016-07-26

can't connect to `/root/.gnupg/S.gpg-agent': 没有那个文件或目录

(pinentry-gtk-2:5355): GLib-GObject-CRITICAL **: Object class GtkSecureEntry doesn't implement property 'editing-canceled' from interface 'GtkCellEditable'

您需要输入密码,才能解开这个用户的私钥:“enilu <eniluzt@qq.com>”
2048 位的 RSA 密钥,钥匙号 E7019D3A,建立于 2016-07-26

can't connect to `/root/.gnupg/S.gpg-agent': 没有那个文件或目录

  。。。。。。。。。。此处有5,6次重复  。。。。。。。。。。

(pinentry-gtk-2:5402): GLib-GObject-CRITICAL **: Object class GtkSecureEntry doesn't implement property 'editing-canceled' from interface 'GtkCellEditable'

您需要输入密码,才能解开这个用户的私钥:“enilu <eniluzt@qq.com>”
2048 位的 RSA 密钥,钥匙号 E7019D3A,建立于 2016-07-26

can't connect to `/root/.gnupg/S.gpg-agent': 没有那个文件或目录

(pinentry-gtk-2:5409): GLib-GObject-CRITICAL **: Object class GtkSecureEntry doesn't implement property 'editing-canceled' from interface 'GtkCellEditable'
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ nutzwk-code-generator ---
[INFO] Installing /home/public/workspace/git/nutzws/nutzwk-code-generator/target/nutzwk-code-generator-1.0.jar to /home/public/repository/cn/enilu/tools/nutzwk-code-generator/1.0/nutzwk-code-generator-1.0.jar
[INFO] Installing /home/public/workspace/git/nutzws/nutzwk-code-generator/pom.xml to /home/public/repository/cn/enilu/tools/nutzwk-code-generator/1.0/nutzwk-code-generator-1.0.pom

控制台的话我没办法... 谷歌一下吧

linux控制台的不晓得, windows下是可以的

确实如你所说是gpg 没有agent的问题。
看有说可以在执行 gpg --gen-key 之前,在环境变量里添加:
/usr/bin/gpg-agent --daemon --use-standard-socket
懒得试了;有兴趣的自己看这两个:

https://www.centos.org/forums/viewtopic.php?t=44661

http://www.linuxquestions.org/questions/linux-security-4/gpg-gpg-agent-can't-connect-to-root-gnupg-s-gpg-agent-611843/

添加回复
请先登陆
回到顶部