Skip to content

Commit 58e7402

Browse files
committed
Pull request comments. Formatting and simplification.
1 parent 45a8487 commit 58e7402

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

shared/src/main/kotlin/org/javacs/kt/classpath/MavenClassPathResolver.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ private val mvnCommandFromPath: Path? by lazy {
130130
findCommandOnPath("mvn")
131131
}
132132

133-
private fun mvnCommand(pom : Path) : Path {
134-
return requireNotNull(mvnCommandFromPath ?: findProjectCommandWithName("mvnw", pom)?.also {
135-
LOG.info("Using mvn wrapper (mvnw) in place of mvn command")
136-
}) { "Unable to find the 'mvn' command or suitable wrapper" }
133+
private fun mvnCommand(pom: Path): Path {
134+
return requireNotNull(mvnCommandFromPath ?: findProjectCommandWithName("mvnw", pom)?.also {
135+
LOG.info("Using mvn wrapper (mvnw) in place of mvn command")
136+
}) { "Unable to find the 'mvn' command or suitable wrapper" }
137137
}
138138

139139
fun parseMavenArtifact(rawArtifact: String, version: String? = null): Artifact {

shared/src/main/kotlin/org/javacs/kt/util/ShellPathUtils.kt

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,16 @@ private fun findExecutableOnPath(fileName: String): Path? {
3434
return null
3535
}
3636

37-
fun findProjectCommandWithName(name : String, projectFile : Path) : Path? {
38-
if(isOSWindows()) {
39-
return findFileRelativeToProjectFile("$name.cmd", projectFile)
40-
} else {
41-
return findFileRelativeToProjectFile(name, projectFile)
42-
}
43-
}
37+
fun findProjectCommandWithName(name: String, projectFile: Path): Path? =
38+
if (isOSWindows()) {
39+
findFileRelativeToProjectFile("$name.cmd", projectFile)
40+
} else {
41+
findFileRelativeToProjectFile(name, projectFile)
42+
}
4443

45-
private fun findFileRelativeToProjectFile(name : String, projectFile : Path) : Path? {
46-
return projectFile.resolveSibling(name).toFile().takeIf { file ->
47-
file.isFile && file.canExecute()
48-
}?.let { file ->
49-
Paths.get(file.absolutePath)
50-
}
51-
}
44+
private fun findFileRelativeToProjectFile(name: String, projectFile: Path): Path? =
45+
projectFile.resolveSibling(name).toFile().takeIf { file ->
46+
file.isFile && file.canExecute()
47+
}?.let { file ->
48+
Paths.get(file.absolutePath)
49+
}

0 commit comments

Comments
 (0)