Skip to content
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

use XDG standards for cache dir, and use Gradle Providers API more #1119

Merged
merged 2 commits into from
Sep 27, 2022
Merged
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Fixed
- Invalidate instrumented classes bound to forms if GUI changed [IDEA-298989](https://youtrack.jetbrains.com/issue/IDEA-298989/Duplicate-method-name-getFont)
- Revert pushing project resource directories to the end of classpath in the test task context. ([#1101](../../../1161))
- Plugin verification cache directory now follows XDG cache standards.

## [1.9.0]
### Added
Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,7 @@ open class IntelliJPlugin : Plugin<Project> {
verificationReportsDir.convention(project.provider {
"${project.buildDir}/reports/pluginVerifier"
})
downloadDir.convention(project.provider {
ideDownloadDir().toString()
})
downloadDir.convention(ideDownloadDir().map { it.toFile().invariantSeparatorsPath })
teamCityOutputFormat.convention(false)
subsystemsToCheck.convention("all")
ideDir.convention(runIdeTaskProvider.get().ideDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
package org.jetbrains.intellij.tasks

import com.jetbrains.plugin.structure.base.utils.createDir
import org.apache.commons.io.FileUtils
import org.apache.tools.ant.util.TeeOutputStream
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.InvalidUserDataException
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.internal.ConventionTask
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
Expand Down Expand Up @@ -47,10 +48,11 @@ import java.nio.file.Paths
import java.util.EnumSet
import javax.inject.Inject

open class RunPluginVerifierTask @Inject constructor(
abstract class RunPluginVerifierTask @Inject constructor(
private val objectFactory: ObjectFactory,
private val execOperations: ExecOperations,
) : ConventionTask() {
private val providers: ProviderFactory,
) : DefaultTask() {

companion object {
private const val METADATA_URL = "$PLUGIN_VERIFIER_REPOSITORY/org/jetbrains/intellij/plugins/verifier-cli/maven-metadata.xml"
Expand Down Expand Up @@ -411,19 +413,20 @@ open class RunPluginVerifierTask @Inject constructor(
*
* @return Plugin Verifier home directory
*/
private fun verifierHomeDir(): Path {
System.getProperty("plugin.verifier.home.dir")?.let {
return Paths.get(it)
}

System.getProperty("user.home")?.let {
return Paths.get(it, ".pluginVerifier")
}

return FileUtils.getTempDirectory().toPath().resolve(".pluginVerifier")
private fun verifierHomeDir(): Provider<Path> {
return providers.systemProperty("plugin.verifier.home.dir")
.orElse(
providers.environmentVariable("XDG_CACHE_HOME").map { "$it/pluginVerifier" }
)
.orElse(
providers.systemProperty("user.home").map { "$it/.cache/pluginVerifier" }
).map {
Paths.get(it)
}.orElse(
temporaryDir.resolve("pluginVerifier").toPath()
)
}


/**
* Resolves the Plugin Verifier version.
* If set to [IntelliJPluginConstants.VERSION_LATEST], there's request to [METADATA_URL]
Expand Down Expand Up @@ -549,7 +552,8 @@ open class RunPluginVerifierTask @Inject constructor(
*
* @return directory for downloaded IDEs
*/
internal fun ideDownloadDir() = verifierHomeDir().resolve("ides").createDir()
internal fun ideDownloadDir(): Provider<Path> =
verifierHomeDir().map { it.resolve("ides").createDir() }

enum class FailureLevel(val sectionHeading: String, val message: String) {
COMPATIBILITY_WARNINGS(
Expand Down