-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Displaying warn
level messages for file collisions
#126
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -132,7 +132,7 @@ public class ShadowCopyAction implements CopyAction { | |
private final PatternSet patternSet | ||
private final ShadowStats stats | ||
|
||
private Set<String> visitedFiles = new HashSet<String>() | ||
private Map<String, Map> visitedFiles = new HashMap<String, Map>() | ||
|
||
public StreamAction(ZipOutputStream zipOutStr, List<Transformer> transformers, List<Relocator> relocators, | ||
PatternSet patternSet, ShadowStats stats) { | ||
|
@@ -157,8 +157,25 @@ public class ShadowCopyAction implements CopyAction { | |
fileDetails.relativePath.pathString.endsWith('.zip') | ||
} | ||
|
||
private boolean recordVisit(RelativePath path) { | ||
return visitedFiles.add(path.pathString) | ||
private boolean recordVisit(path, size, originJar) { | ||
if (visitedFiles.containsKey(path.toString())) { | ||
return false | ||
} | ||
|
||
if (originJar == null) { | ||
originJar = "" | ||
} | ||
|
||
visitedFiles.put(path.toString(), [size: size, originJar: originJar]) | ||
return true | ||
} | ||
|
||
private boolean recordVisit(path) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Argument typing. |
||
return recordVisit(path.toString(), 0, null) | ||
} | ||
|
||
private boolean recordVisit(FileCopyDetails fileCopyDetails) { | ||
return recordVisit(fileCopyDetails.relativePath, fileCopyDetails.size, null) | ||
} | ||
|
||
private void visitFile(FileCopyDetails fileDetails) { | ||
|
@@ -180,7 +197,7 @@ public class ShadowCopyAction implements CopyAction { | |
} else if (isClass) { | ||
remapClass(fileDetails) | ||
} | ||
recordVisit(fileDetails.relativePath) | ||
recordVisit(fileDetails) | ||
} catch (Exception e) { | ||
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e) | ||
} | ||
|
@@ -201,29 +218,41 @@ public class ShadowCopyAction implements CopyAction { | |
} | ||
filteredArchiveElements.each { ArchiveFileTreeElement archiveElement -> | ||
if (archiveElement.relativePath.file) { | ||
visitArchiveFile(archiveElement, archive) | ||
visitArchiveFile(archiveElement, archive, fileDetails) | ||
} | ||
} | ||
archive.close() | ||
stats.finishJar() | ||
} | ||
|
||
private void visitArchiveDirectory(RelativeArchivePath archiveDir) { | ||
if (recordVisit(archiveDir)) { | ||
if (recordVisit(archiveDir.toString())) { | ||
zipOutStr.putNextEntry(archiveDir.entry) | ||
zipOutStr.closeEntry() | ||
} | ||
} | ||
|
||
private void visitArchiveFile(ArchiveFileTreeElement archiveFile, ZipFile archive) { | ||
private void visitArchiveFile(ArchiveFileTreeElement archiveFile, ZipFile archive, FileCopyDetails fileDetails) { | ||
def archiveFilePath = archiveFile.relativePath | ||
def archiveFileSize = archiveFile.size | ||
|
||
if (archiveFile.classFile || !isTransformable(archiveFile)) { | ||
if (recordVisit(archiveFilePath)) { | ||
if (recordVisit(archiveFilePath.toString(), archiveFileSize, fileDetails.relativePath)) { | ||
if (!remapper.hasRelocators() || !archiveFile.classFile) { | ||
copyArchiveEntry(archiveFilePath, archive) | ||
} else { | ||
remapClass(archiveFilePath, archive) | ||
} | ||
} else { | ||
def archiveFileInVisitedFiles = visitedFiles.get(archiveFilePath.toString()) | ||
if (archiveFileInVisitedFiles && (archiveFileInVisitedFiles.size != fileDetails.size)) { | ||
log.warn("IGNORING ${archiveFilePath} from ${fileDetails.relativePath}, size is different (${fileDetails.size} vs ${archiveFileInVisitedFiles.size})") | ||
if (archiveFileInVisitedFiles.originJar) { | ||
log.warn(" --> origin JAR was ${archiveFileInVisitedFiles.originJar}") | ||
} else { | ||
log.warn(" --> file originated from project sourcecode") | ||
} | ||
} | ||
} | ||
} else { | ||
transform(archiveFile, archive) | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please using typing on arguments.