簡體   English   中英

如何向Maven Central提交GitHub項目?

[英]How can I submit a GitHub Project to Maven Central?

我在github上托管了一個GWT / Java項目。 我創建了一個maven項目結構

mvm clean install

我得到了我的項目生成的jar文件。 我試圖將它上傳到oss.sonatype.org,但關閉項目失敗了。

有沒有一種簡單的方法可以將我的罐子提交到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問題,但簽名問題仍然存在。

你的pom有groupId = org.example和artifactId = test:你必須選擇唯一的坐標

最近發表了一篇新的介紹http://central.sonatype.org/pages/ossrh-guide.html

你應該仔細閱讀要求: http//central.sonatype.org/pages/requirements.html

不要忘記,一旦工件發布到Central,它將絕對適用於所有人,並且永遠不會被修改/刪除。 所以不要發布一些測試:一旦你的工作足夠穩定就發布。

您可以使用本地存儲庫管理器進行學習。

有大量文檔,包括一些視頻教程。 在您的情況下,您的工件沒有簽名存在問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM