Wizard: print repositories for Maven
#KT-35715 fixed
This commit is contained in:
+7
@@ -16,6 +16,13 @@
|
|||||||
<kotlin.code.style>official</kotlin.code.style>
|
<kotlin.code.style>official</kotlin.code.style>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>mavenCentral</id>
|
||||||
|
<url>https://repo1.maven.org/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||||
|
|||||||
+15
-7
@@ -27,6 +27,13 @@ data class BuildFileIR(
|
|||||||
fun withModulesUpdated(updater: (ModuleIR) -> TaskResult<ModuleIR>): TaskResult<BuildFileIR> =
|
fun withModulesUpdated(updater: (ModuleIR) -> TaskResult<ModuleIR>): TaskResult<BuildFileIR> =
|
||||||
modules.withModulesUpdated(updater).map { newModules -> copy(modules = newModules) }
|
modules.withModulesUpdated(updater).map { newModules -> copy(modules = newModules) }
|
||||||
|
|
||||||
|
private fun distinctRepositories(): List<RepositoryIR> =
|
||||||
|
irsOfType<RepositoryIR>()
|
||||||
|
.distinctBy { it.repository }
|
||||||
|
.sortedBy { repositoryIR ->
|
||||||
|
if (repositoryIR.repository is DefaultRepository) 0 else 1
|
||||||
|
}
|
||||||
|
|
||||||
override fun BuildFilePrinter.render() = when (this) {
|
override fun BuildFilePrinter.render() = when (this) {
|
||||||
is GradlePrinter -> {
|
is GradlePrinter -> {
|
||||||
irsOfTypeOrNull<GradleImportIR>()?.let { imports ->
|
irsOfTypeOrNull<GradleImportIR>()?.let { imports ->
|
||||||
@@ -44,13 +51,7 @@ data class BuildFileIR(
|
|||||||
sectionCall("plugins", irsOfType<BuildSystemPluginIR>()); nlIndented()
|
sectionCall("plugins", irsOfType<BuildSystemPluginIR>()); nlIndented()
|
||||||
pom.render(this); nl()
|
pom.render(this); nl()
|
||||||
|
|
||||||
irsOfType<RepositoryIR>()
|
sectionCall("repositories", distinctRepositories())
|
||||||
.distinctBy { it.repository }
|
|
||||||
.sortedBy { repositoryIR ->
|
|
||||||
if (repositoryIR.repository is DefaultRepository) 0 else 1
|
|
||||||
}.let {
|
|
||||||
sectionCall("repositories", it)
|
|
||||||
}
|
|
||||||
nl()
|
nl()
|
||||||
modules.render(this)
|
modules.render(this)
|
||||||
irsOfTypeOrNull<FreeIR>()?.let { freeIrs ->
|
irsOfTypeOrNull<FreeIR>()?.let { freeIrs ->
|
||||||
@@ -71,6 +72,13 @@ data class BuildFileIR(
|
|||||||
singleLineNode("kotlin.code.style") { +"official" }
|
singleLineNode("kotlin.code.style") { +"official" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
distinctRepositories().takeIf { it.isNotEmpty() }?.let { repositories ->
|
||||||
|
nl()
|
||||||
|
node("repositories") {
|
||||||
|
repositories.listNl()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val plugins = irsOfType<BuildSystemPluginIR>().takeIf { it.isNotEmpty() }
|
val plugins = irsOfType<BuildSystemPluginIR>().takeIf { it.isNotEmpty() }
|
||||||
|
|
||||||
if (plugins != null) {
|
if (plugins != null) {
|
||||||
|
|||||||
+8
-10
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.BuildFilePrinter
|
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.GradlePrinter
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.MavenPrinter
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.CustomMavenRepository
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.CustomMavenRepository
|
||||||
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.Repository
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Repository
|
||||||
@@ -10,7 +11,7 @@ data class RepositoryIR(val repository: Repository) : BuildSystemIR {
|
|||||||
override fun BuildFilePrinter.render() = when (this) {
|
override fun BuildFilePrinter.render() = when (this) {
|
||||||
is GradlePrinter -> when (repository) {
|
is GradlePrinter -> when (repository) {
|
||||||
is DefaultRepository -> {
|
is DefaultRepository -> {
|
||||||
+repository.type.asGradleName()
|
+repository.type.gradleName
|
||||||
+"()"
|
+"()"
|
||||||
}
|
}
|
||||||
is CustomMavenRepository -> {
|
is CustomMavenRepository -> {
|
||||||
@@ -26,15 +27,12 @@ data class RepositoryIR(val repository: Repository) : BuildSystemIR {
|
|||||||
}
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
|
is MavenPrinter -> {
|
||||||
|
node("repository") {
|
||||||
|
singleLineNode("id") { +repository.idForMaven }
|
||||||
|
singleLineNode("url") { +repository.url }
|
||||||
|
}
|
||||||
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
private fun DefaultRepository.Type.asGradleName() = when (this) {
|
|
||||||
DefaultRepository.Type.JCENTER -> "jcenter"
|
|
||||||
DefaultRepository.Type.MAVEN_CENTRAL -> "mavenCentral"
|
|
||||||
DefaultRepository.Type.GOOGLE -> "google"
|
|
||||||
DefaultRepository.Type.GRADLE_PLUGIN_PORTAL -> "gradlePluginPortal"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-6
@@ -1,10 +1,22 @@
|
|||||||
package org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem
|
package org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem
|
||||||
|
|
||||||
interface Repository
|
interface Repository {
|
||||||
|
val url: String
|
||||||
|
val idForMaven: String
|
||||||
|
}
|
||||||
|
|
||||||
data class DefaultRepository(val type: Type) : Repository {
|
data class DefaultRepository(val type: Type) : Repository {
|
||||||
enum class Type {
|
override val url: String
|
||||||
JCENTER, MAVEN_CENTRAL, GOOGLE, GRADLE_PLUGIN_PORTAL
|
get() = type.url
|
||||||
|
|
||||||
|
override val idForMaven: String
|
||||||
|
get() = type.gradleName
|
||||||
|
|
||||||
|
enum class Type(val gradleName: String, val url: String) {
|
||||||
|
JCENTER("jcenter", "https://jcenter.bintray.com/"),
|
||||||
|
MAVEN_CENTRAL("mavenCentral", "https://repo1.maven.org/maven2/"),
|
||||||
|
GOOGLE("google", "https://dl.google.com/dl/android/maven2/"),
|
||||||
|
GRADLE_PLUGIN_PORTAL("gradlePluginPortal", "https://plugins.gradle.org/m2/")
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -16,12 +28,13 @@ data class DefaultRepository(val type: Type) : Repository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface CustomMavenRepository : Repository {
|
interface CustomMavenRepository : Repository
|
||||||
val url: String
|
|
||||||
}
|
|
||||||
|
|
||||||
data class BintrayRepository(val repository: String) : CustomMavenRepository {
|
data class BintrayRepository(val repository: String) : CustomMavenRepository {
|
||||||
override val url: String = "https://dl.bintray.com/$repository"
|
override val url: String = "https://dl.bintray.com/$repository"
|
||||||
|
|
||||||
|
override val idForMaven: String
|
||||||
|
get() = "bintray." + repository.replace('/', '.')
|
||||||
}
|
}
|
||||||
|
|
||||||
object Repositories {
|
object Repositories {
|
||||||
|
|||||||
Reference in New Issue
Block a user