diff --git a/utils/src/main/kotlin/com/bytelegend/utils/CheckLicenses.kt b/utils/src/main/kotlin/com/bytelegend/utils/CheckLicenses.kt index c403963b..69637f8c 100644 --- a/utils/src/main/kotlin/com/bytelegend/utils/CheckLicenses.kt +++ b/utils/src/main/kotlin/com/bytelegend/utils/CheckLicenses.kt @@ -16,6 +16,7 @@ package com.bytelegend.utils +import org.apache.commons.io.FilenameUtils import org.springframework.util.AntPathMatcher import java.io.File import java.io.IOException @@ -53,18 +54,20 @@ internal val INCLUDED_PATHS = listOf( ) internal val MATCHER = AntPathMatcher() +internal fun Path.unixStyle(): String = FilenameUtils.separatorsToUnix(this.toString()) + internal fun Path.isIgnoredPath(): Boolean = IGNORED_PATHS.any { // Remove leading "./" require(!this.isAbsolute) { "$this must be relative!" } - if (this.toString() == ".") { + if (this.unixStyle() == ".") { return false } - MATCHER.match(it, this.toString().substring(2)) + MATCHER.match(it, this.unixStyle().substring(2)) } internal fun Path.isIncludedPath() = INCLUDED_PATHS.any { // Remove leading "./" - MATCHER.match(it, this.toString().substring(2)) + MATCHER.match(it, this.unixStyle().substring(2)) } internal fun File.parseLicense() = when { diff --git a/utils/utils.gradle.kts b/utils/utils.gradle.kts index 6f4d1a04..4779809a 100644 --- a/utils/utils.gradle.kts +++ b/utils/utils.gradle.kts @@ -50,6 +50,7 @@ dependencies { implementation(libs("commonmark")) implementation(libs("commonmark-ext-task-list-items")) implementation(libs("animated-gif-lib-for-java")) + implementation(libs("commons-io")) testImplementation(libs("junit-jupiter-api")) testImplementation(libs("junit-jupiter-engine"))