On 30/01/2012, at 8:32 AM, Daz DeBoer wrote:

> On 29 January 2012 14:30, GitHub <[email protected]> wrote:
>  Branch: refs/heads/master
>  Home:   https://github.com/gradle/gradle
>  Commit: 4d87844800c7b6277f8345d05c573b59ca2ef11e
>      
> https://github.com/gradle/gradle/commit/4d87844800c7b6277f8345d05c573b59ca2ef11e
>  Author: daz <[email protected]>
>  Date:   2012-01-29 (Sun, 29 Jan 2012)
> 
>  Changed paths:
>    M 
> subprojects/integ-test/src/integTest/groovy/org/gradle/integtests/resolve/maven/MavenSnapshotRemoteDependencyResolutionIntegrationTest.groovy
> 
>  Log Message:
>  -----------
>  Added integration test for locking and updating a snapshot artifact during 
> the same build process
> 
> 
> I'm using RandomAccessFile.channel.lock() to lock the snapshot artifact. 
> Anyone have an idea of how to make this more of a "real" file lock; the sort 
> that will prevent the file from being overwritten in windows?

You just need to open the file for reading, eg new FileInputStream(file) or new 
RandomAccessFile(file, "r"). You need to hang on to a reference to the file so 
that it doesn't get closed due to being garbage collected halfway through the 
test, and you'll need to close the file at the end of the test build, so that 
the test cleanup can delete the files.


--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Reply via email to