Skip to content

Commit

Permalink
Merge pull request #297 from hazendaz/spotbugs
Browse files Browse the repository at this point in the history
Revert fix #238 and correctly handle windows as it was only handling linux type line endings
  • Loading branch information
hazendaz committed Jan 3, 2021
2 parents b640b35 + 66fe09c commit 21d6a0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/main/groovy/org/codehaus/mojo/spotbugs/ResourceHelper.groovy
Expand Up @@ -25,8 +25,6 @@ import org.codehaus.plexus.resource.loader.FileResourceLoader
import org.codehaus.plexus.resource.ResourceManager
import org.codehaus.plexus.util.FileUtils

import java.nio.file.Paths

final class ResourceHelper {

Log log
Expand Down Expand Up @@ -55,11 +53,22 @@ final class ResourceHelper {
String location = null
String artifact = resource

def file = new File(resource)
// Linux Checks
if (resource.indexOf(SpotBugsInfo.FORWARD_SLASH) != -1) {
artifact = resource.substring(resource.lastIndexOf(SpotBugsInfo.FORWARD_SLASH) + 1)
}

if (resource.indexOf(SpotBugsInfo.FORWARD_SLASH) != -1) {
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 (file.exists()) {
artifact = file.getName()
location = file.getAbsolutePath()
if (resource.indexOf(SpotBugsInfo.BACKWARD_SLASH) != -1) {
location = resource.substring(0, resource.lastIndexOf(SpotBugsInfo.BACKWARD_SLASH))
}

// replace all occurrences of the following characters: ? : & =
Expand Down
Expand Up @@ -77,6 +77,10 @@ interface SpotBugsInfo {

static final String COMMA = ","

static final String FORWARD_SLASH = '/'

static final String BACKWARD_SLASH = '\\'

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

0 comments on commit 21d6a0a

Please sign in to comment.