Wizard: move common repositories to the allprojects section

This commit is contained in:
Ilya Kirillov
2020-10-10 15:43:19 +03:00
parent e824199169
commit fa8951c19e
79 changed files with 178 additions and 255 deletions

View File

@@ -7,16 +7,6 @@ plugins {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.appcompat:appcompat:1.2.0'

View File

@@ -7,16 +7,6 @@ plugins {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
implementation("com.google.android.material:material:1.2.0")
implementation("androidx.appcompat:appcompat:1.2.0")

View File

@@ -16,9 +16,14 @@ buildscript {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
}

View File

@@ -16,9 +16,14 @@ buildscript {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
allprojects {
repositories {
google()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
}

View File

@@ -1,9 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
jcenter()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,9 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
jcenter()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -5,13 +5,6 @@ plugins {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
implementation project(':b')
implementation project(':c')

View File

@@ -7,13 +7,6 @@ plugins {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
implementation(project(":b"))
implementation(project(":c"))

View File

@@ -5,13 +5,6 @@ plugins {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
implementation project(':c')
implementation project(':d')

View File

@@ -7,13 +7,6 @@ plugins {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
implementation(project(":c"))
implementation(project(":d"))

View File

@@ -1,9 +1,13 @@
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
allprojects {
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
}

View File

@@ -1,9 +1,13 @@
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
allprojects {
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
}

View File

@@ -5,13 +5,6 @@ plugins {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
}

View File

@@ -7,13 +7,6 @@ plugins {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
testImplementation(kotlin("test-junit"))
}

View File

@@ -5,13 +5,6 @@ plugins {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
implementation project(':a')
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'

View File

@@ -7,13 +7,6 @@ plugins {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
implementation(project(":a"))
testImplementation(kotlin("test-junit"))

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -5,13 +5,6 @@ plugins {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
rootProject
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'

View File

@@ -7,13 +7,6 @@ plugins {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
rootProject
testImplementation(kotlin("test-junit"))

View File

@@ -5,13 +5,6 @@ plugins {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
implementation project(':b')
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'

View File

@@ -7,13 +7,6 @@ plugins {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
implementation(project(":b"))
testImplementation(kotlin("test-junit"))

View File

@@ -5,13 +5,6 @@ plugins {
group = 'testGroupId'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
}

View File

@@ -7,13 +7,6 @@ plugins {
group = "testGroupId"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
testImplementation(kotlin("test-junit"))
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -6,8 +6,8 @@ group = 'me.user'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
jcenter()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -6,8 +6,8 @@ group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
jcenter()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -9,19 +9,19 @@ group = 'me.user'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
jcenter()
maven {
url 'https://dl.bintray.com/kotlin/ktor'
}
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
maven {
url 'https://dl.bintray.com/kotlin/kotlin-js-wrappers'
}
maven {
url 'https://dl.bintray.com/kotlin/kotlinx'
}
maven {
url 'https://dl.bintray.com/kotlin/kotlin-js-wrappers'
url 'https://dl.bintray.com/kotlin/ktor'
}
}

View File

@@ -9,19 +9,19 @@ group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
jcenter()
maven {
url = uri("https://dl.bintray.com/kotlin/ktor")
}
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers")
}
maven {
url = uri("https://dl.bintray.com/kotlin/kotlinx")
}
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers")
url = uri("https://dl.bintray.com/kotlin/ktor")
}
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -7,16 +7,6 @@ plugins {
group = 'me.user'
version = '1.0-SNAPSHOT'
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
dependencies {
implementation project(':shared')
implementation 'com.google.android.material:material:1.2.0'

View File

@@ -7,16 +7,6 @@ plugins {
group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
dependencies {
implementation(project(":shared"))
implementation("com.google.android.material:material:1.2.0")

View File

@@ -16,9 +16,14 @@ buildscript {
group = 'me.user'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'KOTLIN_REPO'
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
}

View File

@@ -16,9 +16,14 @@ buildscript {
group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
allprojects {
repositories {
google()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
}

View File

@@ -1,9 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
jcenter()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,9 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
jcenter()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -9,16 +9,6 @@ plugins {
group = 'me.user'
version = '1.0-SNAPSHOT'
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}
}
kotlin {
android()
ios {

View File

@@ -9,16 +9,6 @@ plugins {
group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}
}
kotlin {
android()
ios {

View File

@@ -8,9 +8,7 @@ group = 'me.user'
version = '1.0-SNAPSHOT'
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url 'KOTLIN_REPO'

View File

@@ -8,9 +8,7 @@ group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")

View File

@@ -1,9 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
jcenter()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,9 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
jcenter()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url 'KOTLIN_REPO'
}

View File

@@ -1,7 +1,7 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenCentral()
maven {
url = uri("KOTLIN_REPO")
}

View File

@@ -23,7 +23,8 @@ data class BuildFileIR(
val modules: ModulesStructureIR,
val fromModules: List<Module>,
val pom: PomIR,
override val irs: PersistentList<BuildSystemIR>
val isRoot: Boolean,
override val irs: PersistentList<BuildSystemIR>,
) : FileIR {
override fun withReplacedIrs(irs: PersistentList<BuildSystemIR>): BuildFileIR = copy(irs = irs)
@@ -57,9 +58,10 @@ data class BuildFileIR(
}
sectionCall("plugins", irsOfType<BuildSystemPluginIR>()); nl(lineBreaks = 2)
pom.render(this); nl()
sectionCall("repositories", distinctRepositories())
nl(lineBreaks = 2)
distinctRepositories().takeIf { it.isNotEmpty() }?.let { repositories ->
sectionCall("repositories", repositories)
nl(lineBreaks = 2)
}
modules.render(this)
irsOfTypeOrNull<FreeIR>()?.let { freeIrs ->
nl(2)

View File

@@ -1,5 +1,6 @@
package org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.GradleIR
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.BuildFilePrinter
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.GradlePrinter
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.MavenPrinter
@@ -13,6 +14,7 @@ interface RepositoryWrapper {
fun <W : RepositoryWrapper> List<W>.distinctAndSorted() =
distinctBy(RepositoryWrapper::repository)
.sortedBy { it.repository.url }
.sortedBy { wrapper ->
if (wrapper.repository is DefaultRepository) 0 else 1
}
@@ -46,3 +48,14 @@ data class RepositoryIR(override val repository: Repository) : BuildSystemIR, Re
else -> Unit
}
}
data class AllProjectsRepositoriesIR(val repositoriesIR: List<RepositoryIR>) : BuildSystemIR, GradleIR, FreeIR {
override fun GradlePrinter.renderGradle() {
sectionCall("allprojects", needIndent = true) {
sectionCall("repositories") {
repositoriesIR.listNl()
}
}
}
}

View File

@@ -70,7 +70,6 @@ interface AndroidModuleConfigurator : ModuleConfigurator,
+GradleOnlyPluginByNameIR(reader.createAndroidPlugin(module).pluginName, priority = 1)
+GradleOnlyPluginByNameIR("kotlin-android-extensions", priority = 3)
+createRepositories(configurationData.kotlinVersion).map(::RepositoryIR)
}
fun Reader.createAndroidPlugin(module: Module): AndroidGradlePlugin

View File

@@ -1,17 +1,15 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.gradle
import kotlinx.collections.immutable.toPersistentList
import org.jetbrains.kotlin.tools.projectWizard.Versions
import org.jetbrains.kotlin.tools.projectWizard.core.*
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
import org.jetbrains.kotlin.tools.projectWizard.core.entity.properties.Property
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting
import org.jetbrains.kotlin.tools.projectWizard.core.service.FileSystemWizardService
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemIR
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.PluginManagementRepositoryIR
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.RepositoryIR
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.SettingsGradleFileIR
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.render
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.*
@@ -21,6 +19,9 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.printBuildFile
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.DefaultRepository
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Repository
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.updateBuildFiles
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.updateModules
import org.jetbrains.kotlin.tools.projectWizard.templates.FileTemplate
import org.jetbrains.kotlin.tools.projectWizard.templates.FileTemplateDescriptor
@@ -103,6 +104,44 @@ abstract class GradlePlugin(context: Context) : BuildSystemPlugin(context) {
}
}
val mergeCommonRepositories by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runBefore(createModules)
runAfter(takeRepositoriesFromDependencies)
runAfter(KotlinPlugin.createPluginRepositories)
isAvailable = isGradle
withAction {
val buildFiles = buildFiles.propertyValue
if (buildFiles.size == 1) return@withAction UNIT_SUCCESS
val moduleRepositories = buildFiles.mapNotNull { buildFileIR ->
if (buildFileIR.isRoot) null
else buildFileIR.irs.mapNotNull { it.safeAs<RepositoryIR>()?.repository }
}
val allRepositories = moduleRepositories.flatMapTo(hashSetOf()) { it }
val commonRepositories = allRepositories.filterTo(
hashSetOf(KotlinPlugin.version.propertyValue.repository)
) { repo ->
moduleRepositories.all { repo in it }
}
updateBuildFiles { buildFile ->
buildFile.withReplacedIrs(
buildFile.irs
.filterNot { it.safeAs<RepositoryIR>()?.repository in commonRepositories }
.toPersistentList()
).let {
if (it.isRoot && commonRepositories.isNotEmpty()) {
val repositories = commonRepositories.map(::RepositoryIR).distinctAndSorted()
it.withIrs(AllProjectsRepositoriesIR(repositories))
} else it
}.asSuccess()
}
}
}
val createSettingsFileTask by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(KotlinPlugin.createModules)
@@ -143,6 +182,7 @@ abstract class GradlePlugin(context: Context) : BuildSystemPlugin(context) {
createLocalPropertiesFile,
initGradleWrapperTask,
createSettingsFileTask,
mergeCommonRepositories,
)
override val properties: List<Property<*>> = super.properties +
listOf(

View File

@@ -109,6 +109,7 @@ class ModulesToIRsConverter(
RootFileModuleStructureIR(persistentListOf()),
emptyList(),
pomIr,
isRoot = true,
rootBuildFileIrs.toPersistentList()
)
}
@@ -189,6 +190,7 @@ class ModulesToIRsConverter(
),
listOf(module),
data.pomIr.copy(artifactId = module.name),
isRoot = false, /* TODO */
createBuildFileIRs(module, state)
).also {
moduleToBuildFile[module] = it
@@ -230,6 +232,7 @@ class ModulesToIRsConverter(
),
module.subModules + module,
pomIr,
isRoot = false,
buildPersistenceList {
+createBuildFileIRs(module, state)
module.subModules.forEach { +createBuildFileIRs(it, state) }