Maven deploy hangs while downloading maven_metadat

2020-08-09 07:54发布

问题:

I have configured my project to be deployed to my own repository. When I run mvn deploy it looks like it's working but hangs at the stage for downloading the maven_metadata.xml file to after it's uploaded the jars.

INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ myproject ---
Uploading: scp://myrepodomain/.../myproject-0.06-2.jar
Uploaded: scp://myrepodomain/.../myproject-0.06-2.jar (39013 KB at 6234.1 KB/sec)
Uploading: scp://myrepodomain/.../myproject-0.06-2.pom
Uploaded: scp://myrepodomain/.../myproject-0.06-2.pom (8 KB at 21.6 KB/sec)
Downloading: scp://myrepodomain/.../maven-metadata.xml 
320/319 B
.....here is where it just hangs forever

If I delete the maven-metadata.xml file on the server, it works fine and just uploads a freshly generated one.

I should also mention that I am just using a simple HTTP server with SCP, I find the larger artifact systems to be way overkill for what I am doing. I can't figure out how to even debug this. Any suggestions would be appreciated.

回答1:

I have managed to fix this by swapping all references of scp to sftp in my pom.xml. The advantage of this solution is it does not require any additional configuration. See http://jira.codehaus.org/browse/MNG-5605 for more information.



回答2:

With OS/X 10.9.3 and Maven 3.2.3, I had the same issue.

It seems to be the wagon plugin which is broken when downloading the files during the deploy.

I solved it by switching the wagon connector to "Maven Wagon SSH External" in order to use the system ssh command.

Below my POM.xml modification :

        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-ssh</artifactId>
            <version>2.6</version>
        </extension>

switched to :

        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-ssh-external</artifactId>
            <version>2.6</version>
        </extension>

And replaced

    scp://myuser@myhost.com

By

    scpexe://myuser@myhost.com

into url tags :

    <repository>
        ...
        <url>scpexe://myuser@myhost.com</url>
        ...
    </repository>


回答3:

This appears to be some obscure bug I was unable to find a reference to in Maven 3.0.5 (default in debian testing). Installing Maven 3.1.1 fixed this issue.



回答4:

I had a problem like this. When I tried wget these ...maven_metadata.xml URLs I received a 404 response.

My solution was to shorten the timeout for these servers (from 2 minutes default to 2 seconds).

First you have to find the ID of the repository for this URL. That is if you are stuck on downloading from artifactoryonline.org, search for this repository in your POMs:

$ find . -name 'pom*.xml' | xargs grep factoryonline

Go to the found POM and fetch the repository ID. Then edit your ~/.m2/settings.xml to something like this:

<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>Metamarkets-repository</id>
                    <configuration>
                            <httpConfiguration>
                                    <all>
                                            <connectionTimeout>2000</connectionTimeout>
                                            <readTimeout>2000</readTimeout>
                                    </all>
                            </httpConfiguration>
                    </configuration>
            </server>
    </servers>
</settings>

This will make the downloading give up after 2 seconds and let the build continue (assuming the maven_metadata.xml will be downloaded from somewhere else).