Maven deploy создает два разных репозитория sonatype - PullRequest
0 голосов
/ 11 мая 2019

Я пытаюсь создать процесс CI с автоматической загрузкой артефактов выпуска в Maven Central (Sonatype) из github с использованием Travis CI. В принципе, все работает нормально, кроме как в конце; Я получил два разных репозитория Nexus от моей команды maven deploy: один для pom и jar; второй с источниками, javadoc и подписями.

Я предполагаю, что он создает два хранилища из-за загрузки метаданных посередине:

[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ darksky-client ---
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom (5.3 kB at 212 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.12/plexus-1.0.12.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.12/plexus-1.0.12.pom (9.8 kB at 392 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar (251 kB at 4.0 MB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar (41 kB at 4.6 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom (4.7 kB at 14 kB/s)
[INFO] Downloading from ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/maven-metadata.xml
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/maven-metadata.xml
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/maven-metadata.xml (312 B at 34 B/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-sources.jar
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-sources.jar (26 kB at 65 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-javadoc.jar
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-javadoc.jar (182 kB at 439 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar.asc
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar.asc (819 B at 7.3 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom.asc
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom.asc (819 B at 5.9 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-sources.jar.asc
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-sources.jar.asc (819 B at 6.7 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-javadoc.jar.asc
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-javadoc.jar.asc (819 B at 7.1 kB/s)

Все еще; Я не понимаю почему и как это исправить.

Мой 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>be.skylark.weather</groupId>
    <artifactId>darksky-client</artifactId>
    <version>1.0.1</version>
    <name>darksky-client</name>
    <description>Rest Client library for the darksky API</description>

    <url>https://github.com/skylarkbe/darksky-client/</url>

    <licenses>
        <license>
            <name>GNU GENERAL PUBLIC LICENSE V3</name>
            <url>http://www.gnu.org/licenses/gpl.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Romain Van der Keilen</name>
            <email>somemail@gmail.com</email>
        </developer>
    </developers>

    <scm>
        <url>https://github.com/skylarkbe/darksky-client/</url>
        <connection>scm:git:git://github.com/skylarkbe/darksky-client.git</connection>
        <developerConnection>scm:git:git@github.com:skylarkbe/darksky-client.git</developerConnection>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/skylarkbe/darksky-client/issues</url>
    </issueManagement>


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

    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <jersey.client.version>2.26-b03</jersey.client.version>
        <junit.jupiter.version>5.4.2</junit.jupiter.version>
        <junit.test.excludes>**/*IntegrationTest.java</junit.test.excludes>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.6</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>${jersey.client.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>${jersey.client.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.6</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- To run tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <excludes>
                        <exclude>${junit.test.excludes}</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- To attach sources -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- To generate javadoc -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- To sign the artifacts -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

С некоторыми дополнительными настройками для инструмента travis CI:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <servers>
        <server>
            <!-- Maven Central Deployment -->
            <id>ossrh</id>
            <username>${env.SONATYPE_USERNAME}</username>
            <password>${env.SONATYPE_PASSWORD}</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <id>ossrh</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <gpg.executable>${env.GPG_EXECUTABLE}</gpg.executable>
                <gpg.passphrase>${env.GPG_PASSWORD}</gpg.passphrase>
            </properties>
        </profile>
    </profiles>

</settings>

Команда maven, которую Трэвис использует для сборки, выглядит следующим образом

mvn --settings .travis.settings.xml install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B -V

Для развертывания используется следующий

mvn clean deploy --settings .travis.settings.xml -DskipTests=true -Prelease -B

GPG работает правильно, чтобы подписать артефакты; это только последний шаг для загрузки в промежуточный репозиторий, который вызывает у меня головную боль ...

Заранее спасибо за помощь:)

Ответы [ 2 ]

0 голосов
/ 11 мая 2019

Вероятно, это была скорее проблема конфигурации travis / sonatype, чем проблема maven.

Я наконец-то смог загрузить все правильно;но я должен был:

<build>
    <plugins>
        <!-- Disable default maven deploy plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>3.0.0-M1</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
    </plugins>
</build>

Затем в моем профиле релиза:

<!-- Uses Sonatype deploy plugin -->
<plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>1.6.8</version>
    <extensions>true</extensions>
    <executions>
        <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
                <goal>deploy</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <serverId>ossrh</serverId>
        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
        <autoReleaseAfterClose>false</autoReleaseAfterClose>
    </configuration>
</plugin>

И все в порядке: NexusArtifactUploaded

Спасибо за помощь и понимание!

0 голосов
/ 11 мая 2019

Итак, я клонировал ваш репозиторий, изменил идентификатор группы на свой собственный и изменил идентификаторы DistributionManagement и сделал

mvn clean deploy -Prelease -B 

И результат:

enter image description here

Как видите, все артефакты правильно загружены.

Более того, я могу видеть только загрузки в Staging репозиторий в вашем выводе журнала:

[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar (41 kB at 4.6 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom (4.7 kB at 14 kB/s)
[INFO] Downloading from ossrh: https://oss.sonatype.org/service/l

Другие записи журналапокажите, что происходят загрузки, которые являются загрузками из центрального репозитория и зависимостями maven-deploy-plugin:

[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ darksky-client ---
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom (5.3 kB at 212 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.12/plexus-1.0.12.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.12/plexus-1.0.12.pom (9.8 kB at 392 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar (251 kB at 4.0 MB/s)
...

Так что, к сожалению, я еще не понимаю вашу проблему ...

ОВерсии, которые я имел в виду, должны определять все используемые вами плагины, например, maven-clean-plugin, maven-resources-plugin, maven-install-plugin, maven-deploy-plugin и т. д., которые не определены в вашем pom.Вы решили не использовать существующего родителя, который мог бы сделать это для вас.Вы можете посмотреть на это как на предложение .

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...