Skip to content

Commit

Permalink
- Added org.jetbrains.intellij.buildFeature.useCacheRedirector buil…
Browse files Browse the repository at this point in the history
…d feature

- Added `IntelliJPlatformCollectorTransformer` and `IntelliJPlatformExtractTransformer` for handling IntelliJ Platform dependency archives
- Added `jetbrainsAnnotations` dependency helper for adding JetBrains Annotations dependency
- Added general `intellijPlatform` along with product-specific dependency helpers for adding IntelliJ Platform dependency
  • Loading branch information
hsz committed Aug 18, 2023
1 parent a9f2bd4 commit 3e566e3
Show file tree
Hide file tree
Showing 27 changed files with 721 additions and 341 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
### Added
- Configure all tasks that extend task classes instead of just those created by the plugin
- Make JbrResolver prefer Gradle javaToolchains by `JetBrains s.r.o`, if available. Only otherwise start fetching and running a new one.
- Added `org.jetbrains.intellij.buildFeature.useCacheRedirector` build feature
- Added `IntelliJPlatformCollectorTransformer` and `IntelliJPlatformExtractTransformer` for handling IntelliJ Platform dependency archives
- Added `jetbrainsAnnotations` dependency helper for adding JetBrains Annotations dependency
- Added general `intellijPlatform` along with product-specific dependency helpers for adding IntelliJ Platform dependency

### Changed
- New project name: IntelliJ Platform Gradle Plugin
Expand Down
91 changes: 49 additions & 42 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ plugins {
alias(libs.plugins.dokka)
}

