![JAR search and dependency download from the Maven repository](/logo.png)
com.freenow.sauron.plugins.protocw.DefaultValidator.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 java.nio.file.Files
import java.nio.file.Path
class DefaultValidator : Validator {
override fun check(repository: Path): Either {
return Either.fx {
!checkRepositoryExists(repository)
!checkNeedsProtoc(repository)
Unit
}
}
private fun checkRepositoryExists(repository: Path): Either {
return Either.cond(Files.isDirectory(repository),
{ Unit },
{ "Repository is not a directory" }
)
}
private fun checkNeedsProtoc(repository: Path): Either {
return Either.fx {
val pom = repository.resolve("pom.xml")
val reader = !Either.cond(Files.exists(pom),
{ Files.newBufferedReader(pom) },
{ "POM does not exist" }
)
!Either.cond(reader.lines().anyMatch { it.contains("protobuf-maven-plugin") },
{ Unit },
{ "Has no protobuf-maven-plugin plugin" }
)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy