Skip to content

Commit 21d6a0a

Browse files
authored
Merge pull request #297 from hazendaz/spotbugs
Revert fix #238 and correctly handle windows as it was only handling linux type line endings
2 parents b640b35 + 66fe09c commit 21d6a0a

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/main/groovy/org/codehaus/mojo/spotbugs/ResourceHelper.groovy

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import org.codehaus.plexus.resource.loader.FileResourceLoader
2525
import org.codehaus.plexus.resource.ResourceManager
2626
import org.codehaus.plexus.util.FileUtils
2727

28-
import java.nio.file.Paths
29-
3028
final class ResourceHelper {
3129

3230
Log log
@@ -55,11 +53,22 @@ final class ResourceHelper {
5553
String location = null
5654
String artifact = resource
5755

58-
def file = new File(resource)
56+
// Linux Checks
57+
if (resource.indexOf(SpotBugsInfo.FORWARD_SLASH) != -1) {
58+
artifact = resource.substring(resource.lastIndexOf(SpotBugsInfo.FORWARD_SLASH) + 1)
59+
}
60+
61+
if (resource.indexOf(SpotBugsInfo.FORWARD_SLASH) != -1) {
62+
location = resource.substring(0, resource.lastIndexOf(SpotBugsInfo.FORWARD_SLASH))
63+
}
64+
65+
// Windows Checks
66+
if (resource.indexOf(SpotBugsInfo.BACKWARD_SLASH) != -1) {
67+
artifact = resource.substring(resource.lastIndexOf(SpotBugsInfo.BACKWARD_SLASH) + 1)
68+
}
5969

60-
if (file.exists()) {
61-
artifact = file.getName()
62-
location = file.getAbsolutePath()
70+
if (resource.indexOf(SpotBugsInfo.BACKWARD_SLASH) != -1) {
71+
location = resource.substring(0, resource.lastIndexOf(SpotBugsInfo.BACKWARD_SLASH))
6372
}
6473

6574
// replace all occurrences of the following characters: ? : & =

src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsInfo.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ interface SpotBugsInfo {
7777

7878
static final String COMMA = ","
7979

80+
static final String FORWARD_SLASH = '/'
81+
82+
static final String BACKWARD_SLASH = '\\'
83+
8084
/**
8185
* The character to separate URL tokens.
8286
*

0 commit comments

Comments
 (0)