Skip to content

Commit

Permalink
[windows] Add fix to support processing properly on windows by not en…
Browse files Browse the repository at this point in the history
…ding up with long c_ path to jar files

Fix on spotbugs#238 only resulted in cleaning up unnecessary copies but made other processing worse.  As a result, spotbugs#238 is being reverted.  This patch is to make windows usage behave like linux usage.  It still expected to copy the jar files (even if unnecessary) but not nexted into a deep folder structure, rather just the artifact name.  The original logic did not handle windows at all.  It now does but is still not a great solution.
  • Loading branch information
hazendaz committed Jan 3, 2021
1 parent e49c190 commit 66fe09c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/groovy/org/codehaus/mojo/spotbugs/ResourceHelper.groovy
Expand Up @@ -53,6 +53,7 @@ final class ResourceHelper {
String location = null
String artifact = resource

// Linux Checks
if (resource.indexOf(SpotBugsInfo.FORWARD_SLASH) != -1) {
artifact = resource.substring(resource.lastIndexOf(SpotBugsInfo.FORWARD_SLASH) + 1)
}
Expand All @@ -61,6 +62,15 @@ final class ResourceHelper {
location = resource.substring(0, resource.lastIndexOf(SpotBugsInfo.FORWARD_SLASH))
}

// Windows Checks
if (resource.indexOf(SpotBugsInfo.BACKWARD_SLASH) != -1) {
artifact = resource.substring(resource.lastIndexOf(SpotBugsInfo.BACKWARD_SLASH) + 1)
}

if (resource.indexOf(SpotBugsInfo.BACKWARD_SLASH) != -1) {
location = resource.substring(0, resource.lastIndexOf(SpotBugsInfo.BACKWARD_SLASH))
}

// replace all occurrences of the following characters: ? : & =
location = location?.replaceAll("[\\?\\:\\&\\=\\%]", "_")
artifact = artifact?.replaceAll("[\\?\\:\\&\\=\\%]", "_")
Expand Down
Expand Up @@ -79,6 +79,8 @@ interface SpotBugsInfo {

static final String FORWARD_SLASH = '/'

static final String BACKWARD_SLASH = '\\'

/**
* The character to separate URL tokens.
*
Expand Down

0 comments on commit 66fe09c

Please sign in to comment.