If the file is Maven dependent, you can use the Maven Dependency Plugin , which has get .
For any file, you can use the Antrun plugin to call Ant Get the task .
Another option would be the maven-download-plugin , which was precisely created to facilitate this kind of thing. It is not very actively developed, and the documentation only mentions the goal of artifact , which does the same thing as dependency:get , but ... If you look at the sources, you will see that there is a WGet mojo that will do the job.
Use this as in any POM:
<plugin> <groupId>com.googlecode.maven-download-plugin</groupId> <artifactId>download-maven-plugin</artifactId> <version>1.3.0</version> <executions> <execution> <phase>process-resources</phase> <goals> <goal>wget</goal> </goals> <configuration> <url>http://url/to/some/file</url> <outputFileName>foo.bar</outputFileName> <outputDirectory>${project.build.directory}</outputDirectory> </configuration> </execution> </executions> </plugin>
Key benefits of this plugin are download caching and signature verification, such as MD5.
Please note that this answer has been heavily updated to reflect changes in the plugin as indicated in the comments.
Pascal Thivent Apr 30 '10 at 2:29 2010-04-30 02:29
source share