[Build, IGS] Don't run a separate thread as it leads to problems with user input

#KTI-1223 In Progress
This commit is contained in:
Alexander.Likhachev
2023-05-10 20:20:30 +02:00
committed by Space Team
parent 1e583d2946
commit ecbf5abb81
@@ -13,7 +13,6 @@ import org.gradle.kotlin.dsl.extra
import java.net.SocketTimeoutException
import java.net.URL
import java.net.UnknownHostException
import kotlin.concurrent.thread
private const val DOMAIN_NAME = "kotlin-build-properties.labs.jb.gg"
private const val SETUP_JSON_URL = "https://$DOMAIN_NAME/setup.json"
@@ -27,35 +26,30 @@ abstract class InternalGradleSetupSettingsPlugin : Plugin<Settings> {
log.info("TeamCity build detected. Skipping automatic local.properties configuration")
return
}
val rootDir = target.rootDir
// invoke this logic in a separate thread to not pause the build
// the properties will be configured for the future builds
thread {
try {
val modifier = LocalPropertiesModifier(rootDir.resolve("local.properties"))
val consentManager = ConsentManager(modifier)
val initialDecision = consentManager.getUserDecision()
if (initialDecision == false) {
log.debug("Skipping automatic local.properties configuration as you've opted out")
return@thread
}
val connection = URL(SETUP_JSON_URL).run { openConnection().apply { connectTimeout = 300 } }
val setupFile = connection.getInputStream().buffered().use {
parseSetupFile(it)
}
if (initialDecision == null && !consentManager.askForConsent()) {
log.debug("Skipping automatic local.properties configuration as the consent wasn't given")
return@thread
}
modifier.applySetup(setupFile)
log.info("Automatic local.properties setup has been applied.")
} catch (e: UnknownHostException) {
log.debug("Cannot connect to the internal properties storage", e)
} catch (e: SocketTimeoutException) {
log.debug("Cannot connect to the internal properties storage", e)
} catch (e: Throwable) {
log.warn("Something went wrong during the automatic local.properties setup attempt", e)
try {
val modifier = LocalPropertiesModifier(target.rootDir.resolve("local.properties"))
val consentManager = ConsentManager(modifier)
val initialDecision = consentManager.getUserDecision()
if (initialDecision == false) {
log.debug("Skipping automatic local.properties configuration as you've opted out")
return
}
val connection = URL(SETUP_JSON_URL).run { openConnection().apply { connectTimeout = 300 } }
val setupFile = connection.getInputStream().buffered().use {
parseSetupFile(it)
}
if (initialDecision == null && !consentManager.askForConsent()) {
log.debug("Skipping automatic local.properties configuration as the consent wasn't given")
return
}
modifier.applySetup(setupFile)
log.info("Automatic local.properties setup has been applied.")
} catch (e: UnknownHostException) {
log.debug("Cannot connect to the internal properties storage", e)
} catch (e: SocketTimeoutException) {
log.debug("Cannot connect to the internal properties storage", e)
} catch (e: Throwable) {
log.warn("Something went wrong during the automatic local.properties setup attempt", e)
}
}
}