Can I download some files from http while maven lifecycle? any plugin?
If the file is a Maven dependency, you could use the Maven Dependency Plugin which has a get
goal.
For any file, you could use the Antrun plugin to call Ant's Get task.
Another option would be the maven-download-plugin, it has been precisely created to facilitate this kind of things. It's not very actively developed and the documentation only mentions an artifact
goal that does exactly the same thing as dependency:get
but.. If you look at the sources, you'll see that is has a WGet mojo that will do the job.
Get it from the subversion repository:
$ svn checkout http://maven-download-plugin.googlecode.com/svn/trunk/maven-download-plugin/ maven-download-plugin-read-only
Then cd into the directory to build the plugin:
$ cd maven-download-plugin-read-only
$ mvn install
And use it like this in any POM:
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>maven-download-plugin</artifactId>
<version>0.2-SNAPSHOT</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 -->
<targetDirectory>${project.build.directory}</targetDirectory>
</configuration>
</execution>
</executions>
</plugin>
To keep your build portable, the above plugin should be installed in a remote repository. If this is not possible and if you want your POM to be portable, consider using the Antrun plugin instead.