我尝试使用 Mave-Wagon 插件通过 HTTP-GET 下载文件:
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http</artifactId>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>download-zip</id>
<phase>generate-sources</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>http://server.com/Download/</url>
<fromFile>FileDownload.aspx?param=asdf&param2=1234</fromFile>
<toDir>${project.build.directory}</toDir>
<toFile>targetfilename.zip</toFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
问题是?在目标文件名中,因为toFile
仅在下载发生后才应用。
当我通过普通浏览器下载 URL 时,浏览器也会给我一个“干净”且漂亮的文件名。Wagon-HTTP 是否忽略了这个 HTTP-Header?
有没有办法将参数传递给 URL 或让 Maven 使用另一个/清理过的文件名?
为了完整起见,整个例外是
Caused by: java.io.FileNotFoundException: Illegal Syntax in filename (sorry this is an translation)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
at org.apache.maven.wagon.LazyFileOutputStream.initialize(LazyFileOutputStream.java:154)
at org.apache.maven.wagon.LazyFileOutputStream.write(LazyFileOutputStream.java:126)
at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:492)
at org.apache.maven.wagon.AbstractWagon.getTransfer(AbstractWagon.java:328)
... 25 more