mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 06:47:40 +07:00
OPENIDE #8 Build OpenIDE with bundled amplicode
This commit is contained in:
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@@ -1290,6 +1290,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/util/test-generator-api/kotlin.util.test-generator-api.iml" filepath="$PROJECT_DIR$/plugins/kotlin/util/test-generator-api/kotlin.util.test-generator-api.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/util/test-generator-fe10/kotlin.util.test-generator-fe10.iml" filepath="$PROJECT_DIR$/plugins/kotlin/util/test-generator-fe10/kotlin.util.test-generator-fe10.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/util/test-generator-fir/kotlin.util.test-generator-fir.iml" filepath="$PROJECT_DIR$/plugins/kotlin/util/test-generator-fir/kotlin.util.test-generator-fir.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/openide/openide.iml" filepath="$PROJECT_DIR$/openide/openide.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -27,5 +27,6 @@
|
||||
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.buildScripts.downloader" />
|
||||
<orderEntry type="library" name="maven-resolver-provider" level="project" />
|
||||
<orderEntry type="module" module-name="openide" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -8,6 +8,7 @@ import org.jetbrains.intellij.build.createCommunityBuildContext
|
||||
import org.jetbrains.intellij.build.impl.buildDistributions
|
||||
import org.jetbrains.intellij.build.telemetry.TraceManager.spanBuilder
|
||||
import org.jetbrains.intellij.build.telemetry.use
|
||||
import ru.openide.OpenIdePluginBundler
|
||||
|
||||
internal object OpenSourceCommunityInstallersBuildTarget {
|
||||
@JvmStatic
|
||||
@@ -22,6 +23,7 @@ internal object OpenSourceCommunityInstallersBuildTarget {
|
||||
|
||||
runBlocking(Dispatchers.Default) {
|
||||
val context = createCommunityBuildContext(options)
|
||||
OpenIdePluginBundler.bundleAmplicodePlugin(context)
|
||||
CompilationTasks.create(context).compileModules(moduleNames = null, includingTestsInModules = listOf("intellij.platform.jps.build.tests"))
|
||||
buildDistributions(context)
|
||||
spanBuilder("build standalone JPS").use {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package org.jetbrains.intellij.build
|
||||
|
||||
import org.jetbrains.intellij.build.kotlin.KotlinBinaries
|
||||
import ru.openide.OpenIdePluginBundler
|
||||
import java.nio.file.Path
|
||||
|
||||
open class OpenIdeProperties(val communityHomeDir: Path): IdeaCommunityProperties(communityHomeDir) {
|
||||
@@ -79,4 +80,8 @@ open class OpenIdeProperties(val communityHomeDir: Path): IdeaCommunityPropertie
|
||||
override fun getBaseArtifactName(appInfo: ApplicationInfoProperties, buildNumber: String) = "openIDE-$buildNumber"
|
||||
|
||||
override fun getOutputDirectoryName(appInfo: ApplicationInfoProperties) = "open-ide"
|
||||
|
||||
override fun getAdditionalPluginPaths(context: BuildContext): List<Path> {
|
||||
return OpenIdePluginBundler.getBundlePluginPaths(context)
|
||||
}
|
||||
}
|
||||
16
openide/openide.iml
Normal file
16
openide/openide.iml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="kotlin-stdlib" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.core" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
|
||||
<orderEntry type="module" module-name="intellij.platform.buildScripts.downloader" />
|
||||
<orderEntry type="module" module-name="intellij.platform.buildScripts" />
|
||||
</component>
|
||||
</module>
|
||||
57
openide/src/ru/openide/OpenIdePluginBundler.kt
Normal file
57
openide/src/ru/openide/OpenIdePluginBundler.kt
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) Haulmont 2024. All Rights Reserved.
|
||||
// Use is subject to license terms.
|
||||
package ru.openide
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.util.io.HttpRequests
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.intellij.build.BuildContext
|
||||
import org.jetbrains.intellij.build.dependencies.BuildDependenciesDownloader
|
||||
import org.jetbrains.intellij.build.dependencies.BuildDependenciesExtractOptions
|
||||
import org.jetbrains.intellij.build.BuildPaths.Companion.COMMUNITY_ROOT
|
||||
import java.net.URI
|
||||
import java.nio.file.Path
|
||||
|
||||
object OpenIdePluginBundler {
|
||||
|
||||
private const val PLUGINS_DIR = "build/download/plugins"
|
||||
private const val AMPLICODE_URL = "https://amplicode.ru"
|
||||
private const val AMPLICODE_MARKETPLACE_URL = "https://amplicode.ru/jetbrains-marketplace"
|
||||
|
||||
fun getBundlePluginPaths(context: BuildContext): List<Path> {
|
||||
val communityHomeDir = context.paths.communityHomeDir
|
||||
return listOf(Path.of("${communityHomeDir}/$PLUGINS_DIR/amplicode"))
|
||||
}
|
||||
|
||||
fun bundleAmplicodePlugin(context: BuildContext) {
|
||||
val majorVersion = context.buildNumber.substringBefore('.')
|
||||
val uri = resolveAmplicodeUri(majorVersion)
|
||||
val archivePath = BuildDependenciesDownloader.downloadFileToCacheLocation(COMMUNITY_ROOT, uri)
|
||||
val targetDir = context.paths.communityHomeDir.resolve("$PLUGINS_DIR/amplicode")
|
||||
BuildDependenciesDownloader.extractFile(archivePath, targetDir, COMMUNITY_ROOT, BuildDependenciesExtractOptions.STRIP_ROOT)
|
||||
}
|
||||
|
||||
private fun resolveAmplicodeUri(majorVersion: String): URI {
|
||||
val result = runCatching {
|
||||
HttpRequests.request(AMPLICODE_MARKETPLACE_URL)
|
||||
.connect { JDOMUtil.load(it.getReader()) }
|
||||
.let { findFragmentUrl(it, majorVersion) }
|
||||
}
|
||||
|
||||
val specificUrl = result.getOrThrow().substring(1)
|
||||
return URI.create("$AMPLICODE_URL$specificUrl")
|
||||
}
|
||||
|
||||
private fun findFragmentUrl(element: Element?, majorVersion: String): String {
|
||||
return element?.getChildren("plugin")
|
||||
?.firstOrNull { it.getAttributeValue("version").extractMajorVersion() == majorVersion }
|
||||
?.getAttributeValue("url")
|
||||
?: throw RuntimeException("Amlicode plugin url not found for $majorVersion version")
|
||||
}
|
||||
|
||||
private fun String.extractMajorVersion(): String? {
|
||||
val regex = Regex("""-(\d+?)-""")
|
||||
val match = regex.find(this)
|
||||
return match?.groupValues?.get(1)
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ object WhiteListUrls {
|
||||
"https://plugins.jetbrains.com", // TODO [OpenIDE]: replace url
|
||||
"https://downloads.marketplace.jetbrains.com/files", // TODO [OpenIDE]: replace url
|
||||
"https://repo1.maven.org/maven2/net/sourceforge/plantuml/plantuml/1.2023.10/plantuml-1.2023.10.jar",
|
||||
"https://amplicode.ru"
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
||||
Reference in New Issue
Block a user