Wizard: do not print plugin repositories in build files if all of them are default ones
Also, use space dev repo for kotlin dev plugins
This commit is contained in:
-1
@@ -1,7 +1,6 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
mavenCentral()
|
|
||||||
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
|
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ abstract class AbstractBuildFileGenerationTest : UsefulTestCase() {
|
|||||||
KOTLIN_VERSION_PLACEHOLDER
|
KOTLIN_VERSION_PLACEHOLDER
|
||||||
).replaceAllTo(
|
).replaceAllTo(
|
||||||
listOf(
|
listOf(
|
||||||
Repositories.KOTLIN_DEV_BINTRAY.url,
|
Repositories.JETBRAINS_KOTLIN_DEV.url,
|
||||||
KotlinVersionProviderTestWizardService.KOTLIN_DEV_BINTRAY_WITH_CACHE_REDIRECTOR.url,
|
KotlinVersionProviderTestWizardService.KOTLIN_DEV_BINTRAY_WITH_CACHE_REDIRECTOR.url,
|
||||||
),
|
),
|
||||||
KOTLIN_REPO_PLACEHOLDER
|
KOTLIN_REPO_PLACEHOLDER
|
||||||
|
|||||||
+6
-17
@@ -11,9 +11,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardKotlinVersion
|
|||||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.KotlinVersionKind
|
import org.jetbrains.kotlin.tools.projectWizard.core.service.KotlinVersionKind
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.KotlinVersionProviderService
|
import org.jetbrains.kotlin.tools.projectWizard.core.service.KotlinVersionProviderService
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ProjectKind
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ProjectKind
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.BintrayRepository
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.*
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.DefaultRepository
|
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Repository
|
|
||||||
|
|
||||||
class KotlinVersionProviderTestWizardService() : KotlinVersionProviderService(), TestWizardService {
|
class KotlinVersionProviderTestWizardService() : KotlinVersionProviderService(), TestWizardService {
|
||||||
private val useCacheRedirector
|
private val useCacheRedirector
|
||||||
@@ -28,23 +26,14 @@ class KotlinVersionProviderTestWizardService() : KotlinVersionProviderService(),
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun getKotlinVersionRepository(versionKind: KotlinVersionKind): Repository = if (useCacheRedirector) {
|
override fun getDevVersionRepository(): Repository =
|
||||||
getKotlinVersionRepositoryWithCacheRedirector(versionKind)
|
if (useCacheRedirector) KOTLIN_DEV_BINTRAY_WITH_CACHE_REDIRECTOR
|
||||||
} else {
|
else super.getDevVersionRepository()
|
||||||
super.getKotlinVersionRepository(versionKind)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getKotlinVersionRepositoryWithCacheRedirector(versionKind: KotlinVersionKind): Repository = when (versionKind) {
|
|
||||||
KotlinVersionKind.STABLE -> DefaultRepository.MAVEN_CENTRAL
|
|
||||||
KotlinVersionKind.EAP -> DefaultRepository.MAVEN_CENTRAL
|
|
||||||
KotlinVersionKind.DEV -> KOTLIN_DEV_BINTRAY_WITH_CACHE_REDIRECTOR
|
|
||||||
KotlinVersionKind.M -> DefaultRepository.MAVEN_CENTRAL
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val CACHE_REDIRECTOR_BINTRAY_URL = "https://cache-redirector.jetbrains.com/dl.bintray.com"
|
private const val CACHE_REDIRECTOR_JETBRAINS_SPACE_URL = "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space"
|
||||||
|
|
||||||
val KOTLIN_DEV_BINTRAY_WITH_CACHE_REDIRECTOR = BintrayRepository("kotlin/kotlin-dev", CACHE_REDIRECTOR_BINTRAY_URL)
|
val KOTLIN_DEV_BINTRAY_WITH_CACHE_REDIRECTOR = BintrayRepository("kotlin/p/kotlin/dev", CACHE_REDIRECTOR_JETBRAINS_SPACE_URL)
|
||||||
|
|
||||||
|
|
||||||
val TEST_KOTLIN_VERSION by lazy {
|
val TEST_KOTLIN_VERSION by lazy {
|
||||||
|
|||||||
+34
-4
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.TaskResult
|
|||||||
import org.jetbrains.kotlin.tools.projectWizard.core.asNullable
|
import org.jetbrains.kotlin.tools.projectWizard.core.asNullable
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.compute
|
import org.jetbrains.kotlin.tools.projectWizard.core.compute
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.safe
|
import org.jetbrains.kotlin.tools.projectWizard.core.safe
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemType
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ProjectKind
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ProjectKind
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.DefaultRepository
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.DefaultRepository
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Repositories
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Repositories
|
||||||
@@ -23,7 +24,12 @@ import java.io.InputStreamReader
|
|||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.stream.Collectors
|
import java.util.stream.Collectors
|
||||||
|
|
||||||
data class WizardKotlinVersion(val version: Version, val kind: KotlinVersionKind, val repository: Repository)
|
data class WizardKotlinVersion(
|
||||||
|
val version: Version,
|
||||||
|
val kind: KotlinVersionKind,
|
||||||
|
val repository: Repository,
|
||||||
|
val buildSystemPluginRepository: (BuildSystemType) -> Repository?,
|
||||||
|
)
|
||||||
|
|
||||||
abstract class KotlinVersionProviderService : WizardService {
|
abstract class KotlinVersionProviderService : WizardService {
|
||||||
abstract fun getKotlinVersion(projectKind: ProjectKind): WizardKotlinVersion
|
abstract fun getKotlinVersion(projectKind: ProjectKind): WizardKotlinVersion
|
||||||
@@ -31,23 +37,47 @@ abstract class KotlinVersionProviderService : WizardService {
|
|||||||
protected fun kotlinVersionWithDefaultValues(version: Version) = WizardKotlinVersion(
|
protected fun kotlinVersionWithDefaultValues(version: Version) = WizardKotlinVersion(
|
||||||
version,
|
version,
|
||||||
getKotlinVersionKind(version),
|
getKotlinVersionKind(version),
|
||||||
getKotlinVersionRepository(version)
|
getKotlinVersionRepository(version),
|
||||||
|
getBuildSystemPluginRepository(getKotlinVersionKind(version), getDevVersionRepository()),
|
||||||
)
|
)
|
||||||
|
|
||||||
protected open fun getKotlinVersionRepository(versionKind: KotlinVersionKind): Repository = when (versionKind) {
|
|
||||||
|
private fun getKotlinVersionRepository(versionKind: KotlinVersionKind): Repository = when (versionKind) {
|
||||||
KotlinVersionKind.STABLE, KotlinVersionKind.EAP, KotlinVersionKind.M -> DefaultRepository.MAVEN_CENTRAL
|
KotlinVersionKind.STABLE, KotlinVersionKind.EAP, KotlinVersionKind.M -> DefaultRepository.MAVEN_CENTRAL
|
||||||
KotlinVersionKind.DEV -> Repositories.KOTLIN_DEV_BINTRAY
|
KotlinVersionKind.DEV -> getDevVersionRepository()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun getDevVersionRepository(): Repository = Repositories.JETBRAINS_KOTLIN_DEV
|
||||||
|
|
||||||
private fun getKotlinVersionRepository(version: Version) =
|
private fun getKotlinVersionRepository(version: Version) =
|
||||||
getKotlinVersionRepository(getKotlinVersionKind(version))
|
getKotlinVersionRepository(getKotlinVersionKind(version))
|
||||||
|
|
||||||
|
|
||||||
private fun getKotlinVersionKind(version: Version) = when {
|
private fun getKotlinVersionKind(version: Version) = when {
|
||||||
"eap" in version.toString().toLowerCase() -> KotlinVersionKind.EAP
|
"eap" in version.toString().toLowerCase() -> KotlinVersionKind.EAP
|
||||||
"rc" in version.toString().toLowerCase() -> KotlinVersionKind.EAP
|
"rc" in version.toString().toLowerCase() -> KotlinVersionKind.EAP
|
||||||
"dev" in version.toString().toLowerCase() -> KotlinVersionKind.DEV
|
"dev" in version.toString().toLowerCase() -> KotlinVersionKind.DEV
|
||||||
"m" in version.toString().toLowerCase() -> KotlinVersionKind.M
|
"m" in version.toString().toLowerCase() -> KotlinVersionKind.M
|
||||||
else -> KotlinVersionKind.STABLE
|
else -> KotlinVersionKind.STABLE
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun getBuildSystemPluginRepository(
|
||||||
|
versionKind: KotlinVersionKind,
|
||||||
|
devRepository: Repository
|
||||||
|
): (BuildSystemType) -> Repository? =
|
||||||
|
when (versionKind) {
|
||||||
|
KotlinVersionKind.STABLE, KotlinVersionKind.EAP, KotlinVersionKind.M -> { buildSystem ->
|
||||||
|
when (buildSystem) {
|
||||||
|
BuildSystemType.GradleKotlinDsl, BuildSystemType.GradleGroovyDsl -> DefaultRepository.GRADLE_PLUGIN_PORTAL
|
||||||
|
BuildSystemType.Maven -> DefaultRepository.MAVEN_CENTRAL
|
||||||
|
BuildSystemType.Jps -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KotlinVersionKind.DEV -> { _ -> devRepository }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.printBuildFile
|
|||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||||
|
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.Repository
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.updateBuildFiles
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.updateBuildFiles
|
||||||
|
|
||||||
@@ -125,6 +126,19 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Reader.getPluginRepositoriesWithDefaultOnes(): List<Repository> {
|
||||||
|
val allRepositories = BuildSystemPlugin.pluginRepositoreis.propertyValue + buildSystemType.getDefaultPluginRepositories()
|
||||||
|
return allRepositories.filterOutOnlyDefaultPluginRepositories(buildSystemType)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun List<Repository>.filterOutOnlyDefaultPluginRepositories(buildSystem: BuildSystemType): List<Repository> {
|
||||||
|
val isAllDefault = all { it.isDefaultPluginRepository(buildSystem) }
|
||||||
|
return if (isAllDefault) emptyList() else this
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Repository.isDefaultPluginRepository(buildSystem: BuildSystemType) =
|
||||||
|
this in buildSystem.getDefaultPluginRepositories()
|
||||||
|
|
||||||
fun PluginSettingsOwner.addBuildSystemData(data: BuildSystemData) = pipelineTask(GenerationPhase.PREPARE) {
|
fun PluginSettingsOwner.addBuildSystemData(data: BuildSystemData) = pipelineTask(GenerationPhase.PREPARE) {
|
||||||
runBefore(BuildSystemPlugin.createModules)
|
runBefore(BuildSystemPlugin.createModules)
|
||||||
withAction {
|
withAction {
|
||||||
@@ -198,6 +212,12 @@ val Writer.allModulesPaths
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun BuildSystemType.getDefaultPluginRepositories(): List<DefaultRepository> = when (this) {
|
||||||
|
BuildSystemType.GradleKotlinDsl, BuildSystemType.GradleGroovyDsl -> listOf(DefaultRepository.GRADLE_PLUGIN_PORTAL)
|
||||||
|
BuildSystemType.Maven -> listOf(DefaultRepository.MAVEN_CENTRAL)
|
||||||
|
BuildSystemType.Jps -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
val Reader.buildSystemType: BuildSystemType
|
val Reader.buildSystemType: BuildSystemType
|
||||||
get() = BuildSystemPlugin.type.settingValue
|
get() = BuildSystemPlugin.type.settingValue
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ class MavenPlugin(context: Context) : BuildSystemPlugin(context) {
|
|||||||
isAvailable = isMaven
|
isAvailable = isMaven
|
||||||
|
|
||||||
withAction {
|
withAction {
|
||||||
val repositories = pluginRepositoreis.propertyValue
|
val repositories = getPluginRepositoriesWithDefaultOnes()
|
||||||
updateBuildFiles { buildFile ->
|
updateBuildFiles { buildFile ->
|
||||||
buildFile.withIrs(repositories.map(::PluginRepositoryMavenIR)).asSuccess()
|
buildFile.withIrs(repositories.map(::PluginRepositoryMavenIR)).asSuccess()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -18,10 +18,7 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.GradlePrinter
|
|||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.printBuildFile
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.printBuildFile
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
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.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.FileTemplate
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.templates.FileTemplateDescriptor
|
import org.jetbrains.kotlin.tools.projectWizard.templates.FileTemplateDescriptor
|
||||||
|
|
||||||
@@ -152,13 +149,7 @@ abstract class GradlePlugin(context: Context) : BuildSystemPlugin(context) {
|
|||||||
withAction {
|
withAction {
|
||||||
val (createBuildFile, buildFileName) = settingsGradleBuildFileData ?: return@withAction UNIT_SUCCESS
|
val (createBuildFile, buildFileName) = settingsGradleBuildFileData ?: return@withAction UNIT_SUCCESS
|
||||||
|
|
||||||
val repositories = buildList<RepositoryIR> {
|
val repositories = getPluginRepositoriesWithDefaultOnes().map { PluginManagementRepositoryIR(RepositoryIR(it)) }
|
||||||
+pluginRepositoreis.propertyValue.map(::RepositoryIR)
|
|
||||||
if (isNotEmpty()) {
|
|
||||||
+RepositoryIR(DefaultRepository.MAVEN_CENTRAL)
|
|
||||||
+RepositoryIR(DefaultRepository.GRADLE_PLUGIN_PORTAL)
|
|
||||||
}
|
|
||||||
}.map(::PluginManagementRepositoryIR)
|
|
||||||
|
|
||||||
val settingsGradleIR = SettingsGradleFileIR(
|
val settingsGradleIR = SettingsGradleFileIR(
|
||||||
StructurePlugin.name.settingValue,
|
StructurePlugin.name.settingValue,
|
||||||
|
|||||||
+11
-3
@@ -55,7 +55,15 @@ class KotlinPlugin(context: Context) : Plugin(context) {
|
|||||||
|
|
||||||
val version by property(
|
val version by property(
|
||||||
// todo do not hardcode kind & repository
|
// todo do not hardcode kind & repository
|
||||||
WizardKotlinVersion(Versions.KOTLIN, KotlinVersionKind.M, Repositories.KOTLIN_EAP_MAVEN_CENTRAL)
|
WizardKotlinVersion(
|
||||||
|
Versions.KOTLIN,
|
||||||
|
KotlinVersionKind.M,
|
||||||
|
Repositories.KOTLIN_EAP_MAVEN_CENTRAL,
|
||||||
|
KotlinVersionProviderService.getBuildSystemPluginRepository(
|
||||||
|
KotlinVersionKind.M,
|
||||||
|
devRepository = Repositories.JETBRAINS_KOTLIN_DEV
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val initKotlinVersions by pipelineTask(GenerationPhase.PREPARE_GENERATION) {
|
val initKotlinVersions by pipelineTask(GenerationPhase.PREPARE_GENERATION) {
|
||||||
@@ -127,10 +135,10 @@ class KotlinPlugin(context: Context) : Plugin(context) {
|
|||||||
withAction {
|
withAction {
|
||||||
val version = version.propertyValue
|
val version = version.propertyValue
|
||||||
if (version.kind.isStable) return@withAction UNIT_SUCCESS
|
if (version.kind.isStable) return@withAction UNIT_SUCCESS
|
||||||
val pluginRepository = version.repository
|
val pluginRepository = version.buildSystemPluginRepository(buildSystemType) ?: return@withAction UNIT_SUCCESS
|
||||||
BuildSystemPlugin.pluginRepositoreis.addValues(pluginRepository) andThen
|
BuildSystemPlugin.pluginRepositoreis.addValues(pluginRepository) andThen
|
||||||
updateBuildFiles { buildFile ->
|
updateBuildFiles { buildFile ->
|
||||||
buildFile.withIrs(RepositoryIR(pluginRepository)).asSuccess()
|
buildFile.withIrs(RepositoryIR(version.repository)).asSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -38,7 +38,7 @@ data class BintrayRepository(val repository: String, val base: String = "https:/
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class JetBrainsSpace(val repository: String) : CustomMavenRepository {
|
data class JetBrainsSpace(val repository: String) : CustomMavenRepository {
|
||||||
override val url: String = "https://maven.pkg.jetbrains.space/public/p/$repository"
|
override val url: String = "https://maven.pkg.jetbrains.space/$repository"
|
||||||
|
|
||||||
override val idForMaven: String
|
override val idForMaven: String
|
||||||
get() = "jetbrains." + repository.replace('/', '.')
|
get() = "jetbrains." + repository.replace('/', '.')
|
||||||
@@ -49,6 +49,6 @@ object Repositories {
|
|||||||
val KOTLINX = BintrayRepository("kotlin/kotlinx")
|
val KOTLINX = BintrayRepository("kotlin/kotlinx")
|
||||||
val KOTLIN_JS_WRAPPERS_BINTRAY = BintrayRepository("kotlin/kotlin-js-wrappers")
|
val KOTLIN_JS_WRAPPERS_BINTRAY = BintrayRepository("kotlin/kotlin-js-wrappers")
|
||||||
val KOTLIN_EAP_MAVEN_CENTRAL = DefaultRepository.MAVEN_CENTRAL
|
val KOTLIN_EAP_MAVEN_CENTRAL = DefaultRepository.MAVEN_CENTRAL
|
||||||
val KOTLIN_DEV_BINTRAY = BintrayRepository("kotlin/kotlin-dev")
|
val JETBRAINS_COMPOSE_DEV = JetBrainsSpace("public/p/compose/dev")
|
||||||
val JETBRAINS_COMPOSE_DEV = JetBrainsSpace("compose/dev")
|
val JETBRAINS_KOTLIN_DEV = JetBrainsSpace("kotlin/p/kotlin/dev")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user