Skip to content

Internalize util functionality #1147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
524 changes: 524 additions & 0 deletions api/gradle-intellij-plugin.api

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
id("com.gradle.plugin-publish") version "1.0.0"
id("org.jetbrains.changelog") version "1.3.1"
id("org.jetbrains.dokka") version "1.7.10"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.11.1"
}

version = when (properties("snapshot")?.toBoolean() ?: false) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/jetbrains/intellij/BuildFeature.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum class BuildFeature(private val defaultValue: Boolean) {
.let { "$prefix.buildFeature.$it" }
}

fun Project.isBuildFeatureEnabled(feature: BuildFeature) =
internal fun Project.isBuildFeatureEnabled(feature: BuildFeature) =
feature.getValue(this).apply {
when (this) {
true -> "Build feature is enabled: $feature"
Expand Down
26 changes: 13 additions & 13 deletions src/main/kotlin/org/jetbrains/intellij/DependenciesUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import org.jetbrains.intellij.IntelliJPluginConstants.SETUP_DEPENDENCIES_TASK_NA
import org.jetbrains.intellij.dependency.PluginDependency
import org.jetbrains.intellij.tasks.SetupDependenciesTask

fun Project.intellij(): FileCollection = intellijBase()
fun Project.intellij(filter: Closure<*>): FileCollection = intellijBase().matching(filter)
fun Project.intellij(filter: Action<PatternFilterable>): FileCollection = intellijBase().matching(filter)
fun Project.intellij(filter: PatternFilterable): FileCollection = intellijBase().matching(filter)
internal fun Project.intellij(): FileCollection = intellijBase()
internal fun Project.intellij(filter: Closure<*>): FileCollection = intellijBase().matching(filter)
internal fun Project.intellij(filter: Action<PatternFilterable>): FileCollection = intellijBase().matching(filter)
internal fun Project.intellij(filter: PatternFilterable): FileCollection = intellijBase().matching(filter)

private fun Project.intellijBase(): FileTree {
val setupDependenciesTaskProvider = project.tasks.named<SetupDependenciesTask>(SETUP_DEPENDENCIES_TASK_NAME)
Expand All @@ -33,10 +33,10 @@ private fun Project.intellijBase(): FileTree {
return files(setupDependenciesTask.idea.get().jarFiles).asFileTree
}

fun Project.intellijPlugin(plugin: String): FileCollection = intellijPluginBase(plugin)
fun Project.intellijPlugin(plugin: String, filter: Closure<*>): FileCollection = intellijPluginBase(plugin).matching(filter)
fun Project.intellijPlugin(plugin: String, filter: Action<PatternFilterable>): FileCollection = intellijPluginBase(plugin).matching(filter)
fun Project.intellijPlugin(plugin: String, filter: PatternFilterable): FileCollection = intellijPluginBase(plugin).matching(filter)
internal fun Project.intellijPlugin(plugin: String): FileCollection = intellijPluginBase(plugin)
internal fun Project.intellijPlugin(plugin: String, filter: Closure<*>): FileCollection = intellijPluginBase(plugin).matching(filter)
internal fun Project.intellijPlugin(plugin: String, filter: Action<PatternFilterable>): FileCollection = intellijPluginBase(plugin).matching(filter)
internal fun Project.intellijPlugin(plugin: String, filter: PatternFilterable): FileCollection = intellijPluginBase(plugin).matching(filter)

private fun Project.intellijPluginBase(plugin: String): FileTree {
val extension = extensions.getByType<IntelliJPluginExtension>()
Expand All @@ -53,7 +53,7 @@ private fun Project.intellijPluginBase(plugin: String): FileTree {
return files(jarFiles).asFileTree
}

fun Project.intellijPlugins(vararg plugins: String): FileCollection {
internal fun Project.intellijPlugins(vararg plugins: String): FileCollection {
val extension = extensions.getByType<IntelliJPluginExtension>()
val selectedPlugins = mutableSetOf<PluginDependency>()
val nonValidPlugins = mutableListOf<String>()
Expand All @@ -73,10 +73,10 @@ fun Project.intellijPlugins(vararg plugins: String): FileCollection {
return files(selectedPlugins.map { it.jarFiles })
}

fun Project.intellijExtra(extra: String): FileCollection = intellijExtraBase(extra)
fun Project.intellijExtra(extra: String, filter: Closure<*>): FileCollection = intellijExtraBase(extra).matching(filter)
fun Project.intellijExtra(extra: String, filter: Action<PatternFilterable>): FileCollection = intellijExtraBase(extra).matching(filter)
fun Project.intellijExtra(extra: String, filter: PatternFilterable): FileCollection = intellijExtraBase(extra).matching(filter)
internal fun Project.intellijExtra(extra: String): FileCollection = intellijExtraBase(extra)
internal fun Project.intellijExtra(extra: String, filter: Closure<*>): FileCollection = intellijExtraBase(extra).matching(filter)
internal fun Project.intellijExtra(extra: String, filter: Action<PatternFilterable>): FileCollection = intellijExtraBase(extra).matching(filter)
internal fun Project.intellijExtra(extra: String, filter: PatternFilterable): FileCollection = intellijExtraBase(extra).matching(filter)

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 @@ -14,7 +14,7 @@ import java.io.Writer
import java.text.SimpleDateFormat
import java.util.*

class IntelliJIvyDescriptorFileGenerator(private val projectIdentity: IvyPublicationIdentity) {
internal class IntelliJIvyDescriptorFileGenerator(private val projectIdentity: IvyPublicationIdentity) {

private val ivyFileEncoding = "UTF-8"
private val ivyDatePattern = "yyyyMMddHHmmss"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package org.jetbrains.intellij

import org.gradle.api.component.SoftwareComponent

class IntelliJPluginLibrary : SoftwareComponent {
internal class IntelliJPluginLibrary : SoftwareComponent {

override fun getName() = "intellij-plugin"
}
2 changes: 1 addition & 1 deletion src/main/kotlin/org/jetbrains/intellij/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package org.jetbrains.intellij

class Version(
internal class Version(
val major: Int = 0,
val minor: Int = 0,
val patch: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.io.File
import java.net.URI
import java.net.URL

class CustomPluginsRepository(repositoryUrl: String) : PluginsRepository {
internal class CustomPluginsRepository(repositoryUrl: String) : PluginsRepository {

private val pluginsXmlUri: URI
private val repositoryUrl: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package org.jetbrains.intellij.dependency

import java.io.File

object IdePluginSourceZipFilesProvider {
internal object IdePluginSourceZipFilesProvider {

private val pluginIdToSourceZipFileName = mapOf(
"com.intellij.css" to "src_css-api.zip",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import java.util.zip.ZipFile
import javax.inject.Inject

@Suppress("BooleanMethodIsAlwaysInverted")
abstract class IdeaDependencyManager @Inject constructor(
internal abstract class IdeaDependencyManager @Inject constructor(
private val repositoryUrl: String,
private val ideaDependencyCachePath: String,
private val archiveUtils: ArchiveUtils,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,15 @@ package org.jetbrains.intellij.dependency
import org.jetbrains.intellij.collectJars
import java.io.File

class IdeaExtraDependency(val name: String, val classes: File) {

val jarFiles = when {
classes.isDirectory -> collectJars(classes)
else -> setOf(classes)
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as IdeaExtraDependency

if (name != other.name) return false
if (classes != other.classes) return false
if (jarFiles != other.jarFiles) return false

return true
}

override fun hashCode(): Int {
var result = name.hashCode()
result = 31 * result + classes.hashCode()
result = 31 * result + jarFiles.hashCode()
return result
}
data class IdeaExtraDependency(
val name: String,
val jarFiles: Set<File>,
) {
constructor(name: String, classes: File) : this(
name = name,
jarFiles = when {
classes.isDirectory -> collectJars(classes).toSet()
else -> setOf(classes)
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.gradle.api.internal.tasks.DefaultTaskDependency
import org.gradle.api.publish.ivy.IvyArtifact
import java.io.File

class IntellijIvyArtifact(
internal class IntellijIvyArtifact(
internal val file: File,
internal var name: String,
private var extension: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package org.jetbrains.intellij.dependency

import java.io.File

class JpsIdeaDependency(
internal class JpsIdeaDependency(
version: String,
buildNumber: String,
classes: File,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package org.jetbrains.intellij.dependency

import java.io.File

class LocalIdeaDependency(
internal class LocalIdeaDependency(
name: String,
version: String,
buildNumber: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.jetbrains.intellij.utils.DependenciesDownloader
import org.jetbrains.intellij.utils.mavenRepository
import java.io.File

interface MavenRepository : PluginsRepository {
internal interface MavenRepository : PluginsRepository {

var resolvedDependency: Boolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.jetbrains.plugin.structure.intellij.version.IdeVersion
import org.jetbrains.intellij.collectJars
import java.io.File

class PluginDependencyImpl(
internal class PluginDependencyImpl(
override val id: String,
override val platformPluginId: String?,
override val version: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.io.File
import java.nio.file.Paths
import javax.inject.Inject

abstract class PluginDependencyManager @Inject constructor(
internal abstract class PluginDependencyManager @Inject constructor(
gradleHomePath: String,
private val ideaDependency: IdeaDependency?,
private val pluginsRepositories: List<PluginsRepository>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.jetbrains.plugin.structure.intellij.version.IdeVersion
import org.jetbrains.intellij.error
import java.io.File

class PluginProjectDependency(private val pluginDirectory: File, val context: String?) : PluginDependency {
internal class PluginProjectDependency(private val pluginDirectory: File, val context: String?) : PluginDependency {

private val pluginDependency: PluginDependencyImpl? by lazy {
pluginDirectory.takeIf { it.exists() }?.let {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/jetbrains/intellij/jbr/Jbr.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package org.jetbrains.intellij.jbr

import java.io.File

data class Jbr(
internal data class Jbr(
val version: String,
val javaHome: File,
val javaExecutable: String?,
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/jetbrains/intellij/jbr/JbrResolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.nio.file.Path
import java.util.*
import javax.inject.Inject

abstract class JbrResolver @Inject constructor(
internal abstract class JbrResolver @Inject constructor(
private val jreRepository: String,
private val isOffline: Boolean,
private val archiveUtils: ArchiveUtils,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElement
import javax.xml.bind.annotation.XmlRootElement

@XmlRootElement(name = "content")
data class AndroidStudioReleases(
internal data class AndroidStudioReleases(

@set:XmlAttribute
var version: Int = 0,
Expand All @@ -17,7 +17,7 @@ data class AndroidStudioReleases(
var items: List<Item> = mutableListOf(),
) : Serializable

data class Item(
internal data class Item(

@set:XmlElement
var name: String = "",
Expand All @@ -44,7 +44,7 @@ data class Item(
var downloads: List<Download> = mutableListOf(),
) : Serializable

data class Download(
internal data class Download(

@set:XmlElement
var link: String = "",
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/jetbrains/intellij/model/MavenMetadata.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import javax.xml.bind.annotation.XmlElementWrapper
import javax.xml.bind.annotation.XmlRootElement

@XmlRootElement(name = "metadata")
data class MavenMetadata(
internal data class MavenMetadata(

@set:XmlElement
var groupId: String? = null,
Expand All @@ -19,7 +19,7 @@ data class MavenMetadata(
var versioning: MavenMetadataVersioning? = null,
)

data class MavenMetadataVersioning(
internal data class MavenMetadataVersioning(

@set:XmlElement
var latest: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlRegistry

@Suppress("unused")
@XmlRegistry
class ObjectFactory {
internal class ObjectFactory {

fun createPluginsCache() = PluginsCache()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package org.jetbrains.intellij.model

data class PerformanceTestResult(
internal data class PerformanceTestResult(
val testName: String,
val statistic: PerformanceTestStatistic,
val script: PerformanceTestScript,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package org.jetbrains.intellij.model

class PerformanceTestScript private constructor(
internal class PerformanceTestScript private constructor(
val projectName: String?,
val scriptContent: String?,
val assertionTimeout: Long?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package org.jetbrains.intellij.model

class PerformanceTestStatistic private constructor(
internal class PerformanceTestStatistic private constructor(
val totalTime: Long?,
val responsive: Long?,
val averageResponsive: Long?,
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/jetbrains/intellij/model/PluginsCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import javax.xml.bind.annotation.XmlElementWrapper
import javax.xml.bind.annotation.XmlRootElement

@XmlRootElement(name = "plugins")
data class PluginsCache(
internal data class PluginsCache(

@set:XmlElement(name = "plugin")
var plugins: List<PluginsCachePlugin> = mutableListOf(),
) : Serializable

data class PluginsCachePlugin(
internal data class PluginsCachePlugin(

@set:XmlAttribute
var id: String = "",
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/org/jetbrains/intellij/model/ProductInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.gradle.api.GradleException
import org.gradle.internal.os.OperatingSystem

@Serializable
data class ProductInfo(
internal data class ProductInfo(
var name: String? = null,
var version: String? = null,
var versionSuffix: String? = null,
Expand Down Expand Up @@ -36,7 +36,7 @@ data class ProductInfo(
}

@Serializable
data class Launch(
internal data class Launch(
var os: OS? = null,
var launcherPath: String? = null,
var javaExecutablePath: String? = null,
Expand All @@ -47,12 +47,12 @@ data class Launch(
)

@Serializable
data class CustomProperty(
internal data class CustomProperty(
var key: String? = null,
var value: String? = null,
)

@Suppress("EnumEntryName")
enum class OS {
internal enum class OS {
Linux, Windows, macOS
}
Loading