Открыть боковую панель
Aurora OS
Kotlin Multiplatform
Libraries
ktor
Коммиты
69e2cabd
Не подтверждена
Коммит
69e2cabd
создал
Сен 23, 2024
по автору
Alexander Sysoev
Зафиксировано автором
GitHub
Сен 23, 2024
Просмотр файлов
Added Develocity plugin for build scans and remote build cache (#4311)
владелец
4e42dd51
Изменения
10
Скрыть пробелы
Построчно
Рядом
.gitignore
Просмотр файла @
69e2cabd
...
...
@@ -39,3 +39,5 @@ gradle-user-home
.fleet
.kotlin
scan-journal.log
docs/develocity.md
0 → 100644
Просмотр файла @
69e2cabd
# Develocity usage guide
> [!NOTE]
> Build scans and remote build cache are for JetBrains developers only.
>
> To disable publishing attempts, add `ktor.develocity.skipBuildScans=true` property
to your
`~/.gradle/gradle.properties`
file
Develocity is configured for this project.
That means that you can use both
[
build scans
](
https://docs.gradle.org/current/userguide/build_scans.html
)
and remote
[
build cache
](
https://docs.gradle.org/current/userguide/build_cache.html
)
features.
To use build scans, first you need to log in here: https://ge.jetbrains.com.
You can do that directly in Gradle:
```
Bash
./gradlew :provisionDevelocityAccessKey
```
Sing in with your Google work account, and that is it.
Now your scans will automatically be published after each build, and
Gradle will read the remote build caches so that your local build may be faster.
This also allows you to check various metrics about your scans (https://ge.jetbrains.com).
Build scan logs are collected locally in the
`scan-journal.log`
file.
gradle-settings-conventions/build.gradle.kts
0 → 100644
Просмотр файла @
69e2cabd
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
plugins
{
`kotlin-dsl`
}
repositories
{
mavenCentral
()
gradlePluginPortal
()
}
dependencies
{
implementation
(
"com.gradle:develocity-gradle-plugin:3.17"
)
implementation
(
"com.gradle:common-custom-user-data-gradle-plugin:2.0.1"
)
}
gradle-settings-conventions/settings.gradle.kts
0 → 100644
Просмотр файла @
69e2cabd
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
rootProject
.
name
=
"gradle-conventions-settings"
gradle-settings-conventions/src/main/kotlin/conventions-develocity.settings.gradle.kts
0 → 100644
Просмотр файла @
69e2cabd
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import
java.util.*
plugins
{
id
(
"com.gradle.develocity"
)
id
(
"com.gradle.common-custom-user-data-gradle-plugin"
)
}
develocity
{
val
startParameter
=
gradle
.
startParameter
val
scanJournal
=
File
(
settingsDir
,
"scan-journal.log"
)
server
=
DEVELOCITY_SERVER
buildScan
{
uploadInBackground
=
!
isCIRun
// obfuscate NIC since we don't want to expose user real IP (will be relevant without VPN)
obfuscation
{
ipAddresses
{
addresses
->
addresses
.
map
{
_
->
"0.0.0.0"
}
}
}
capture
{
fileFingerprints
=
true
}
buildScanPublished
{
scanJournal
.
appendText
(
"${Date()} — $buildScanUri — $startParameter\n"
)
}
val
skipBuildScans
=
settings
.
providers
.
gradleProperty
(
"ktor.develocity.skipBuildScans"
)
.
getOrElse
(
"false"
)
.
toBooleanStrict
()
publishing
.
onlyIf
{
!
skipBuildScans
}
}
}
buildCache
{
if
(
isCIRun
)
{
local
{
isEnabled
=
false
}
}
remote
(
develocity
.
buildCache
)
{
isPush
=
isCIRun
isEnabled
=
true
}
}
enrichTeamCityData
()
enrichGitData
()
gradle-settings-conventions/src/main/kotlin/customization.kt
0 → 100644
Просмотр файла @
69e2cabd
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import
com.gradle.develocity.agent.gradle.DevelocityConfiguration
import
org.gradle.api.initialization.Settings
fun
Settings
.
enrichTeamCityData
()
{
val
ge
=
extensions
.
getByType
(
DevelocityConfiguration
::
class
.
java
)
gradle
.
projectsEvaluated
{
if
(
isCIRun
)
{
val
buildTypeId
=
"teamcity.buildType.id"
val
buildId
=
"teamcity.build.id"
if
(
gradle
.
rootProject
.
hasProperty
(
buildId
)
&&
gradle
.
rootProject
.
hasProperty
(
buildTypeId
))
{
val
buildIdValue
=
gradle
.
rootProject
.
property
(
buildId
).
toString
()
val
teamCityBuildNumber
=
java
.
net
.
URLEncoder
.
encode
(
buildIdValue
,
"UTF-8"
)
val
teamCityBuildTypeId
=
gradle
.
rootProject
.
property
(
buildTypeId
)
ge
.
buildScan
.
link
(
"Ktor TeamCity build"
,
"${TEAMCITY_URL}/buildConfiguration/${teamCityBuildTypeId}/${teamCityBuildNumber}"
)
}
if
(
gradle
.
rootProject
.
hasProperty
(
buildId
))
{
ge
.
buildScan
.
value
(
"CI build id"
,
gradle
.
rootProject
.
property
(
buildId
)
as
String
)
}
}
}
}
fun
Settings
.
enrichGitData
()
{
val
ge
=
extensions
.
getByType
(
DevelocityConfiguration
::
class
.
java
)
val
skipGitTags
=
settings
.
providers
.
gradleProperty
(
"ktor.develocity.skipGitTags"
)
.
getOrElse
(
"false"
)
.
toBooleanStrict
()
gradle
.
projectsEvaluated
{
if
(!
isCIRun
&&
!
skipGitTags
)
{
// Git commit id
val
commitId
=
execute
(
"git rev-parse --verify HEAD"
)
if
(
commitId
.
isNotEmpty
())
{
ge
.
buildScan
.
value
(
"Git Commit ID"
,
commitId
)
ge
.
buildScan
.
link
(
"GitHub Commit Link"
,
"$GITHUB_REPO/tree/$commitId"
)
}
// Git branch name
val
branchName
=
execute
(
"git rev-parse --abbrev-ref HEAD"
)
if
(
branchName
.
isNotEmpty
())
{
ge
.
buildScan
.
value
(
"Git Branch Name"
,
branchName
)
ge
.
buildScan
.
link
(
"GitHub Branch Link"
,
"$GITHUB_REPO/tree/$branchName"
)
}
// Git dirty local state
val
status
=
execute
(
"git status --porcelain"
)
if
(
status
.
isNotEmpty
())
{
ge
.
buildScan
.
value
(
"Git Status"
,
status
)
}
}
}
}
gradle-settings-conventions/src/main/kotlin/execute.kt
0 → 100644
Просмотр файла @
69e2cabd
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import
org.gradle.api.initialization.Settings
@Suppress
(
"UnstableApiUsage"
)
fun
Settings
.
execute
(
cmd
:
String
):
String
{
return
settings
.
providers
.
exec
{
commandLine
(
cmd
.
split
(
" "
))
}.
standardOutput
.
asText
.
get
().
trim
()
}
gradle-settings-conventions/src/main/kotlin/params.kt
0 → 100644
Просмотр файла @
69e2cabd
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
const
val
DEVELOCITY_SERVER
=
"https://ge.jetbrains.com"
const
val
GITHUB_REPO
=
"https://github.com/ktorio/ktor"
const
val
TEAMCITY_URL
=
"https://ktor.teamcity.com"
val
isCIRun
=
System
.
getenv
(
"TEAMCITY_VERSION"
)
!=
null
gradle.properties
Просмотр файла @
69e2cabd
...
...
@@ -33,3 +33,11 @@ kotlin.daemon.useFallbackStrategy=false
# dokka
# workaround for resolving platform dependencies, see https://github.com/Kotlin/dokka/issues/3153
org.jetbrains.dokka.classpath.useNativeDistributionAccessor
=
true
# Uncomment to skip attempts to publish Develocity build scans
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#ktor.develocity.skipBuildScans=true
# Uncomment to skip adding git tags to Develocity build scan
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#ktor.develocity.skipGitTags=true
settings.gradle.kts
Просмотр файла @
69e2cabd
...
...
@@ -3,6 +3,8 @@
*/
pluginManagement
{
includeBuild
(
"gradle-settings-conventions"
)
repositories
{
mavenCentral
()
google
()
...
...
@@ -10,24 +12,12 @@ pluginManagement {
}
}
rootProject
.
name
=
"ktor"
val
CACHE_USER
=
System
.
getenv
(
"GRADLE_CACHE_USER"
)
if
(
CACHE_USER
!=
null
)
{
val
CACHE_PASSWORD
=
System
.
getenv
(
"GRADLE_CACHE_PASSWORD"
)
buildCache
{
remote
(
HttpBuildCache
::
class
)
{
isPush
=
true
setUrl
(
"https://ktor-gradle-cache.teamcity.com/cache/"
)
credentials
{
username
=
CACHE_USER
password
=
CACHE_PASSWORD
}
}
}
plugins
{
id
(
"conventions-develocity"
)
}
rootProject
.
name
=
"ktor"
val
fullVersion
=
System
.
getProperty
(
"java.version"
,
"8.0.0"
)
val
versionComponents
=
fullVersion
.
split
(
"."
)
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать