@@ -32,7 +32,6 @@ import org.gradle.api.internal.file.DefaultFileTreeElement
32
32
import org.gradle.api.internal.file.copy.CopyAction
33
33
import org.gradle.api.internal.file.copy.CopyActionProcessingStream
34
34
import org.gradle.api.internal.file.copy.FileCopyDetailsInternal
35
- import org.gradle.api.specs.Spec
36
35
import org.gradle.api.tasks.WorkResult
37
36
import org.gradle.api.tasks.bundling.Zip
38
37
import org.gradle.api.tasks.util.PatternSet
@@ -238,81 +237,26 @@ class JRubyJarCopyAction implements CopyAction {
238
237
239
238
@Override
240
239
void visitFile (FileCopyDetails fileDetails ) {
241
- if (! isArchive(fileDetails)) {
242
- try {
243
- boolean isClass = isClass(fileDetails)
244
- if (! remapper. hasRelocators() || ! isClass) {
245
- if (! isTransformable(fileDetails)) {
246
- String mappedPath = remapper. map(fileDetails. relativePath. pathString)
247
- ZipEntry archiveEntry = new ZipEntry (mappedPath)
248
- archiveEntry. setTime(getArchiveTimeFor(fileDetails. lastModified))
249
- archiveEntry. unixMode = (UnixStat . FILE_FLAG | fileDetails. mode)
250
- zipOutStr. putNextEntry(archiveEntry)
251
- fileDetails. copyTo(zipOutStr)
252
- zipOutStr. closeEntry()
253
- } else {
254
- transform(fileDetails)
255
- }
256
- } else if (isClass && ! isUnused(fileDetails. path)) {
257
- remapClass(fileDetails)
258
- }
259
- recordVisit(fileDetails. relativePath)
260
- } catch (Exception e) {
261
- throw new GradleException (String . format(" Could not add %s to ZIP '%s'." , fileDetails, zipFile), e)
262
- }
263
- } else {
264
- processArchive(fileDetails)
265
- }
266
- }
267
-
268
- private void processArchive (FileCopyDetails fileDetails ) {
269
- ZipFile archive = new ZipFile (fileDetails. file)
270
240
try {
271
- List<ArchiveFileTreeElement > archiveElements = archive. entries. collect {
272
- new ArchiveFileTreeElement (new RelativeArchivePath (it))
273
- }
274
- Spec<FileTreeElement > patternSpec = patternSet. asSpec
275
- List<ArchiveFileTreeElement > filteredArchiveElements = archiveElements. findAll { ArchiveFileTreeElement archiveElement ->
276
- patternSpec. isSatisfiedBy(archiveElement. asFileTreeElement())
277
- }
278
- filteredArchiveElements. each { ArchiveFileTreeElement archiveElement ->
279
- if (archiveElement. relativePath. file) {
280
- visitArchiveFile(archiveElement, archive)
281
- }
282
- }
283
- } finally {
284
- archive. close()
285
- }
286
- }
287
-
288
- private void visitArchiveDirectory (RelativeArchivePath archiveDir ) {
289
- if (recordVisit(archiveDir)) {
290
- zipOutStr. putNextEntry(archiveDir. entry)
291
- zipOutStr. closeEntry()
292
- }
293
- }
294
-
295
- private void visitArchiveFile (ArchiveFileTreeElement archiveFile , ZipFile archive ) {
296
- RelativeArchivePath archiveFilePath = archiveFile. relativePath
297
- if (archiveFile. classFile || ! isTransformable(archiveFile)) {
298
- if (recordVisit(archiveFilePath) && ! isUnused(archiveFilePath. entry. name)) {
299
- if (! remapper. hasRelocators() || ! archiveFile. classFile) {
300
- copyArchiveEntry(archiveFilePath, archive)
241
+ boolean isClass = isClass(fileDetails)
242
+ if (! remapper. hasRelocators() || ! isClass) {
243
+ if (! isTransformable(fileDetails)) {
244
+ String mappedPath = remapper. map(fileDetails. relativePath. pathString)
245
+ ZipEntry archiveEntry = new ZipEntry (mappedPath)
246
+ archiveEntry. setTime(getArchiveTimeFor(fileDetails. lastModified))
247
+ archiveEntry. unixMode = (UnixStat . FILE_FLAG | fileDetails. mode)
248
+ zipOutStr. putNextEntry(archiveEntry)
249
+ fileDetails. copyTo(zipOutStr)
250
+ zipOutStr. closeEntry()
301
251
} else {
302
- remapClass(archiveFilePath, archive )
252
+ transform(fileDetails )
303
253
}
254
+ } else if (isClass && ! isUnused(fileDetails. path)) {
255
+ remapClass(fileDetails)
304
256
}
305
- } else {
306
- transform(archiveFile, archive)
307
- }
308
- }
309
-
310
- private void addParentDirectories (RelativeArchivePath file ) {
311
- if (file) {
312
- addParentDirectories(file. parent)
313
- if (! file. file) {
314
- visitArchiveDirectory(file)
315
- }
257
+ recordVisit(fileDetails. relativePath)
258
+ } catch (Exception e) {
259
+ throw new GradleException (String . format(" Could not add %s to ZIP '%s'." , fileDetails, zipFile), e)
316
260
}
317
261
}
318
262
@@ -384,22 +328,6 @@ class JRubyJarCopyAction implements CopyAction {
384
328
}
385
329
}
386
330
387
- private void copyArchiveEntry (RelativeArchivePath archiveFile , ZipFile archive ) {
388
- String mappedPath = remapper. map(archiveFile. entry. name)
389
- ZipEntry entry = new ZipEntry (mappedPath)
390
- entry. setTime(getArchiveTimeFor(archiveFile. entry. time))
391
- RelativeArchivePath mappedFile = new RelativeArchivePath (entry)
392
- addParentDirectories(mappedFile)
393
- zipOutStr. putNextEntry(mappedFile. entry)
394
- InputStream is = archive. getInputStream(archiveFile. entry)
395
- try {
396
- IOUtils . copyLarge(is, zipOutStr)
397
- } finally {
398
- is. close()
399
- }
400
- zipOutStr. closeEntry()
401
- }
402
-
403
331
@Override
404
332
protected void visitDir (FileCopyDetails dirDetails ) {
405
333
try {
0 commit comments