【问题标题】:How can I submit a GitHub Project to Maven Central?如何向 Maven Central 提交 GitHub 项目?
【发布时间】:2014-04-29 13:18:38
【问题描述】:

我在 github 上托管了一个 GWT/Java 项目。我创建了一个 Maven 项目结构,当我这样做时

mvm clean install

我得到了我的项目生成的 jar 文件。我尝试将其上传到 oss.sonatype.org 但关闭该项目失败。

有没有一种简单的方法可以将我的 jar 提交到 maven Central?我的 pom.xml 中是否有任何错误,如下所示?

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- sonatype parent pom -->
    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>7</version>
    </parent>


    <groupId>org.example</groupId>
    <artifactId>test</artifactId>
    <version>1.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Test</name>

    <url>https://github.com/test/test</url>
    <description>A test.js library.</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <gwtversion>2.6.0</gwtversion>
    </properties>

    <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>


    <developers>
        <developer>
            <name>Author</name>
            <email>mail@example.com</email>
            <url>http://www.example.de</url>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com:test/test.git</connection>
        <developerConnection>scm:git:git@github.com:test/test.git</developerConnection>
        <url>http://github.com/test/test.git</url>
        <tag>HEAD</tag>
    </scm>


    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus snapshot repository</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>sonatype-nexus-staging</id>
            <name>Sonatype Nexus release repository</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>


    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
                <configuration>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>

                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                    <projectnatures>
                        <projectnature>org.eclipse.jdt.core.javanature</projectnature>
                        <nature>com.google.gwt.eclipse.core.gwtNature</nature>
                    </projectnatures>
                    <buildcommands>
                        <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
                        <buildcommand>com.google.appengine.eclipse.core.projectValidator</buildcommand>
                        <buildcommand>com.google.gwt.eclipse.core.gwtProjectValidator</buildcommand>
                    </buildcommands>
                    <classpathContainers>
                        <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
                        <classpathContainer>com.google.gwt.eclipse.core.GWT_CONTAINER</classpathContainer>
                    </classpathContainers>
                    <excludes>
                        <exclude>com.google.gwt:gwt-servlet</exclude>
                        <exclude>com.google.gwt:gwt-user</exclude>
                        <exclude>com.google.gwt:gwt-dev</exclude>
                        <exclude>javax.validation:validation-api</exclude>
                    </excludes>


                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
                </configuration>
            </plugin>



        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/client/**</include>
                    <include>**/shared/**</include>
                    <include>**/*.gwt.xml</include>
                </includes>
            </resource>
        </resources>
    </build>


    <profiles>
        <profile>
            <id>release-sign-artifacts</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.5</version>
                        <configuration>
                            <passphrase>${gpg.passphrase}</passphrase>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>



    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <type>jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtversion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>${gwtversion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <classifier>sources</classifier>
            <scope>provided</scope>
        </dependency>

        <!-- only for File API emulation in hosted mode -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.0.1</version>
        </dependency>
    </dependencies>



</project>

编辑:当我想关闭 sonatype 上的 repo 时出现以下错误:

编辑:我解决了 JavaDoc 问题,但签名问题仍然存在。

【问题讨论】:

  • 您需要严格按照说明中的每一步操作。您是否在第 3 步中创建了 Jira 票证? docs.sonatype.org/display/Repository/…
  • @ThorbjørnRavnAndersen 是的,我创建了一个 Jira 票证,但后来我变成了一个不创建空票证的邮件。
  • 再试一次并完全按照指示进行。票很重要。
  • 可能需要“一段时间”才能回复您的票证。应该不会超过几天,但它们是手动处理的,所以给它们一些呼吸的时间。如果一周后仍未收到回复,则可能有问题,您应该再试一次。
  • 对不起,我也不是这里的专家,但是您创建了 PGP 签名吗? docs.sonatype.org/display/Repository/… 否则,也许@ThorbjørnRavnAndersen 知道那里可能出了什么问题。

标签: java eclipse maven jar


【解决方案1】:

你的 pom 有 groupId = org.example 和 artifactId = test:你必须选择唯一的坐标

最近发布了一个新的介绍http://central.sonatype.org/pages/ossrh-guide.html

你应该仔细阅读要求:http://central.sonatype.org/pages/requirements.html

不要忘记,一旦工件发布到 Central,它绝对可供所有人使用,并且永远不会被修改/删除。所以不要发布一些测试:在你的工作足够稳定后发布。

您可以与本地存储库管理器一起学习。

【讨论】:

【解决方案2】:

有大量的documentation,包括一些可用的视频教程。在您的情况下,您的工件没有被签名存在问题。

【讨论】:

    猜你喜欢
    • 2021-10-08
    • 2016-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    • 2021-07-02
    • 1970-01-01
    • 2011-12-11
    相关资源
    最近更新 更多