Skip to content

Commit 60125b6

Browse files
committed
simplify code
1 parent 480ae1a commit 60125b6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/ScriptRequestGenerator.groovy

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ScriptRequestGenerator implements Closeable {
5050
URL[] urlRoots = ([createWorkspaceUrl(filePath.parent)] + classpath) as URL[]
5151
ScriptRequest request = new ScriptRequest(
5252
readFile(filePath), urlRoots, ignoreExisting, getAbsolutePath(filePath),
53-
FilenameUtils.normalize(getAbsolutePath(workspace))
53+
getAbsolutePath(workspace)
5454
)
5555
scriptRequests.add(request)
5656
}
@@ -70,7 +70,7 @@ class ScriptRequestGenerator implements Closeable {
7070
@PackageScope
7171
static String getAbsolutePath(FilePath filePath) {
7272
// see JENKINS-33723
73-
filePath.getRemote()
73+
FilenameUtils.normalize(filePath.getRemote(), true)
7474
}
7575

7676
private URL createClasspathURL(FilePath filePath) {
@@ -95,10 +95,7 @@ class ScriptRequestGenerator implements Closeable {
9595
}
9696

9797
private URL createWorkspaceUrl(FilePath filePath) {
98-
// workspace and filePath may have differing separators in their common base
99-
String normalizedWorkspace = FilenameUtils.normalize(getAbsolutePath(workspace))
100-
String relativePath = getAbsolutePath(filePath) - normalizedWorkspace
101-
relativePath = relativePath.replaceAll('\\\\', '/') // normalize for Windows
98+
String relativePath = getAbsolutePath(filePath) - getAbsolutePath(workspace)
10299
String slash = filePath.directory ? '/' : ''
103100
new URL(createWorkspaceUrl(), "$relativePath$slash")
104101
}

0 commit comments

Comments
 (0)