Pas*_*ent 57
如果该文件是Maven依赖项,则可以使用具有目标的Maven Dependency Pluginget
.
对于任何文件,您都可以使用Antrun插件来调用Ant的Get任务.
另一种选择是maven-download-plugin,它是为了促进这种事情而精确创建的.它并没有非常积极地开发,文档只提到了一个artifact
完全相同的目标dependency:get
但是......如果你看一下这些来源,你会发现它有一个能够完成这项工作的WGet mojo.
在任何POM中都这样使用它:
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<!-- the wget goal actually binds itself to this phase by default -->
<phase>process-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>http://url/to/some/file</url>
<outputFileName>foo.bar</outputFileName>
<!-- default target location, just to demonstrate the parameter -->
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这个插件的主要好处是缓存下载和检查签名,如MD5.
请注意,此答案已经过大量更新,以反映插件中的更改,如注释中所述.
mmu*_*ler 25
看起来像CodeHaus的wagon-maven-plugin允许通过HTTP下载文件(虽然这不是原始目标).
以下是在集成测试之前下载GlassFish zip的示例:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>download-glassfish</id>
<phase>pre-integration-test</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>http://download.java.net</url>
<fromFile>glassfish/3.1/release/glassfish-3.1.zip</fromFile>
<toDir>${project.build.directory}/glassfish</toDir>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
aar*_*ron 17
maven-antrun-plugin是一个更直接的解决方案:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>download-files</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- download file -->
<get src="http://url/to/some/file"
dest="${project.build.directory}/downloads/"
verbose="false"
usetimestamp="true"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
Mic*_*ael 14
我想添加一些关于download-maven-plugin的东西:
归档时间: |
|
查看次数: |
50398 次 |
最近记录: |