version = when (properties("snapshot").get().toBoolean()) {
val isSnapshot = properties("snapshot").get().toBoolean()
version = when (isSnapshot) {
true -> properties("snapshotVersion").map { "$it-SNAPSHOT" }
false -> properties("version")
}.get()
Expand Down Expand Up @@ -213,10 +214,10 @@ gradlePlugin {
tags.set(properties("tags").map { it.split(',') })
}

plugins.create("intellijPluginDependencies") {
id = "org.jetbrains.intellij.platform.dependencies"
displayName = "IntelliJ Platform Gradle Plugin (dependencies)"
implementationClass = "org.jetbrains.intellij.platform.gradleplugin.plugins.IntelliJPlatformDependenciesPlugin"
plugins.create("intellijPluginSettings") {
id = "org.jetbrains.intellij.platform.settings"
displayName = "IntelliJ Platform Gradle Plugin (settings)"
implementationClass = "org.jetbrains.intellij.platform.gradleplugin.plugins.IntelliJPlatformSettingsPlugin"
description = project.description
tags.set(properties("tags").map { it.split(',') })
}
Expand Down Expand Up @@ -244,47 +245,53 @@ publishing {
}
}
publications {
create<MavenPublication>("snapshot") {
create<MavenPublication>("pluginMaven") {
groupId = properties("group").get()
artifactId = properties("artifactId").get()
version = version.toString()

from(components["java"])

pom {
name.set("IntelliJ Platform Gradle Plugin")
description.set(project.description)
url.set(properties("website"))

packaging = "jar"

scm {
connection.set(properties("scmUrl"))
developerConnection.set(properties("scmUrl"))
url.set(properties("vcsUrl"))
}

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://github.com/JetBrains/gradle-intellij-plugin/blob/master/LICENSE")
}
}

developers {
developer {
id.set("zolotov")
name.set("Alexander Zolotov")
email.set("zolotov@jetbrains.com")
}
developer {
id.set("hsz")
name.set("Jakub Chrzanowski")
email.set("jakub.chrzanowski@jetbrains.com")
}
}
}
}

// create<MavenPublication>("snapshot") {
// groupId = properties("group").get()
// artifactId = properties("artifactId").get()
// version = version.toString()
//
// from(components["java"])
//
// pom {
// name.set("IntelliJ Platform Gradle Plugin")
// description.set(project.description)
// url.set(properties("website"))
//
// packaging = "jar"
//
// scm {
// connection.set(properties("scmUrl"))
// developerConnection.set(properties("scmUrl"))
// url.set(properties("vcsUrl"))
// }
//
// licenses {
// license {
// name.set("The Apache License, Version 2.0")
// url.set("https://github.com/JetBrains/gradle-intellij-plugin/blob/master/LICENSE")
// }
// }
//
// developers {
// developer {
// id.set("zolotov")
// name.set("Alexander Zolotov")
// email.set("zolotov@jetbrains.com")
// }
// developer {
// id.set("hsz")
// name.set("Jakub Chrzanowski")
// email.set("jakub.chrzanowski@jetbrains.com")
// }
// }
// }
// }
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version=1.15.0
snapshotVersion=2.0
version=2.0.0
snapshotVersion=2.0.1
snapshot=false
group=org.jetbrains.intellij.platform
artifactId=intellij-platform-gradle-plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
package org.jetbrains.intellij.platform.gradleplugin

import org.gradle.api.Project
import org.gradle.api.provider.ProviderFactory
import org.jetbrains.intellij.platform.gradleplugin.IntelliJPluginConstants.PLUGIN_ID as prefix

enum class BuildFeature(private val defaultValue: Boolean) {
NO_SEARCHABLE_OPTIONS_WARNING(true),
PAID_PLUGIN_SEARCHABLE_OPTIONS_WARNING(true),
SELF_UPDATE_CHECK(true),
USE_CACHE_REDIRECTOR(true),
;

fun getValue(project: Project) = project.findProperty(toString())
?.toString()
?.toBoolean()
.or { defaultValue }
fun getValue(providers: ProviderFactory) = providers.gradleProperty(toString())
.map { it.toBoolean() }
.orElse(defaultValue)

override fun toString() = name
.lowercase()
Expand All @@ -28,10 +29,12 @@ enum class BuildFeature(private val defaultValue: Boolean) {

fun Project.isBuildFeatureEnabled(feature: BuildFeature) =
feature
.getValue(this)
.apply {
when (this) {
true -> "Build feature is enabled: $feature"
false -> "Build feature is disabled: $feature"
}.also { info(logCategory(), it) }
.getValue(providers)
.map { value ->
value.also {
when (value) {
true -> "Build feature is enabled: $feature"
false -> "Build feature is disabled: $feature"
}.also { info(logCategory(), value.toString()) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ import org.jetbrains.intellij.platform.gradleplugin.IntelliJPluginConstants.SETU
import org.jetbrains.intellij.platform.gradleplugin.dependency.PluginDependency
import org.jetbrains.intellij.platform.gradleplugin.tasks.SetupDependenciesTask

@Deprecated("Deprecated in 2.0")
fun Project.intellij() = intellijBase()
@Deprecated("Deprecated in 2.0")
fun Project.intellij(filter: Closure<*>) = intellijBase().matching(filter)
@Deprecated("Deprecated in 2.0")
fun Project.intellij(filter: Action<PatternFilterable>) = intellijBase().matching(filter)
@Deprecated("Deprecated in 2.0")
fun Project.intellij(filter: PatternFilterable) = intellijBase().matching(filter)

@Deprecated("Deprecated in 2.0")
private fun Project.intellijBase(): FileTree {
val setupDependenciesTaskProvider = project.tasks.named<SetupDependenciesTask>(SETUP_DEPENDENCIES_TASK_NAME)
val ideaProvider = setupDependenciesTaskProvider.flatMap { setupDependenciesTask ->
Expand All @@ -37,11 +42,16 @@ private fun Project.intellijBase(): FileTree {
return ideaProvider.get()
}

@Deprecated("Deprecated in 2.0")
fun Project.intellijPlugin(plugin: String) = intellijPluginBase(plugin)
@Deprecated("Deprecated in 2.0")
fun Project.intellijPlugin(plugin: String, filter: Closure<*>) = intellijPluginBase(plugin).matching(filter)
@Deprecated("Deprecated in 2.0")
fun Project.intellijPlugin(plugin: String, filter: Action<PatternFilterable>) = intellijPluginBase(plugin).matching(filter)
@Deprecated("Deprecated in 2.0")
fun Project.intellijPlugin(plugin: String, filter: PatternFilterable) = intellijPluginBase(plugin).matching(filter)

@Deprecated("Deprecated in 2.0")
private fun Project.intellijPluginBase(plugin: String): FileTree {
val extension = extensions.getByType<IntelliJPluginExtension>()

Expand All @@ -56,6 +66,7 @@ private fun Project.intellijPluginBase(plugin: String): FileTree {
return files(dependency.jarFiles).asFileTree
}

@Deprecated("Deprecated in 2.0")
fun Project.intellijPlugins(vararg plugins: String): FileCollection {
val extension = extensions.getByType<IntelliJPluginExtension>()
val selectedPlugins = mutableSetOf<PluginDependency>()
Expand All @@ -76,11 +87,16 @@ fun Project.intellijPlugins(vararg plugins: String): FileCollection {
return files(selectedPlugins.map { it.jarFiles })
}

@Deprecated("Deprecated in 2.0")
fun Project.intellijExtra(extra: String) = intellijExtraBase(extra)
@Deprecated("Deprecated in 2.0")
fun Project.intellijExtra(extra: String, filter: Closure<*>) = intellijExtraBase(extra).matching(filter)
@Deprecated("Deprecated in 2.0")
fun Project.intellijExtra(extra: String, filter: Action<PatternFilterable>) = intellijExtraBase(extra).matching(filter)
@Deprecated("Deprecated in 2.0")
fun Project.intellijExtra(extra: String, filter: PatternFilterable) = intellijExtraBase(extra).matching(filter)

@Deprecated("Deprecated in 2.0")
private fun Project.intellijExtraBase(extra: String): FileTree {
val setupDependenciesTaskProvider = project.tasks.named<SetupDependenciesTask>(SETUP_DEPENDENCIES_TASK_NAME)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ class IntelliJIvyDescriptorFileGenerator(private val projectIdentity: IvyPublica
?.sources
?.takeIf { plugin.builtin }
?.let {
val name = if (isDependencyOnPyCharm(ideaDependency)) "pycharmPC" else "ideaIC"
val name = when(ideaDependency.name) {
"pycharmPY", "pycharmPC" -> "pycharmPC"
else -> "ideaIC"
}
val artifact = IntellijIvyArtifact(it.toPath(), name, "jar", "sources", "sources")
artifact.conf = sourcesConfiguration.name
addArtifact(artifact)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.

package org.jetbrains.intellij.platform.gradleplugin

import org.gradle.api.GradleException

enum class IntelliJPlatformType(val code: String) {
AndroidStudio("AI"),
CLion("CL"),
Gateway("GW"),
GoLand("GO"),
IntellijIdeaCommunity("IC"),
IntellijIdeaUltimate("IU"),
JPS("JPS"),
PhpStorm("PS"),
PyCharmProfessional("PY"),
PyCharmCommunity("PC"),
Rider("RD");

companion object {
private val map = values().associateBy(IntelliJPlatformType::code)

fun fromCode(code: String) = map[code]
?: throw GradleException("Specified type '$code' is unknown. Supported values: ${values().joinToString()}")
}

override fun toString() = code
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ object IntelliJPluginConstants {
const val PLUGIN_ID = "org.jetbrains.intellij.platform"
const val PLUGIN_GROUP_NAME = "intellij"
const val EXTENSION_NAME = "intellijPlatform"
const val INTELLIJ_PLATFORM_REPOSITORY_SETTINGS_NAME = "intellijPlatformRepositoriesSettings"

@Deprecated("Check it")
const val DEFAULT_SANDBOX = "idea-sandbox"

const val BUILD_PLUGIN_TASK_NAME = "buildPlugin"
Expand Down Expand Up @@ -35,6 +37,7 @@ object IntelliJPluginConstants {
const val RUN_IDE_FOR_UI_TESTS_TASK_NAME = "runIdeForUiTests"
const val RUN_IDE_PERFORMANCE_TEST_TASK_NAME = "runIdePerformanceTest"
const val RUN_PLUGIN_VERIFIER_TASK_NAME = "runPluginVerifier"
@Deprecated("Deprecated in 2.0")
const val SETUP_DEPENDENCIES_TASK_NAME = "setupDependencies"
const val SIGN_PLUGIN_TASK_NAME = "signPlugin"
const val VERIFY_PLUGIN_TASK_NAME = "verifyPlugin"
Expand Down Expand Up @@ -76,21 +79,28 @@ object IntelliJPluginConstants {

const val COMPILE_KOTLIN_TASK_NAME = "compileKotlin"
const val KOTLIN_GRADLE_PLUGIN_ID = "org.jetbrains.kotlin.jvm"
@Deprecated("Deprecated in 2.0")
const val IDEA_GRADLE_PLUGIN_ID = "org.jetbrains.gradle.plugin.idea-ext"

const val PLUGIN_XML_DIR_NAME = "patchedPluginXmlFiles"
const val SEARCHABLE_OPTIONS_DIR_NAME = "searchableOptions"
const val SEARCHABLE_OPTIONS_SUFFIX = ".searchableOptions.xml"

// see https://github.com/JetBrains/gradle-intellij-plugin/issues/1060
@Deprecated("Deprecated in 2.0")
const val INTELLIJ_DEFAULT_DEPENDENCIES_CONFIGURATION_NAME = "z10_intellijDefaultDependencies"
@Deprecated("Deprecated in 2.0")
const val PERFORMANCE_TEST_CONFIGURATION_NAME = "z20_performanceTest"
@Deprecated("Deprecated in 2.0")
const val IDEA_PLUGINS_CONFIGURATION_NAME = "z50_ideaPlugins"
@Deprecated("Deprecated in 2.0")
const val IDEA_CONFIGURATION_NAME = "z90_intellij"
const val INTELLIJ_PLATFORM_CONFIGURATION_NAME = "intellijPlatformConfiguration"

const val INSTRUMENTED_JAR_CONFIGURATION_NAME = "instrumentedJar"
const val INSTRUMENTED_JAR_PREFIX = "instrumented"

const val ANNOTATIONS_DEPENDENCY_VERSION = "24.0.0"
const val ANNOTATIONS_DEPENDENCY_VERSION = "24.0.1"
const val DEFAULT_IDEA_VERSION = "LATEST-EAP-SNAPSHOT"
const val MINIMAL_SUPPORTED_GRADLE_VERSION = "8.0"
const val JETBRAINS_JAVA_TOOLCHAIN_VENDOR_NAME = "JetBrains"
Expand All @@ -100,10 +110,6 @@ object IntelliJPluginConstants {
const val RELEASE_SUFFIX_SNAPSHOT = "-SNAPSHOT"
const val RELEASE_SUFFIX_CUSTOM_SNAPSHOT = "-CUSTOM-SNAPSHOT"

const val RELEASE_TYPE_SNAPSHOTS = "snapshots"
const val RELEASE_TYPE_NIGHTLY = "nightly"
const val RELEASE_TYPE_RELEASES = "releases"

const val MARKETPLACE_HOST = "https://plugins.jetbrains.com"
const val IDEA_PRODUCTS_RELEASES_URL = "https://www.jetbrains.com/updates/updates.xml"
const val ANDROID_STUDIO_PRODUCTS_RELEASES_URL = "https://jb.gg/android-studio-releases-list.xml"
Expand All @@ -119,28 +125,4 @@ object IntelliJPluginConstants {

const val VERSION_LATEST = "latest"
const val PERFORMANCE_PLUGIN_ID = "com.jetbrains.performancePlugin"

const val PLATFORM_TYPE_ANDROID_STUDIO = "AI"
const val PLATFORM_TYPE_CLION = "CL"
const val PLATFORM_TYPE_GATEWAY = "GW"
const val PLATFORM_TYPE_GOLAND = "GO"
const val PLATFORM_TYPE_INTELLIJ_COMMUNITY = "IC"
const val PLATFORM_TYPE_INTELLIJ_ULTIMATE = "IU"
const val PLATFORM_TYPE_PHPSTORM = "PS"
const val PLATFORM_TYPE_PYCHARM = "PY"
const val PLATFORM_TYPE_PYCHARM_COMMUNITY = "PC"
const val PLATFORM_TYPE_RIDER = "RD"

val PLATFORM_TYPES = listOf(
PLATFORM_TYPE_ANDROID_STUDIO,
PLATFORM_TYPE_CLION,
PLATFORM_TYPE_GATEWAY,
PLATFORM_TYPE_GOLAND,
PLATFORM_TYPE_INTELLIJ_COMMUNITY,
PLATFORM_TYPE_INTELLIJ_ULTIMATE,
PLATFORM_TYPE_PHPSTORM,
PLATFORM_TYPE_PYCHARM,
PLATFORM_TYPE_PYCHARM_COMMUNITY,
PLATFORM_TYPE_RIDER,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.newInstance
import org.jetbrains.intellij.platform.gradleplugin.IntelliJPlatformType.IntellijIdeaCommunity
import org.jetbrains.intellij.platform.gradleplugin.IntelliJPluginConstants.IDEA_PLUGINS_CONFIGURATION_NAME
import org.jetbrains.intellij.platform.gradleplugin.IntelliJPluginConstants.PLATFORM_TYPE_INTELLIJ_COMMUNITY
import org.jetbrains.intellij.platform.gradleplugin.dependency.IdeaDependency
import org.jetbrains.intellij.platform.gradleplugin.dependency.PluginDependency
import org.jetbrains.intellij.platform.gradleplugin.dependency.PluginsRepositoryConfiguration
Expand Down Expand Up @@ -151,13 +151,6 @@ abstract class IntelliJPluginExtension @Inject constructor(
*/
abstract val sandboxDir: Property<String>

/**
* The IntelliJ-based IDE distributions repository URL.
*
* Default value: `https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository`
*/
abstract val intellijRepository: Property<String>

/**
* Configures repositories for downloading plugin dependencies.
*
Expand Down Expand Up @@ -239,7 +232,7 @@ abstract class IntelliJPluginExtension @Inject constructor(

fun getVersionType(): Provider<String> = version.map {
versionTypeRegex.matchEntire(it)?.groupValues?.getOrNull(1)
?: type.getOrElse(PLATFORM_TYPE_INTELLIJ_COMMUNITY)
?: type.getOrElse(IntellijIdeaCommunity.toString())
}

fun addPluginDependency(pluginDependency: PluginDependency) {
Expand Down
Loading

0 comments on commit 3e566e3

Please sign in to comment.