diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/LinuxDistributionCustomizer.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/LinuxDistributionCustomizer.kt index 56ae82b7734e..7a8892abf1ba 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/LinuxDistributionCustomizer.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/LinuxDistributionCustomizer.kt @@ -3,6 +3,7 @@ package org.jetbrains.intellij.build import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf +import kotlinx.collections.immutable.plus import org.jetbrains.annotations.ApiStatus import org.jetbrains.intellij.build.impl.support.RepairUtilityBuilder import org.jetbrains.intellij.build.kotlin.KotlinBinaries @@ -24,10 +25,12 @@ inline fun communityLinuxCustomizer(projectHome: String, configure: LinuxDistrib init { iconPngPath = "$projectHome/build/conf/ideaCE/linux/images/icon_CE_128.png" iconPngPathForEAP = "$projectHome/build/conf/ideaCE/linux/images/icon_CE_EAP_128.png" - snapName = "intellij-idea-community" - snapDescription = - "The most intelligent Java IDE. Every aspect of IntelliJ IDEA is specifically designed to maximize developer productivity. " + - "Together, powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience." + snaps += Snap( + name = "intellij-idea-community", + description = + "The most intelligent Java IDE. Every aspect of IntelliJ IDEA is specifically designed to maximize developer productivity. " + + "Together, powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience." + ) } override fun getRootDirectoryName(appInfo: ApplicationInfoProperties, buildNumber: String): String = "idea-IC-$buildNumber" @@ -98,19 +101,34 @@ open class LinuxDistributionCustomizer { } /** - * If `true`, a separate `*[org.jetbrains.intellij.build.impl.LinuxDistributionBuilder.NO_RUNTIME_SUFFIX].tar.gz` artifact without a runtime will be produced. + * If `true`, a separate `*[org.jetbrains.intellij.build.impl.NO_RUNTIME_SUFFIX].tar.gz` artifact without a runtime will be produced. */ var buildArtifactWithoutRuntime: Boolean = false - /** - * Set both properties if a .snap package should be produced. - * [snapName] is the name of the package (e.g., "intellij-idea" or "pycharm"). - * [snapDescription] is the plain text description of the package. - * [snapLegacyAliases] are legacy names for the package, e.g., "intellij-idea-ultimate" or "pycharm-community". - */ + @Deprecated(message = "IJI-2568", replaceWith = ReplaceWith("snaps += Snap(name = value, description = TODO())")) var snapName: String? = null + + @Deprecated(message = "IJI-2568", replaceWith = ReplaceWith("snaps += Snap(name = TODO(), description = value)")) var snapDescription: String? = null - var snapLegacyAliases: List = emptyList() + + /** + * Add an instance of [Snap] if a .snap package should be produced. + */ + var snaps: PersistentList = persistentListOf() + + /** + * [name] is the name of the package (e.g., "intellij-idea" or "pycharm"). + * [description] is the plain text description of the package. + */ + data class Snap( + val name: String, + val description: String, + ) { + init { + require(name.isNotBlank()) { "Snap name cannot be blank" } + require(description.isNotBlank()) { "$name Snap description cannot be blank" } + } + } /** * Name of the root directory inside the .tar.gz archive. diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.kt index da19d8299ebb..f1c84b6ed8c0 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.kt @@ -234,16 +234,26 @@ class LinuxDistributionBuilder( Span.current().addEvent("Linux .snap package build is disabled") return } - val snapName = requireNotNull(customizer.snapName) { - "Linux .snap package build requires 'snapName' in ${customizer::class.java.simpleName}" - } - buildSnapPackage(snapName, runtimeDir, unixDistPath, arch, targetLibcImpl) - customizer.snapLegacyAliases.forEach { - buildSnapPackage(snapName = it, runtimeDir, unixDistPath, arch, targetLibcImpl) + customizer.snaps.forEach { + buildSnapPackage( + snapName = it.name, + snapDescription = it.description, + runtimeDir = runtimeDir, + unixDistPath = unixDistPath, + arch = arch, + targetLibcImpl = targetLibcImpl, + ) } } - private suspend fun buildSnapPackage(snapName: String, runtimeDir: Path, unixDistPath: Path, arch: JvmArchitecture, targetLibcImpl: LinuxLibcImpl) = BuildSnapSemaphore.withPermit { + private suspend fun buildSnapPackage( + snapName: String, + snapDescription: String, + runtimeDir: Path, + unixDistPath: Path, + arch: JvmArchitecture, + targetLibcImpl: LinuxLibcImpl, + ) = BuildSnapSemaphore.withPermit { val architecture = getSnapArchName(arch) val snapDir = context.paths.buildOutputDir.resolve("dist.snap.$snapName.$architecture") val snapArtifactName = getSnapArtifactName(snapName, arch) @@ -256,7 +266,6 @@ class LinuxDistributionBuilder( } check(Docker.isAvailable) { "Docker is required to build .snap package" } requireNotNull(iconPngPath) { "'iconPngPath' not set" } - check(!customizer.snapDescription.isNullOrBlank()) { "'snapDescription' not set" } span.addEvent("prepare files") val appInfo = context.applicationInfo @@ -284,7 +293,7 @@ class LinuxDistributionBuilder( "NAME" to snapName, "VERSION" to snapVersion, "SUMMARY" to productName, - "DESCRIPTION" to (customizer.snapDescription ?: ""), + "DESCRIPTION" to snapDescription, "GRADE" to if (appInfo.isEAP) "devel" else "stable", "LAUNCHER" to "bin/${launcherFileName}" ) @@ -340,9 +349,7 @@ class LinuxDistributionBuilder( val archSuffix = suffix(arch, targetLibcImpl) return sequenceOf("${archSuffix}.tar.gz", "${NO_RUNTIME_SUFFIX}${archSuffix}.tar.gz") .map { suffix -> context.productProperties.getBaseArtifactName(context) + suffix } - .plus(customizer.snapName?.let { getSnapArtifactName(it, arch) }) - .filterNotNull() - .plus(customizer.snapLegacyAliases.map { getSnapArtifactName(it, arch) }) + .plus(customizer.snaps.asSequence().map { getSnapArtifactName(it.name, arch) }) .map(context.paths.artifactDir::resolve) .filter { it.exists() } .toList() diff --git a/python/build/src/org/jetbrains/intellij/build/pycharm/PyCharmCommunityProperties.kt b/python/build/src/org/jetbrains/intellij/build/pycharm/PyCharmCommunityProperties.kt index e4381aaebedd..c4f5ebc4c6bb 100644 --- a/python/build/src/org/jetbrains/intellij/build/pycharm/PyCharmCommunityProperties.kt +++ b/python/build/src/org/jetbrains/intellij/build/pycharm/PyCharmCommunityProperties.kt @@ -112,10 +112,12 @@ open class PyCharmCommunityProperties(protected val communityHome: Path) : PyCha init { iconPngPath = "${communityHome}/python/build/resources/PyCharmCore128.png" iconPngPathForEAP = "${communityHome}/python/build/resources/PyCharmCore128_EAP.png" - snapName = "pycharm-community" - snapDescription = - "Python IDE for professional developers. Save time while PyCharm takes care of the routine. " + - "Focus on bigger things and embrace the keyboard-centric approach to get the most of PyCharm’s many productivity features." + snaps += Snap( + name = "pycharm-community", + description = + "Python IDE for professional developers. Save time while PyCharm takes care of the routine. " + + "Focus on bigger things and embrace the keyboard-centric approach to get the most of PyCharm’s many productivity features." + ) } override fun getRootDirectoryName(appInfo: ApplicationInfoProperties, buildNumber: String): String {