-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#194 Overwrite file if overwrite=true regardless of skipCache
- Loading branch information
1 parent
05a6dc7
commit 8910347
Showing
4 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
invoker.goals = clean verify | ||
invoker.buildResult = success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<!-- Build description --> | ||
<groupId>com.googlecode.maven-download-plugin.it</groupId> | ||
<artifactId>testBasic</artifactId> | ||
<packaging>pom</packaging> | ||
<version>${testing.versionUnderTest}</version> | ||
<name>Test</name> | ||
|
||
<!-- Build plugins and extensions --> | ||
<build> | ||
<plugins> | ||
<!-- Download the file first time --> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<id>first-download</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>wget</goal> | ||
</goals> | ||
<configuration> | ||
<url>${test.img.file.url}</url> | ||
<skipCache>true</skipCache> | ||
<overwrite>true</overwrite> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- | ||
Store last modification timestamp of downloaded file into 'stamp' file | ||
to be compared on verification stage. | ||
--> | ||
<plugin> | ||
<groupId>org.codehaus.gmavenplus</groupId> | ||
<artifactId>gmavenplus-plugin</artifactId> | ||
<version>1.5</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.codehaus.groovy</groupId> | ||
<artifactId>groovy</artifactId> | ||
<version>3.0.8</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
<executions> | ||
<execution> | ||
<id>save-timestamp</id> | ||
<phase>process-resources</phase> | ||
<goals> | ||
<goal>execute</goal> | ||
</goals> | ||
<configuration> | ||
<properties> | ||
<target>${project.build.directory}</target> | ||
<testfilename>${test.img.file.name}</testfilename> | ||
</properties> | ||
<scripts> | ||
<script> | ||
<![CDATA[ | ||
File file = new File(target, testfilename); | ||
File stamp = new File(target, "stamp"); | ||
stamp << file.lastModified(); | ||
assert true; | ||
]]> | ||
</script> | ||
</scripts> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- Download the file second time --> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<id>second-download</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>wget</goal> | ||
</goals> | ||
<configuration> | ||
<url>${test.img.file.url}</url> | ||
<skipCache>false</skipCache> | ||
<overwrite>true</overwrite> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Covers the bug https://github.com/maven-download-plugin/maven-download-plugin/issues/194 | ||
* | ||
* Scenario: | ||
* Given plugin configuration: | ||
* - skipCache = false (default) | ||
* - overwrite = true | ||
* - no checksum specified | ||
* When Run the plugin to download the zip | ||
* And Save timestamp into "stamp" file | ||
* And Run the plugin to download the same zip | ||
* Then the file should be overwritten | ||
* | ||
* `img_file_name` is injected through scriptVariables | ||
*/ | ||
File target = new File(basedir, "target") | ||
File zip = new File(target, img_file_name) | ||
assert zip.exists() | ||
File stamp = new File(target, "stamp") | ||
assert stamp.exists() : "Timestamp file should exist" | ||
assert stamp.text != String.valueOf(zip.lastModified()) : "File expected to be modified but it wasn't" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters