Skip to content

Commit e2ba1ac

Browse files
committed
PluginInfo script; use ruby blocks
Putting the File.open statements in blocks ensures the files are closed even if a problem occurs during processing. See scijava/incubator#12 (comment) Thanks @imagejan!
1 parent b817b59 commit e2ba1ac

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎pom.xml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@
126126
basedir = '${project.basedir}'.gsub /\\+/, '\\\\'
127127
sourceFile = basedir + '/target/classes/META-INF/json/org.scijava.plugin.Plugin'
128128
destFile = basedir + '/target/test-classes/META-INF/json/org.scijava.plugin.Plugin'
129-
input = File.open(sourceFile)
130-
data_to_copy = input.read()
131-
output = File.open(destFile, 'a')
132-
output.write(data_to_copy)
133-
input.close()
134-
output.close()
129+
File.open(sourceFile) do |input|
130+
data_to_copy = input.read()
131+
File.open(destFile, 'a') do |output|
132+
output.write(data_to_copy)
133+
end
134+
end
135135
</script>
136136
</configuration>
137137
</execution>

0 commit comments

Comments
 (0)