[Gradle IT] Separated adding repositories block and dependencyManagement
In Gradle, there is a bug that leads to race condition, when we use ivy repo in the settings file. This bug was solved only in 8.1, so we supported dependencyManagement in our IT only since 8.1. For Gradle less 8.1 we just add the same repos to build script. ^KT-65708 Fixed
This commit is contained in:
committed by
Space Team
parent
85399bc969
commit
70a887e3ba
+6
-1
@@ -183,7 +183,12 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
|
|||||||
@DisplayName("with instance execution")
|
@DisplayName("with instance execution")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testInstantExecution(gradleVersion: GradleVersion) {
|
fun testInstantExecution(gradleVersion: GradleVersion) {
|
||||||
project("instantExecution", gradleVersion) {
|
project(
|
||||||
|
"instantExecution",
|
||||||
|
gradleVersion,
|
||||||
|
// we can remove this line, when the min version of Gradle be at least 8.1
|
||||||
|
dependencyManagement = DependencyManagement.DisabledDependencyManagement
|
||||||
|
) {
|
||||||
testConfigurationCacheOf(
|
testConfigurationCacheOf(
|
||||||
"assemble",
|
"assemble",
|
||||||
executedTaskNames = listOf(":lib-project:compileKotlin")
|
executedTaskNames = listOf(":lib-project:compileKotlin")
|
||||||
|
|||||||
+5
-1
@@ -1188,7 +1188,11 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
@DisplayName("KT-57531: Kotlin Native Link with cycle in dependency constraints")
|
@DisplayName("KT-57531: Kotlin Native Link with cycle in dependency constraints")
|
||||||
fun `test Kotlin Native Link with cycle in dependency constraints`(gradleVersion: GradleVersion) {
|
fun `test Kotlin Native Link with cycle in dependency constraints`(gradleVersion: GradleVersion) {
|
||||||
project("kt-57531-KotlinNativeLink-with-cycle-in-dependency-constraints", gradleVersion) {
|
project(
|
||||||
|
"kt-57531-KotlinNativeLink-with-cycle-in-dependency-constraints",
|
||||||
|
gradleVersion,
|
||||||
|
localRepoDir = defaultLocalRepo(gradleVersion)
|
||||||
|
) {
|
||||||
build("publish")
|
build("publish")
|
||||||
build("assemble") {
|
build("assemble") {
|
||||||
assertTasksExecuted(":consumer:linkDebugExecutableLinuxX64")
|
assertTasksExecuted(":consumer:linkDebugExecutableLinuxX64")
|
||||||
|
|||||||
+12
-2
@@ -1554,7 +1554,12 @@ class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
|
|||||||
@DisplayName("test FAIL_ON_PROJECT_REPOS using custom repository")
|
@DisplayName("test FAIL_ON_PROJECT_REPOS using custom repository")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testFailOnProjectReposUsingCustomRepo(gradleVersion: GradleVersion) {
|
fun testFailOnProjectReposUsingCustomRepo(gradleVersion: GradleVersion) {
|
||||||
project("js-project-repos", gradleVersion) {
|
project(
|
||||||
|
"js-project-repos",
|
||||||
|
gradleVersion,
|
||||||
|
// we can remove this line, when the min version of Gradle be at least 8.1
|
||||||
|
dependencyManagement = DependencyManagement.DisabledDependencyManagement
|
||||||
|
) {
|
||||||
settingsGradleKts.modify {
|
settingsGradleKts.modify {
|
||||||
it + """
|
it + """
|
||||||
|
|
||||||
@@ -1601,7 +1606,12 @@ class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
|
|||||||
@DisplayName("test FAIL_ON_PROJECT_REPOS no download")
|
@DisplayName("test FAIL_ON_PROJECT_REPOS no download")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testFailOnProjectReposNoDownload(gradleVersion: GradleVersion) {
|
fun testFailOnProjectReposNoDownload(gradleVersion: GradleVersion) {
|
||||||
project("js-project-repos", gradleVersion) {
|
project(
|
||||||
|
"js-project-repos",
|
||||||
|
gradleVersion,
|
||||||
|
// we can remove this line, when the min version of Gradle be at least 8.1
|
||||||
|
dependencyManagement = DependencyManagement.DisabledDependencyManagement
|
||||||
|
) {
|
||||||
buildGradleKts.modify {
|
buildGradleKts.modify {
|
||||||
it + """
|
it + """
|
||||||
|
|
||||||
|
|||||||
+2
@@ -24,6 +24,8 @@ class ProjectIsolationIT : KGPBaseTest() {
|
|||||||
project(
|
project(
|
||||||
projectName = "instantExecution",
|
projectName = "instantExecution",
|
||||||
gradleVersion = gradleVersion,
|
gradleVersion = gradleVersion,
|
||||||
|
// we can remove this line, when the min version of Gradle be at least 8.1
|
||||||
|
dependencyManagement = DependencyManagement.DisabledDependencyManagement
|
||||||
) {
|
) {
|
||||||
build(":main-project:compileKotlin")
|
build(":main-project:compileKotlin")
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -141,7 +141,7 @@ class MppCompositeBuildIT : KGPBaseTest() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
fun `test - sample1 - ide dependencies`(gradleVersion: GradleVersion) {
|
fun `test - sample1 - ide dependencies`(gradleVersion: GradleVersion) {
|
||||||
project("mpp-composite-build/sample1", gradleVersion) {
|
project("mpp-composite-build/sample1", gradleVersion) {
|
||||||
projectPath.resolve("included-build").addDefaultSettingsToSettingsGradle()
|
projectPath.resolve("included-build").addDefaultSettingsToSettingsGradle(gradleVersion)
|
||||||
buildGradleKts.replaceText("<kgp_version>", KOTLIN_VERSION)
|
buildGradleKts.replaceText("<kgp_version>", KOTLIN_VERSION)
|
||||||
projectPath.resolve("included-build/build.gradle.kts").replaceText("<kgp_version>", KOTLIN_VERSION)
|
projectPath.resolve("included-build/build.gradle.kts").replaceText("<kgp_version>", KOTLIN_VERSION)
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ class MppCompositeBuildIT : KGPBaseTest() {
|
|||||||
"mpp-composite-build/sample1",
|
"mpp-composite-build/sample1",
|
||||||
gradleVersion,
|
gradleVersion,
|
||||||
) {
|
) {
|
||||||
projectPath.resolve("included-build").addDefaultSettingsToSettingsGradle()
|
projectPath.resolve("included-build").addDefaultSettingsToSettingsGradle(gradleVersion)
|
||||||
buildGradleKts.replaceText("<kgp_version>", KOTLIN_VERSION)
|
buildGradleKts.replaceText("<kgp_version>", KOTLIN_VERSION)
|
||||||
projectPath.resolve("included-build/build.gradle.kts").replaceText("<kgp_version>", KOTLIN_VERSION)
|
projectPath.resolve("included-build/build.gradle.kts").replaceText("<kgp_version>", KOTLIN_VERSION)
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ class MppCompositeBuildIT : KGPBaseTest() {
|
|||||||
reason = "KGP 1.7.21 produces deprecation warnings with Gradle 8.4"
|
reason = "KGP 1.7.21 produces deprecation warnings with Gradle 8.4"
|
||||||
) { gradleVersion >= GradleVersion.version(TestVersions.Gradle.G_8_4) }
|
) { gradleVersion >= GradleVersion.version(TestVersions.Gradle.G_8_4) }
|
||||||
) {
|
) {
|
||||||
projectPath.resolve("included-build").addDefaultSettingsToSettingsGradle()
|
projectPath.resolve("included-build").addDefaultSettingsToSettingsGradle(gradleVersion)
|
||||||
buildGradleKts.replaceText("<kgp_version>", KOTLIN_VERSION)
|
buildGradleKts.replaceText("<kgp_version>", KOTLIN_VERSION)
|
||||||
projectPath.resolve("included-build/build.gradle.kts").replaceText("<kgp_version>", "1.7.21")
|
projectPath.resolve("included-build/build.gradle.kts").replaceText("<kgp_version>", "1.7.21")
|
||||||
|
|
||||||
|
|||||||
+184
-175
@@ -75,94 +75,99 @@ internal fun getGroovyDependencyManagementBlock(
|
|||||||
): String =
|
): String =
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
"""
|
"""
|
||||||
dependencyResolutionManagement {
|
|dependencyResolutionManagement {
|
||||||
repositories {
|
| ${getGroovyRepositoryBlock(additionalDependencyRepositories, localRepo)}
|
||||||
mavenLocal()
|
| repositoriesMode.set(${mapRepositoryModeToString(gradleRepositoriesMode)})
|
||||||
mavenCentral()
|
|}
|
||||||
google()
|
""".trimMargin()
|
||||||
ivy {
|
|
||||||
url = "https://download.jetbrains.com/kotlin/native/builds/dev"
|
|
||||||
patternLayout {
|
|
||||||
artifact("[revision]/[classifier]/[artifact]-[classifier]-[revision].[ext]")
|
|
||||||
}
|
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/"
|
|
||||||
}
|
|
||||||
ivy {
|
|
||||||
url = "https://github.com/yarnpkg/yarn/releases/download"
|
|
||||||
|
|
||||||
patternLayout {
|
internal fun getGroovyRepositoryBlock(
|
||||||
artifact("v[revision]/[artifact](-v[revision]).[ext]")
|
additionalDependencyRepositories: Set<String>,
|
||||||
}
|
localRepo: Path? = null,
|
||||||
metadataSources {
|
): String =
|
||||||
artifact()
|
//language=Groovy
|
||||||
}
|
"""
|
||||||
content {
|
|
|
||||||
includeModule("com.yarnpkg", "yarn")
|
| repositories {
|
||||||
}
|
| mavenLocal()
|
||||||
}
|
| mavenCentral()
|
||||||
ivy {
|
| google()
|
||||||
url = "https://nodejs.org/dist"
|
| ivy {
|
||||||
|
| url = "https://download.jetbrains.com/kotlin/native/builds/dev"
|
||||||
patternLayout {
|
| patternLayout {
|
||||||
artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
| artifact("[revision]/[classifier]/[artifact]-[classifier]-[revision].[ext]")
|
||||||
}
|
| }
|
||||||
metadataSources {
|
| metadataSources {
|
||||||
artifact()
|
| artifact()
|
||||||
}
|
| }
|
||||||
content {
|
| }
|
||||||
includeModule("org.nodejs", "node")
|
| maven {
|
||||||
}
|
| url "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/"
|
||||||
}
|
| }
|
||||||
ivy {
|
| ivy {
|
||||||
url = uri("https://nodejs.org/download/v8-canary")
|
| url = "https://github.com/yarnpkg/yarn/releases/download"
|
||||||
|
| patternLayout {
|
||||||
patternLayout {
|
| artifact("v[revision]/[artifact](-v[revision]).[ext]")
|
||||||
artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
| }
|
||||||
}
|
| metadataSources {
|
||||||
metadataSources {
|
| artifact()
|
||||||
artifact()
|
| }
|
||||||
}
|
| content {
|
||||||
content {
|
| includeModule("com.yarnpkg", "yarn")
|
||||||
includeModule("org.nodejs", "node")
|
| }
|
||||||
}
|
| }
|
||||||
}
|
| ivy {
|
||||||
ivy {
|
| url = "https://nodejs.org/dist"
|
||||||
url = uri("https://github.com/WebAssembly/binaryen/releases/download")
|
| patternLayout {
|
||||||
|
| artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
||||||
patternLayout {
|
| }
|
||||||
artifact("version_[revision]/binaryen-version_[revision]-[classifier].[ext]")
|
| metadataSources {
|
||||||
}
|
| artifact()
|
||||||
metadataSources {
|
| }
|
||||||
artifact()
|
| content {
|
||||||
}
|
| includeModule("org.nodejs", "node")
|
||||||
content {
|
| }
|
||||||
includeModule("com.github.webassembly", "binaryen")
|
| }
|
||||||
}
|
| ivy {
|
||||||
}
|
| url = uri("https://nodejs.org/download/v8-canary")
|
||||||
ivy {
|
| patternLayout {
|
||||||
url = uri("https://storage.googleapis.com/chromium-v8/official/canary")
|
| artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
||||||
|
| }
|
||||||
patternLayout {
|
| metadataSources {
|
||||||
artifact("[artifact]-[revision].[ext]")
|
| artifact()
|
||||||
}
|
| }
|
||||||
metadataSources {
|
| content {
|
||||||
artifact()
|
| includeModule("org.nodejs", "node")
|
||||||
}
|
| }
|
||||||
content {
|
| }
|
||||||
includeModule("google.d8", "v8")
|
| ivy {
|
||||||
}
|
| url = uri("https://github.com/WebAssembly/binaryen/releases/download")
|
||||||
}
|
| patternLayout {
|
||||||
${additionalDependencyRepositories.map { repo -> "maven{ url = \"$repo\" }" }.joinToString("\n")}
|
| artifact("version_[revision]/binaryen-version_[revision]-[classifier].[ext]")
|
||||||
${localRepo?.absolutePathString()?.let { repo -> "maven{ url = \"${repo.replace("\\", "\\\\")}\" }" } ?: ""}
|
| }
|
||||||
}
|
| metadataSources {
|
||||||
repositoriesMode.set(${mapRepositoryModeToString(gradleRepositoriesMode)})
|
| artifact()
|
||||||
}
|
| }
|
||||||
""".trimIndent()
|
| content {
|
||||||
|
| includeModule("com.github.webassembly", "binaryen")
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| ivy {
|
||||||
|
| url = uri("https://storage.googleapis.com/chromium-v8/official/canary")
|
||||||
|
| patternLayout {
|
||||||
|
| artifact("[artifact]-[revision].[ext]")
|
||||||
|
| }
|
||||||
|
| metadataSources {
|
||||||
|
| artifact()
|
||||||
|
| }
|
||||||
|
| content {
|
||||||
|
| includeModule("google.d8", "v8")
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| ${additionalDependencyRepositories.map { repo -> "maven{ url = \"$repo\" }" }.joinToString("\n")}
|
||||||
|
| ${localRepo?.absolutePathString()?.let { repo -> "maven{ url = \"${repo.replace("\\", "\\\\")}\" }" } ?: ""}
|
||||||
|
| }
|
||||||
|
""".trimMargin()
|
||||||
|
|
||||||
@Language("kts")
|
@Language("kts")
|
||||||
internal val DEFAULT_KOTLIN_SETTINGS_FILE =
|
internal val DEFAULT_KOTLIN_SETTINGS_FILE =
|
||||||
@@ -231,95 +236,99 @@ internal fun getKotlinDependencyManagementBlock(
|
|||||||
): String =
|
): String =
|
||||||
//language=kotlin
|
//language=kotlin
|
||||||
"""
|
"""
|
||||||
dependencyResolutionManagement {
|
|dependencyResolutionManagement {
|
||||||
repositories {
|
| ${getKotlinRepositoryBlock(additionalDependencyRepositories, localRepo)}
|
||||||
mavenLocal()
|
| repositoriesMode.set(${mapRepositoryModeToString(gradleRepositoriesMode)})
|
||||||
mavenCentral()
|
|}
|
||||||
google()
|
""".trimMargin()
|
||||||
ivy {
|
|
||||||
url = uri("https://download.jetbrains.com/kotlin/native/builds/dev")
|
|
||||||
patternLayout {
|
|
||||||
artifact("[revision]/[classifier]/[artifact]-[classifier]-[revision].[ext]")
|
|
||||||
}
|
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ivy {
|
|
||||||
url = uri("https://github.com/yarnpkg/yarn/releases/download")
|
|
||||||
|
|
||||||
patternLayout {
|
|
||||||
artifact("v[revision]/[artifact](-v[revision]).[ext]")
|
|
||||||
}
|
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
content {
|
|
||||||
includeModule("com.yarnpkg", "yarn")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ivy {
|
|
||||||
url = uri("https://nodejs.org/dist")
|
|
||||||
|
|
||||||
patternLayout {
|
|
||||||
artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
|
||||||
}
|
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
content {
|
|
||||||
includeModule("org.nodejs", "node")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ivy {
|
|
||||||
url = uri("https://nodejs.org/download/v8-canary")
|
|
||||||
|
|
||||||
patternLayout {
|
|
||||||
artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
|
||||||
}
|
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
content {
|
|
||||||
includeModule("org.nodejs", "node")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ivy {
|
|
||||||
url = uri("https://github.com/WebAssembly/binaryen/releases/download")
|
|
||||||
|
|
||||||
patternLayout {
|
|
||||||
artifact("version_[revision]/binaryen-version_[revision]-[classifier].[ext]")
|
|
||||||
}
|
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
content {
|
|
||||||
includeModule("com.github.webassembly", "binaryen")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ivy {
|
|
||||||
url = uri("https://storage.googleapis.com/chromium-v8/official/canary")
|
|
||||||
|
|
||||||
patternLayout {
|
|
||||||
artifact("[artifact]-[revision].[ext]")
|
|
||||||
}
|
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
content {
|
|
||||||
includeModule("google.d8", "v8")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url = uri("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/")
|
|
||||||
}
|
|
||||||
${additionalDependencyRepositories.map { repo -> "maven{ url = uri(\"$repo\") }" }.joinToString("\n")}
|
|
||||||
${localRepo?.absolutePathString()?.let { repo -> "maven{ url = uri(\"${repo.replace("\\", "\\\\")}\") }" } ?: ""}
|
|
||||||
}
|
|
||||||
repositoriesMode.set(${mapRepositoryModeToString(gradleRepositoriesMode)})
|
|
||||||
}
|
|
||||||
""".trimIndent()
|
|
||||||
|
|
||||||
|
internal fun getKotlinRepositoryBlock(
|
||||||
|
additionalDependencyRepositories: Set<String>,
|
||||||
|
localRepo: Path? = null,
|
||||||
|
): String =
|
||||||
|
//language=kotlin
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
| repositories {
|
||||||
|
| mavenLocal()
|
||||||
|
| mavenCentral()
|
||||||
|
| google()
|
||||||
|
| ivy {
|
||||||
|
| url = uri("https://download.jetbrains.com/kotlin/native/builds/dev")
|
||||||
|
| patternLayout {
|
||||||
|
| artifact("[revision]/[classifier]/[artifact]-[classifier]-[revision].[ext]")
|
||||||
|
| }
|
||||||
|
| metadataSources {
|
||||||
|
| artifact()
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| ivy {
|
||||||
|
| url = uri("https://github.com/yarnpkg/yarn/releases/download")
|
||||||
|
| patternLayout {
|
||||||
|
| artifact("v[revision]/[artifact](-v[revision]).[ext]")
|
||||||
|
| }
|
||||||
|
| metadataSources {
|
||||||
|
| artifact()
|
||||||
|
| }
|
||||||
|
| content {
|
||||||
|
| includeModule("com.yarnpkg", "yarn")
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| ivy {
|
||||||
|
| url = uri("https://nodejs.org/dist")
|
||||||
|
| patternLayout {
|
||||||
|
| artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
||||||
|
| }
|
||||||
|
| metadataSources {
|
||||||
|
| artifact()
|
||||||
|
| }
|
||||||
|
| content {
|
||||||
|
| includeModule("org.nodejs", "node")
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| ivy {
|
||||||
|
| url = uri("https://nodejs.org/download/v8-canary")
|
||||||
|
| patternLayout {
|
||||||
|
| artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
||||||
|
| }
|
||||||
|
| metadataSources {
|
||||||
|
| artifact()
|
||||||
|
| }
|
||||||
|
| content {
|
||||||
|
| includeModule("org.nodejs", "node")
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| ivy {
|
||||||
|
| url = uri("https://github.com/WebAssembly/binaryen/releases/download")
|
||||||
|
| patternLayout {
|
||||||
|
| artifact("version_[revision]/binaryen-version_[revision]-[classifier].[ext]")
|
||||||
|
| }
|
||||||
|
| metadataSources {
|
||||||
|
| artifact()
|
||||||
|
| }
|
||||||
|
| content {
|
||||||
|
| includeModule("com.github.webassembly", "binaryen")
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| ivy {
|
||||||
|
| url = uri("https://storage.googleapis.com/chromium-v8/official/canary")
|
||||||
|
| patternLayout {
|
||||||
|
| artifact("[artifact]-[revision].[ext]")
|
||||||
|
| }
|
||||||
|
| metadataSources {
|
||||||
|
| artifact()
|
||||||
|
| }
|
||||||
|
| content {
|
||||||
|
| includeModule("google.d8", "v8")
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| maven {
|
||||||
|
| url = uri("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/")
|
||||||
|
| }
|
||||||
|
| ${additionalDependencyRepositories.map { repo -> "maven{ url = uri(\"$repo\") }" }.joinToString("\n")}
|
||||||
|
| ${localRepo?.absolutePathString()?.let { repo -> "maven{ url = uri(\"${repo.replace("\\", "\\\\")}\") }" } ?: ""}
|
||||||
|
| }
|
||||||
|
""".trimMargin()
|
||||||
|
|
||||||
private fun mapRepositoryModeToString(gradleRepositoriesMode: RepositoriesMode): String {
|
private fun mapRepositoryModeToString(gradleRepositoriesMode: RepositoriesMode): String {
|
||||||
return when (gradleRepositoriesMode) {
|
return when (gradleRepositoriesMode) {
|
||||||
|
|||||||
+81
-15
@@ -61,7 +61,7 @@ fun KGPBaseTest.project(
|
|||||||
workingDir,
|
workingDir,
|
||||||
projectPathAdditionalSuffix,
|
projectPathAdditionalSuffix,
|
||||||
)
|
)
|
||||||
projectPath.addDefaultSettingsToSettingsGradle(dependencyManagement, localRepoDir)
|
projectPath.addDefaultSettingsToSettingsGradle(gradleVersion, dependencyManagement, localRepoDir)
|
||||||
projectPath.enableCacheRedirector()
|
projectPath.enableCacheRedirector()
|
||||||
projectPath.enableAndroidSdk()
|
projectPath.enableAndroidSdk()
|
||||||
if (buildOptions.languageVersion != null || buildOptions.languageApiVersion != null) {
|
if (buildOptions.languageVersion != null || buildOptions.languageApiVersion != null) {
|
||||||
@@ -438,7 +438,7 @@ class TestProject(
|
|||||||
val otherProjectPath = "$pathPrefix/$otherProjectName".testProjectPath
|
val otherProjectPath = "$pathPrefix/$otherProjectName".testProjectPath
|
||||||
otherProjectPath.copyRecursively(projectPath.resolve(otherProjectName))
|
otherProjectPath.copyRecursively(projectPath.resolve(otherProjectName))
|
||||||
|
|
||||||
projectPath.resolve(otherProjectName).addDefaultSettingsToSettingsGradle()
|
projectPath.resolve(otherProjectName).addDefaultSettingsToSettingsGradle(gradleVersion)
|
||||||
|
|
||||||
settingsGradle.append(
|
settingsGradle.append(
|
||||||
"""
|
"""
|
||||||
@@ -551,31 +551,97 @@ private fun setupProjectFromTestResources(
|
|||||||
private val String.testProjectPath: Path get() = Paths.get("src", "test", "resources", "testProject", this)
|
private val String.testProjectPath: Path get() = Paths.get("src", "test", "resources", "testProject", this)
|
||||||
|
|
||||||
internal fun Path.addDefaultSettingsToSettingsGradle(
|
internal fun Path.addDefaultSettingsToSettingsGradle(
|
||||||
|
gradleVersion: GradleVersion,
|
||||||
dependencyManagement: DependencyManagement = DependencyManagement.DefaultDependencyManagement(),
|
dependencyManagement: DependencyManagement = DependencyManagement.DefaultDependencyManagement(),
|
||||||
localRepo: Path? = null,
|
localRepo: Path? = null,
|
||||||
) {
|
) {
|
||||||
addPluginManagementToSettings()
|
addPluginManagementToSettings()
|
||||||
when (dependencyManagement) {
|
when (dependencyManagement) {
|
||||||
is DependencyManagement.DefaultDependencyManagement -> addDependencyManagementToSettings(
|
is DependencyManagement.DefaultDependencyManagement -> {
|
||||||
additionalDependencyRepositories = dependencyManagement.additionalRepos,
|
// we cannot switch to dependencyManagement before Gradle 8.1 because of KT-65708
|
||||||
localRepo = localRepo
|
if (gradleVersion < GradleVersion.version(TestVersions.Gradle.G_8_1)) {
|
||||||
)
|
addDependencyRepositoriesToBuildScript(
|
||||||
|
additionalDependencyRepositories = dependencyManagement.additionalRepos,
|
||||||
|
localRepo = localRepo
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
addDependencyManagementToSettings(
|
||||||
|
additionalDependencyRepositories = dependencyManagement.additionalRepos,
|
||||||
|
localRepo = localRepo
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
is DependencyManagement.DisabledDependencyManagement -> {}
|
is DependencyManagement.DisabledDependencyManagement -> {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val buildSrc = resolve("buildSrc")
|
private fun Path.addDependencyRepositoriesToBuildScript(
|
||||||
if (Files.exists(buildSrc)) {
|
additionalDependencyRepositories: Set<String>,
|
||||||
buildSrc.addPluginManagementToSettings()
|
localRepo: Path? = null,
|
||||||
when (dependencyManagement) {
|
) {
|
||||||
is DependencyManagement.DefaultDependencyManagement -> buildSrc.addDependencyManagementToSettings(
|
val buildGradle = resolve("build.gradle")
|
||||||
additionalDependencyRepositories = dependencyManagement.additionalRepos,
|
val buildGradleKts = resolve("build.gradle.kts")
|
||||||
localRepo = localRepo
|
val settingsGradle = resolve("settings.gradle")
|
||||||
|
val settingsGradleKts = resolve("settings.gradle.kts")
|
||||||
|
when {
|
||||||
|
Files.exists(buildGradle) -> buildGradle.modify {
|
||||||
|
it.insertBlockToBuildScriptAfterPluginsAndImports(
|
||||||
|
getGroovyRepositoryBlock(additionalDependencyRepositories, localRepo).wrapWithAllProjectBlock()
|
||||||
)
|
)
|
||||||
is DependencyManagement.DisabledDependencyManagement -> {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Files.exists(buildGradleKts) -> buildGradleKts.modify {
|
||||||
|
it.insertBlockToBuildScriptAfterPluginsAndImports(
|
||||||
|
getKotlinRepositoryBlock(additionalDependencyRepositories, localRepo).wrapWithAllProjectBlock()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Files.exists(settingsGradle) -> buildGradle.toFile()
|
||||||
|
.writeText(
|
||||||
|
getGroovyRepositoryBlock(
|
||||||
|
additionalDependencyRepositories,
|
||||||
|
localRepo
|
||||||
|
).wrapWithAllProjectBlock()
|
||||||
|
)
|
||||||
|
|
||||||
|
Files.exists(settingsGradleKts) -> buildGradleKts.toFile()
|
||||||
|
.writeText(
|
||||||
|
getKotlinRepositoryBlock(
|
||||||
|
additionalDependencyRepositories,
|
||||||
|
localRepo
|
||||||
|
).wrapWithAllProjectBlock()
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> error("No build-file or settings file found")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Files.exists(resolve("buildSrc"))) {
|
||||||
|
resolve("buildSrc").addDependencyRepositoriesToBuildScript(additionalDependencyRepositories, localRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.wrapWithAllProjectBlock(): String =
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|allprojects {
|
||||||
|
| $this
|
||||||
|
|}
|
||||||
|
|
|
||||||
|
""".trimMargin()
|
||||||
|
|
||||||
|
private fun String.insertBlockToBuildScriptAfterPluginsAndImports(blockToInsert: String): String {
|
||||||
|
val importsPattern = Regex("^import.*$", RegexOption.MULTILINE)
|
||||||
|
val pluginsBlockPattern = Regex("plugins\\s*\\{[^}]*}", RegexOption.DOT_MATCHES_ALL)
|
||||||
|
|
||||||
|
val lastImportIndex = importsPattern.findAll(this).map { it.range.last }.maxOrNull()
|
||||||
|
val pluginBlockEndIndex = pluginsBlockPattern.find(this)?.range?.last
|
||||||
|
|
||||||
|
val insertionIndex = listOfNotNull(lastImportIndex, pluginBlockEndIndex).maxOrNull() ?: return blockToInsert + this
|
||||||
|
|
||||||
|
return StringBuilder(this).insert(insertionIndex + 1, "\n$blockToInsert\n").toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
internal fun Path.addPluginManagementToSettings() {
|
internal fun Path.addPluginManagementToSettings() {
|
||||||
val buildGradle = resolve("build.gradle")
|
val buildGradle = resolve("build.gradle")
|
||||||
val buildGradleKts = resolve("build.gradle.kts")
|
val buildGradleKts = resolve("build.gradle.kts")
|
||||||
@@ -641,7 +707,7 @@ internal fun Path.addDependencyManagementToSettings(
|
|||||||
localRepo
|
localRepo
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|""".trimMargin()
|
""".trimMargin()
|
||||||
} else {
|
} else {
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
|||||||
-5
@@ -6,11 +6,6 @@ plugins {
|
|||||||
allprojects {
|
allprojects {
|
||||||
group = "a"
|
group = "a"
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ version = "1.0.0"
|
|||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
maven(rootProject.buildDir.resolve("repo"))
|
maven("<localRepo>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ version = "1.0.0"
|
|||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
maven(rootProject.buildDir.resolve("repo"))
|
maven("<localRepo>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-9
@@ -1,12 +1,3 @@
|
|||||||
dependencyResolutionManagement {
|
|
||||||
repositories {
|
|
||||||
maven(rootProject.projectDir.resolve("build").resolve("repo"))
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
google()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include(":p1")
|
include(":p1")
|
||||||
include(":p2")
|
include(":p2")
|
||||||
include(":consumer")
|
include(":consumer")
|
||||||
-4
@@ -13,10 +13,6 @@ buildscript {
|
|||||||
|
|
||||||
apply plugin: 'kotlin-multiplatform'
|
apply plugin: 'kotlin-multiplatform'
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
targets {
|
targets {
|
||||||
|
|||||||
-5
@@ -2,11 +2,6 @@ plugins {
|
|||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
<SingleNativeTarget>("native") {
|
<SingleNativeTarget>("native") {
|
||||||
binaries.executable()
|
binaries.executable()
|
||||||
|
|||||||
-7
@@ -1,10 +1,3 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform").apply(false)
|
kotlin("multiplatform").apply(false)
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user