Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I submit a GitHub Project to Maven Central?

I have a GWT/Java project hosted on github. I created a maven project structure and when I do

mvm clean install

I get the generated jar file of my project. I tried to upload it to oss.sonatype.org but closing the project there failed.

Is there an easy way to submit my jar to maven central? Do I have any errors in my pom.xml as sown below?

<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>[email protected]</email>
            <url>http://www.example.de</url>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:[email protected]:test/test.git</connection>
        <developerConnection>scm:git:[email protected]: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>

Edit: I get the following errors when I want to close my repo on sonatype:

enter image description here

enter image description here

enter image description here

Edit: I solved the JavaDoc Issue but the Signature Issue is still open.

like image 871
confile Avatar asked Mar 21 '14 23:03

confile


People also ask

How do I add a Git repository to Maven?

To bring a GitHub hosted Maven project into Eclipse, follow these steps: Copy the GitHub URL of the repository to the clipboard. Open Eclipse and choose Import –> Projects from Git (with smart import) Choose the Clone URI option in the Git import wizard and click Next.


1 Answers

your pom has groupId = org.example and artifactId = test: you have to choose unique coordinates

a new introduction has been published lately http://central.sonatype.org/pages/ossrh-guide.html

and you should read carefully requirements: http://central.sonatype.org/pages/requirements.html

Don't forget that once an artifact is published to Central, it will be available for absolutely everybody and won't ever be modified/deleted. So don't publish some tests: publish once your work is sufficiently stable.

You can learn with a local repository manager.

like image 142
hboutemy Avatar answered Sep 22 '22 07:09

hboutemy