diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 0e83e16..6dda42c 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -42,13 +42,13 @@ tasks { // region publishing object Artifact { - val groupId = "co.uzzu.dotenv" - val artifactId = "gradle" - val version = "3.0.0" + const val GroupId = "co.uzzu.dotenv" + const val ArtifactId = "gradle" + const val Version = "3.0.0" } -group = Artifact.groupId -version = Artifact.version +group = Artifact.GroupId +version = Artifact.Version publishing { publishing { @@ -57,7 +57,7 @@ publishing { } publications.create("pluginMaven", MavenPublication::class) { - artifactId = Artifact.artifactId + artifactId = Artifact.ArtifactId } } } diff --git a/plugin/src/main/kotlin/co/uzzu/dotenv/DotEnvParser.kt b/plugin/src/main/kotlin/co/uzzu/dotenv/DotEnvParser.kt index 6ee288e..90117e7 100644 --- a/plugin/src/main/kotlin/co/uzzu/dotenv/DotEnvParser.kt +++ b/plugin/src/main/kotlin/co/uzzu/dotenv/DotEnvParser.kt @@ -1,7 +1,7 @@ package co.uzzu.dotenv object DotEnvParser { - private const val newLine = "\n" + private const val NewLine = "\n" private val newLinesRegex = Regex("""\\n""", option = RegexOption.MULTILINE) private val keyValRegex = Regex("""^\s*([\w.-]+)\s*=\s*(.*)?\s*$""") private val newLinesMatches = Regex("""\n|\r|\r\n""") @@ -23,7 +23,7 @@ object DotEnvParser { val trimmedValue = if (isDoubleQuoted || isSingleQuoted) { val dequoted = rawValue.substring(1, rawValue.lastIndex) if (isDoubleQuoted) { - dequoted.replace(newLinesRegex, newLine) + dequoted.replace(newLinesRegex, NewLine) } else { dequoted } diff --git a/plugin/src/main/kotlin/co/uzzu/dotenv/gradle/DotEnvProperties.kt b/plugin/src/main/kotlin/co/uzzu/dotenv/gradle/DotEnvProperties.kt index ff0f5ae..e328579 100644 --- a/plugin/src/main/kotlin/co/uzzu/dotenv/gradle/DotEnvProperties.kt +++ b/plugin/src/main/kotlin/co/uzzu/dotenv/gradle/DotEnvProperties.kt @@ -39,7 +39,7 @@ open class DotEnvRoot( fun fetch(name: String) = envProvider.getenv()[name] ?: dotenvMap[name] - ?: throw IllegalStateException("""Environment variable $name was not set.""") + ?: error("""Environment variable $name was not set.""") /** * @return An environment variable @@ -112,7 +112,7 @@ open class DotEnvProperty( get() = envProvider.getenv()[name] ?: dotenvValue - ?: throw IllegalStateException("""Environment variable $name was not set.""") + ?: error("""Environment variable $name was not set.""") /** * @return An environment variable. If it was not set, returns specified default value diff --git a/plugin/src/test/kotlin/co/uzzu/dotenv/DotEnvParserTest.kt b/plugin/src/test/kotlin/co/uzzu/dotenv/DotEnvParserTest.kt index fba569a..890a917 100644 --- a/plugin/src/test/kotlin/co/uzzu/dotenv/DotEnvParserTest.kt +++ b/plugin/src/test/kotlin/co/uzzu/dotenv/DotEnvParserTest.kt @@ -9,8 +9,8 @@ class DotEnvParserTest { @Test fun testBasicParse() { val text = """ - HOGE_API_KEY="dummy_key" - HOGE_API_SECRET="dummy_secret" + HOGE_API_KEY="dummy_key" + HOGE_API_SECRET="dummy_secret" """.trimIndent() val actual = DotEnvParser.parse(text) @@ -23,8 +23,8 @@ class DotEnvParserTest { @Test fun emptyValue() { val text = """ - HOGE_API_KEY= - HOGE_API_SECRET= + HOGE_API_KEY= + HOGE_API_SECRET= """.trimIndent() val actual = DotEnvParser.parse(text) @@ -37,8 +37,8 @@ class DotEnvParserTest { @Test fun quotedValue() { val text = """ - HOGE_API_KEY="dummy_key" - HOGE_API_SECRET='dummy_secret' + HOGE_API_KEY="dummy_key" + HOGE_API_SECRET='dummy_secret' """.trimIndent() val actual = DotEnvParser.parse(text) @@ -51,8 +51,8 @@ class DotEnvParserTest { @Test fun incompleteQuoteValue() { val text = """ - HOGE_API_KEY="dummy_key - HOGE_API_SECRET=dummy_secret' + HOGE_API_KEY="dummy_key + HOGE_API_SECRET=dummy_secret' """.trimIndent() val actual = DotEnvParser.parse(text) @@ -65,8 +65,8 @@ class DotEnvParserTest { @Test fun singleCharQuoteValue() { val text = """ - HOGE_API_KEY=" - HOGE_API_SECRET=' + HOGE_API_KEY=" + HOGE_API_SECRET=' """.trimIndent() val actual = DotEnvParser.parse(text) diff --git a/plugin/src/test/kotlin/co/uzzu/dotenv/gradle/HierarchicalDotEnvDefinitionsTest.kt b/plugin/src/test/kotlin/co/uzzu/dotenv/gradle/HierarchicalDotEnvDefinitionsTest.kt index 470eaf8..08a7a74 100644 --- a/plugin/src/test/kotlin/co/uzzu/dotenv/gradle/HierarchicalDotEnvDefinitionsTest.kt +++ b/plugin/src/test/kotlin/co/uzzu/dotenv/gradle/HierarchicalDotEnvDefinitionsTest.kt @@ -88,7 +88,7 @@ class HierarchicalDotEnvDefinitionsTest { file( ".env", """ - HOGE=100 + HOGE=100 """.trimIndent() ) directory("sub")