Skip to content

Commit

Permalink
chore: Close read stream of local.properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrylo committed Nov 15, 2023
1 parent 61db3d9 commit 6cd1bdd
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/

import java.util.Properties

pluginManagement {
Expand Down Expand Up @@ -28,18 +47,22 @@ dependencyResolutionManagement {
credentials {
val localProperties = loadLocalProperties()

username = System.getenv("GPR_USERNAME") ?: localProperties.getProperty("gpr.user")
password = System.getenv("GPR_TOKEN") ?: localProperties.getProperty("gpr.key")
username = System.getenv("GPR_USERNAME") ?: localProperties?.getProperty("gpr.user")
password = System.getenv("GPR_TOKEN") ?: localProperties?.getProperty("gpr.key")
}
}
}
}

include(":app")

fun loadLocalProperties(): Properties {
return Properties().apply {
val localProperties = file("$rootDir/local.properties")
load(localProperties.reader())
fun loadLocalProperties(): Properties? {
val localProperties = file("$rootDir/local.properties")
if (!localProperties.exists()) return null

localProperties.reader().use { reader ->
return Properties().apply {
load(reader)
}
}
}

0 comments on commit 6cd1bdd

Please sign in to comment.