2

我尝试从 maven 结帐。我有以下 pom.xml 内容:

<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>groupId</groupId>
<artifactId>server</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<build>
    <sourceDirectory>${basedir}/src</sourceDirectory>
    <outputDirectory>${basedir}/build</outputDirectory>
    <resources>
        <resource>
            <directory>${basedir}/src</directory>
            <excludes>
                <exclude>**/*.gitignore</exclude>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <dependencies>
                <dependency>
                <groupId>org.codehaus.plexus</groupId>
                <artifactId>plexus-utils</artifactId>
                <version>2.1</version>
                </dependency>
                <dependency>
                <groupId>org.apache.maven.scm</groupId>
                <artifactId>maven-scm-provider-gitexe</artifactId>
                <version>1.2</version>
                </dependency>
            </dependencies>
            <version>1.0</version>
            <configuration>                
                <connectionType>connection</connectionType>
                <checkoutDirectory>${project.basedir}/target/checkout</checkoutDirectory>
                <workingDirectory>${project.basedir}/target/checkout</workingDirectory>
            </configuration>
            <executions>
                <execution>
                    <id>check-out-master</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>checkout</goal>
                    </goals>
                                <configuration>
                        <servers>
                            <server>staging</server>
                        </servers>
                    </configuration>
                 </execution>
             </executions>
        </plugin>
    </plugins>
</build>

<!-- THIRD PARTY DEPENDENCIES -->
<!-- ... -->

<!-- GIT -->

<scm>
    <connection>scm:git:ssh://10.0.50.12/opt/git-repos/server.git</connection>
    <url>scm:git:ssh://10.0.50.12/opt/git-repos/server.git</url>

    <developerConnection>scm:git:ssh://10.0.50.12/opt/git-repos/server.git</developerConnection>
</scm>

在我的 settings.xml 中,我有以下内容:

<server>
    <id>staging</id>
    <username>username</username>
    <password>password</password>
</server>

我无法让它工作,也无法获得密码提示。

在执行时我得到这个:

[INFO] --- maven-scm-plugin:1.0:checkout (check-out-master) @ server ---

[INFO] Removing C:\workspace\server\server\target\checkout

[INFO] Executing: cmd.exe /X /C "git clone ssh://10.0.50.12/opt/git-repos/server.git C:\workspace\server\server\target\checkout"

[INFO] Working directory: C:\workspace\server\server\target

它卡在这一点上......我猜它正在等待密码。

有人知道使用密码或至少提示输入密码的解决方案吗?

编辑

今天我做了一个简单的测试:我从 linux 运行 mvn compile 命令,我得到了 git 密码的提示。也许我应该需要一个 ssh 代理

4

1 回答 1

0

确保在您运行它的机器上正确设置了 git(定义了名称和电子邮件设置)。然后先尝试从控制台结帐。如果可行,它也应该适用于 Maven。如您所见,它正在执行一个外部进程。

如果失败,请尝试运行 Maven 在打印时为 git 调用的命令。

于 2013-02-21T15:19:43.143 回答