After publishing artifacts with maven-publish using http or https protovol all transfered files remain open by the process. If it runs as a gradle daemon under windows OS the files can not be deleted unless the daemon is stopped.
To reproduce the problem consider the following gradle script:
plugins.apply 'maven-publish'
group = 'my.gradle.test.group'
version = "0.0_SNAPSHOT"
def file = file("${project.buildDir}/publishedFile.txt")
file.parentFile.mkdirs()
file.write 'content'
publishing {
publications {
mavenCustom(MavenPublication) { MavenPublication publication ->
publication.artifactId = 'artifact'
publication.artifact file.absolutePath
}
}
}
publishing {
repositories {
maven {
url 'http://build1.intern/nexus/content/repositories/snapshots/'
credentials {
username System.getenv('NEXUS_USER')
password System.getenv('NEXUS_PASS')
}
}
}
}
task 'publishAndCleanUp'
publishAndCleanUp.doLast {
file.delete()
if(file.exists())
throw new GradleException ("${file.path} exists after deletion")
}
publishAndCleanUp.dependsOn publish
Running task publishAndCleanUp under Windows cause the exception to be thrown because the file is still open when file.delete() is called. Not only the artifact file but also other files transfered to server like maven-metadata-remote.xml remain blocked after publish is executed
The problem is caused by method
org.gradle.internal.resource.transport.http.RepeatableInputStreamEntity.writeTo
which opens file streams and never closes them.