覆盖存储库以在 pom.xml 中上传

Override repository for upload in pom.xml

背后的故事:我向 GitHub 中的某个 public 存储库提交了一个错误,它已被修复,但是当我要求发布这些更改时,我没有得到任何回应。所以我正在等待下一个库版本 2 个月。所以我决定分叉这个 repo 并发布到自定义 Bintray。回购是 https://github.com/okta/okta-sdk-java

该项目有多个maven模块:

$ find . -type f -name pom.xml
./httpclients/okhttp/pom.xml
./httpclients/httpclient/pom.xml
./impl/pom.xml
./swagger-templates/pom.xml
./pom.xml
./integration-tests/pom.xml
./api/pom.xml
./coverage/pom.xml
./examples/pom.xml
./examples/quickstart/pom.xml

我只需要发布 impl 模块。

问题是根 pom.xml 有父配置:

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.okta</groupId>
        <artifactId>okta-parent</artifactId>
        <version>14</version>
        <relativePath>../okta-java-parent</relativePath>
    </parent>

    <groupId>com.okta.sdk</groupId>
    <artifactId>okta-sdk-root</artifactId>
    <version>1.6.0-SNAPSHOT</version>
    <packaging>pom</packaging>

并且所有部署配置都在 okta-parent pom.xml 中指定。 我试图用(在根 pom.xml 中)覆盖存储库配置:

  <distributionManagement>
    <repository>
      <id>bintray-g4s8-maven</id>
      <name>mvn</name>
      <url>https://api.bintray.com/maven/g4s8/mvn/okta-sdk-impl/;publish=1</url>
    </repository>
  </distributionManagement>

但这并没有帮助。 我在我的 settings.xml 中为这个 repo 配置了服务器,它对我的​​所有其他项目都运行良好:

<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
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>bintray-g4s8-maven</id>
            <username>g4s8</username>
            <password>...</password>
        </server>
    </servers>
</settings>

当我尝试发布它时出现错误:

$ mvn deploy -pl impl -Ppublish -DskipTests
...
[INFO] --- nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) @ okta-sdk-impl ---
[INFO] Performing deferred deploys (gathering into "/home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred")...
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/target/okta-sdk-impl-1.6.0-SNAPSHOT.jar to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT.jar
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/pom.xml to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT.pom
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/target/okta-sdk-impl-1.6.0-SNAPSHOT-sources.jar to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT-sources.jar
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/target/okta-sdk-impl-1.6.0-SNAPSHOT-javadoc.jar to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT-javadoc.jar
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/target/okta-sdk-impl-1.6.0-SNAPSHOT-javadoc.jar to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT-javadoc.jar
[INFO] Deploying remotely...
[INFO] Bulk deploying locally gathered artifacts from directory: 
[INFO]  * Bulk deploying locally gathered snapshot artifacts
Downloading from sonatype-nexus-snapshots: https://oss.sonatype.org/content/repositories/snapshots/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/maven-metadata.xml
Downloaded from sonatype-nexus-snapshots: https://oss.sonatype.org/content/repositories/snapshots/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/maven-metadata.xml (993 B at 412 B/s)
Uploading to sonatype-nexus-snapshots: https://oss.sonatype.org/content/repositories/snapshots/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-20191101.130725-30-javadoc.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  58.070 s
[INFO] Finished at: 2019-11-01T16:07:41+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) on project okta-sdk-impl: Failed to deploy artifacts: Could not transfer artifact com.okta.sdk:okta-sdk-impl:jar:javadoc:1.6.0-20191101.130725-30 from/to sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots/): Failed to transfer file https://oss.sonatype.org/content/repositories/snapshots/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-20191101.130725-30-javadoc.jar with status code 401 -> [Help 1]

Maven 正在将工件上传到 https://oss.sonatype.org/ 而不是配置的 URL https://api.bintray.com/maven/g4s8/mvn/okta-sdk-impl/;publish=1。我怎样才能强制它使用我的 URL 而不是父 URL?


更新

有效 pom 显示 distributionManagement 中的两个存储库:

    <distributionManagement>
      <repository>
        <id>bintray-g4s8-maven</id>
        <name>mvn</name>
        <url>https://api.bintray.com/maven/g4s8/mvn/okta-sdk-impl/;publish=1</url>
      </repository>
      <snapshotRepository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
      </snapshotRepository>
    </distributionManagement>

您似乎正在构建 SNAPSHOT 版本。配置的<snapshotRepository>oss.sonatype...。您只添加了构建发布版本的配置。