如何使用maven从svn签出代码?

时间:2013-07-23 05:00:30

标签: svn maven maven-scm

我正在尝试从svn签出代码。我写了一个pom.xml来做同样的事情。以下是我的代码。

<scm>
    <connection>scm:svn:http://10.6.15.103/svn/PLM_Windchill_MidMarket/PLM_Windchill_MidMarket</connection>
    <developerConnection>scm:svn:http://10.6.15.103/svn/PLM_Windchill_MidMarket/PLM_Windchill_MidMarket</developerConnection>
</scm>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.7</version>
            <configuration>
                <checkoutDirectory>${project.basedir}/src/svn</checkoutDirectory>
                <workingDirectory>${project.basedir}/src/svn</workingDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

当我运行mvn scm:checkout install时,我收到以下错误:

 Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.7:checkout (default-cli) on project test_project1: Cannot run checkout command : Can't load the scm provider. Guice provision errors:

 1) Error in custom provider, java.lang.TypeNotPresentException: Type org.apache.maven.scm.provider.cvslib.cvsjava.CvsJavaScmProvider not present
 at ClassRealm[plugin>org.apache.maven.plugins:maven-scm-plugin:1.7, parent: sun.misc.Launcher$AppClassLoader@5acac268]
 at ClassRealm[plugin>org.apache.maven.plugins:maven-scm-plugin:1.7, parent: sun.misc.Launcher$AppClassLoader@5acac268]
 while locating org.apache.maven.scm.provider.ScmProvider annotated with @com.google.inject.name.Named(value=cvs)

 1 error: org/apache/maven/scm/provider/cvslib/AbstractCvsScmProvider: org.apache.maven.scm.provider.cvslib.AbstractCvsScmProvider

我可以知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

看起来你可能遇到过这个错误: https://bugzilla.redhat.com/show_bug.cgi?id=962273#c1

在bug中它建议使用cvs_native实现而不是Java实现。您可以通过更改插件配置来执行此操作:

<project>
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-scm-plugin</artifactId>
                <version>1.7</version>
                <configuration>
                    <providerImplementations>
                        <cvs>cvs_native</cvs>
                    </providerImplementations>
                </configuration>
            </plugin>
        </plugins
    </build>
</project>

另外作为旁注,scm插件的最新版本是1.8.1,也许移动到最新版本将解决您的问题。