简体   繁体   中英

Why is `maven clean deploy` failing while I am trying to deploy to a local sonatype maven repo?

I am trying to set a Sonatype Maven Artefacts private repository.

My.m2/settings.xml looks like below

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:10081/repository/maven-tarkshala/</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
<activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
  <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>tarkshala</password> 
    </server>
  </servers>
</settings>

And my project's pom looks like this

<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright © 2019 Federico Recio (N/A)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         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>
    <parent>
        <groupId>com.smoketurner.dropwizard</groupId>
        <artifactId>dropwizard-pom</artifactId>
        <version>2.0.16-1</version>
    </parent>

    <groupId>com.tarkshala</groupId>
    <artifactId>dropwizard-swagger</artifactId>
    <version>2.0.16</version>

    <properties>
        <jersey.version>2.35</jersey.version>
        <swagger.version>2.2.7</swagger.version>
    </properties>

    <name>Dropwizard Swagger support</name>
    <description>A simple way to document your REST APIs in DropWizard using Swagger</description>
    <url>https://github.com/smoketurner/dropwizard-swagger/</url>

    <developers>
        <developer>
            <name>Federico Recio</name>
            <url>http://about.me/federecio</url>
        </developer>
        <developer>
            <id>jplock</id>
            <name>Justin Plock</name>
            <email>jplock@smoketurner.com</email>
            <timezone>America/New_York</timezone>
        </developer>
    </developers>

    <!-- Used to point local artifacts to the hosted repo , Starts  -->
    <distributionManagement>
        <repository>
            <id>nexus</id>
            <name>maven-releases</name>
            <url>http://localhost:10081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus</id>
            <name>maven-snapshots</name>
            <url>http://localhost:10081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <!--  Ends  -->

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey.containers</groupId>
                <artifactId>jersey-container-servlet-core</artifactId>
                <version>${jersey.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-auth</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-assets</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-views</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-views-freemarker</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-jaxrs2</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-integration</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>2.3.3</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <version>1.2.2</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>4.5.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <properties>
                        <owner>Federico Recio</owner>
                        <email>N/A</email>
                    </properties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.8</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>nexus</serverId>
                    <nexusUrl>http://localhost:10081/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

It builds and deploy well if I change version to SNAPSHOT like <version>2.0.16-SNAPSHOT</version> . I could verify same in my repository as well as shown.

快照版本的存储库屏幕截图

Build logs also looks good as following:

[INFO] --- nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) @ dropwizard-swagger ---
[INFO] Performing deferred deploys (gathering into "/Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred")...
[INFO] Installing /Users/apple/Work/repos/dropwizard-swagger/target/dropwizard-swagger-2.0.16-SNAPSHOT.jar to /Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-SNAPSHOT.jar
[INFO] Installing /Users/apple/Work/repos/dropwizard-swagger/pom.xml to /Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-SNAPSHOT.pom
[INFO] Installing /Users/apple/Work/repos/dropwizard-swagger/target/dropwizard-swagger-2.0.16-SNAPSHOT-sources.jar to /Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-SNAPSHOT-sources.jar
[INFO] Installing /Users/apple/Work/repos/dropwizard-swagger/target/dropwizard-swagger-2.0.16-SNAPSHOT-javadoc.jar to /Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-SNAPSHOT-javadoc.jar
[INFO] Deploying remotely...
[INFO] Bulk deploying locally gathered artifacts from directory: 
[INFO]  * Bulk deploying locally gathered snapshot artifacts
Downloading from nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1-javadoc.jar
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1-javadoc.jar (370 kB at 3.3 MB/s)
Downloading from nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/maven-metadata.xml
Downloaded from nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/maven-metadata.xml (294 B at 12 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml (651 B at 12 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/maven-metadata.xml
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/maven-metadata.xml (335 B at 4.6 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1.jar
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1.jar (2.6 MB at 16 MB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1.pom
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1.pom (6.0 kB at 122 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml (999 B at 17 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1-sources.jar
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1-sources.jar (2.6 MB at 14 MB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml (1.2 kB at 25 kB/s)
[INFO]  * Bulk deploy of locally gathered snapshot artifacts finished.
[INFO] Remote deploy finished with success.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.868 s
[INFO] Finished at: 2023-01-08T08:25:29+05:30
[INFO] ------------------------------------------------------------------------

But when I change the version to release like <version>2.0.16</version> . Command mvn clean deploy fails with following error

[INFO] 
[INFO] --- nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) @ dropwizard-swagger ---
[INFO] Performing local staging (local stagingDirectory="/Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/staging")...
[INFO]  + Using server credentials "nexus" from Maven settings.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.436 s
[INFO] Finished at: 2023-01-08T08:12:56+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) on project dropwizard-swagger: Execution injected-nexus-deploy of goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy failed: Nexus connection problem to URL [http://localhost:10081/ ]: 404 - Not Found -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Looks like you are using the Nexus staging maven plugin to deploy. But you are NOT using Nexus Professional with the staging support and have not set the URL for that correctly.

To fix it either change the URL in distributionManagement to point at the staging URL, or remove usage of the staging plugin and use the normal deploy plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM