Maven:如何从远程存储库下载/包含文件?

时间:2011-07-25 13:53:10

标签: maven-2 maven selenium

我正在使用Maven 3.0.3。对于我们的项目,我们为我们的集成测试阶段启动了Selenium服务器以运行测试。我们有一个自定义用户扩展文件,我们整合如下...

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>selenium-maven-plugin</artifactId>
        <version>1.1</version>
        <executions>
                <execution>
                        <phase>pre-integration-test</phase>
                        <goals>
                                <goal>start-server</goal>
                        </goals>
                        <configuration>
                                <background>true</background>
                                <logOutput>true</logOutput>
                                <userExtensions>${project.basedir}/src/test/resources/selenium/user-extensions.js</userExtensions>
                        </configuration>
                </execution>
        </executions>
</plugin>

此文件存在于git存储库中,我希望我们从git存储库下载该文件的最新版本,而不是将其复制到我们的项目中,并在文件的新版本发布时手动更新所有项目。但是,我不知道如何获取该文件的最新版本并将其包含在Maven的插件中。有什么想法吗?

2 个答案:

答案 0 :(得分:3)

使用maven-scm-plugin

        <plugin>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.2</version>
            <executions>
                <execution>
                    <id>Foo</id>
                    <goals>
                        <goal>export</goal>
                    </goals>
                    <phase>generate-resources</phase>
                    <configuration>
                        <connectionUrl>scm:git:...</connectionUrl>
                        <exportDirectory>${project.build.directory}</exportDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

答案 1 :(得分:2)

解决此问题的方法是在结果工件(例如jar或zip文件)中构建一个包含此文件的单独模块,并将其部署到maven存储库。

然后,您可以使用maven dependencies插件从maven存储库中检索它,将其解压缩到目标文件夹并在selenium插件调用中引用它。