![JAR search and dependency download from the Maven repository](/logo.png)
com.freenow.sauron.plugins.protocw.DefaultChecker.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protocw-checker Show documentation
Show all versions of protocw-checker Show documentation
Sauron Protoc Wrapper Checker Plugin
The newest version!
package com.freenow.sauron.plugins.protocw
import arrow.core.Either
import arrow.core.extensions.fx
import arrow.core.rightIfNotNull
import com.freenow.sauron.plugins.ProtocwChecker
import java.nio.file.Paths
import java.util.Optional
class DefaultChecker(
private val service: Service,
private val protocValidator: Validator
) : Checker {
override fun apply(
repoPath: Optional,
protocwFileName: Optional,
protocwPropertiesFileName: Optional
): Either {
return Either.fx {
val repositoryPath = !repoPath.unWrap().rightIfNotNull { "${ProtocwChecker.INPUT_REPO_PATH} was not set" }
val repository = Paths.get(repositoryPath)
!protocValidator.check(repository).mapLeft { "Protocw not needed: $it" }
val protocwFile = repository.resolve(
protocwFileName.map { toString() }
.orElse("protocw")
)
val protocwPropertiesFile = repository.resolve(
protocwPropertiesFileName.map { toString() }
.orElse("protocw.properties")
)
service.check(protocwFile, protocwPropertiesFile)
}
}
}
private fun Optional.unWrap(): T? {
return orElse(null)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy