Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
023d66f
first dirty prototype of SBT resolution caching
Mar 14, 2023
b4d2e7f
less hacky SBT structure portability
Mar 14, 2023
3fbffb5
project file hashing is deterministic
Mar 14, 2023
0f119c8
BuildFilesHash input includes filenames
Mar 14, 2023
bdfd1fa
simple http-based sbt structure remote caching
Mar 14, 2023
a2e5a0a
tmp plugin version
Mar 14, 2023
398487d
credentials file format consistent with the one used by sbt artifact …
Mar 14, 2023
940d0c7
limited hashed files to .sbt, .scala and .properties files
Mar 14, 2023
3c18787
fixed structure localization on windows
Mar 14, 2023
20107a9
more workarounds for windows
Mar 14, 2023
18ef036
cosmetic
Mar 14, 2023
e3fe4df
logging
Mar 14, 2023
967c31b
making sure hash is the same on all platforms
Mar 15, 2023
0af8e9c
marking locally nonexistent files in sbt structure
Mar 15, 2023
37bdfe2
more fixes and workarounds for local-os-specific XML serialization of…
Mar 15, 2023
27c1e7c
more horrible workarounds for path problems
Mar 15, 2023
9b9235f
including some sbt settings into build definition hash
Mar 15, 2023
aa69029
removed debug logs
Mar 15, 2023
5f4f1d4
version
Mar 15, 2023
df752a8
more and more hacks
Mar 15, 2023
37c0ef4
logging improvements
Mar 15, 2023
ef239bc
logging improvements
Mar 15, 2023
6fcb5e6
improved logging of build def hashing
Mar 15, 2023
ffa2c7d
improved logging of build def hashing
Mar 15, 2023
d67ace1
cosmetic
Mar 15, 2023
8c1ef3d
jar paths in unlocalized structure XML are resolver-agnostic
Mar 17, 2023
e6d5e12
clearing sbt update-cache before generating to-be-cached structure
Mar 17, 2023
6f1258d
including SBT version into build definition hash
Mar 17, 2023
a2f771b
improved logging and coursier cache .error file awareness
Mar 17, 2023
223a8b2
more logging improvements
Mar 17, 2023
9ce9124
proper project settings for structure cache instead of system properties
Mar 18, 2023
3b4fe2c
bundling some strings
Mar 18, 2023
719d151
IDEA can be allowed to manually download missing deps from cached str…
Mar 19, 2023
8a8a5fc
improved error handling
Mar 20, 2023
f821746
xz compression for remote structure cache
Mar 20, 2023
efee08e
temporary plugin id
Mar 20, 2023
851a311
temporary plugin name
Mar 20, 2023
c64a692
temporary plugin description
Mar 20, 2023
57dcd90
temporary plugin name in build.sbt
Mar 20, 2023
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.nio.file.Paths

// Global build settings

(ThisBuild / intellijPluginName) := "Scala"
(ThisBuild / intellijPluginName) := "Scala (AVSystem)"

(ThisBuild / intellijBuild) := Versions.intellijVersion

Expand Down
11 changes: 8 additions & 3 deletions pluginXml/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
<idea-plugin url="https://confluence.jetbrains.com/display/SCA/Scala+Plugin+for+IntelliJ+IDEA"
xmlns:xi="http://www.w3.org/2001/XInclude"
require-restart="true">
<id>org.intellij.scala</id>
<name>Scala</name>
<id>com.avsystem.scala</id>
<name>Scala (AVSystem)</name>
<description>
<![CDATA[
<b>Temporary customized version by AVSystem</b>
Adds support for the Scala language. The following features are available for free with IntelliJ IDEA Community Edition:
<br>
<ul>
Expand All @@ -29,11 +30,15 @@
<li>Testing frameworks support (ScalaTest, Specs2, uTest)</li>
<li>Scala debugger, worksheets and Ammonite scripts</li>
</ul>
AVSystem experimental extensions:
<ul>
<li>sbt structure caching</li>
</ul>
<br>
Support for Play Framework, Akka and Scala.js is enabled in IntelliJ IDEA Ultimate.
]]>
</description>
<version>VERSION</version>
<version>2022.3.99-sbtcaching.1</version>
<change-notes><!-- CHANGE_NOTES --></change-notes>
<vendor url="https://www.jetbrains.com">JetBrains</vendor>
<idea-version since-build="223.7571" until-build="223.*"/>
Expand Down
1 change: 1 addition & 0 deletions sbt/sbt-api/resources/META-INF/sbt-api.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<idea-plugin>
<extensionPoints>
<extensionPoint qualifiedName="com.intellij.sbt.internal.dynamicLinker" interface="org.jetbrains.sbt.internal.InternalDynamicLinker"/>
<extensionPoint qualifiedName="org.intellij.sbt.structureCache" interface="org.jetbrains.sbt.project.SbtStructureCache" dynamic="true"/>
</extensionPoints>

<extensions defaultExtensionNs="com.intellij">
Expand Down
15 changes: 15 additions & 0 deletions sbt/sbt-api/src/org/jetbrains/sbt/project/SbtStructureCache.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.jetbrains.sbt.project

import org.jetbrains.sbt.project.SbtStructureCache.BuildDefinitionHash

trait SbtStructureCache {
def getCachedStructureXml(key: BuildDefinitionHash): Option[String]

def cacheStructureXml(key: BuildDefinitionHash, data: String): Unit
}
object SbtStructureCache {
final case class BuildDefinitionHash(hash: String) {
override def toString: String = hash
}
}

29 changes: 28 additions & 1 deletion sbt/sbt-api/src/org/jetbrains/sbt/settings/SbtSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ final class SbtSettings(project: Project)
@BeanProperty var customVMEnabled: Boolean = false
@BeanProperty var customVMPath: String = ""
@BeanProperty var customSbtStructurePath: String = ""
@BeanProperty var localStructureCachePath: String = ""
@BeanProperty var remoteStructureCacheUri: String = ""
@BeanProperty var remoteStructureCacheCredentialsPath: String = ""
@BeanProperty var allowManualDependencyDownload: Boolean = false

override def getState: SbtSettings.State = {
val state = new SbtSettings.State
Expand All @@ -45,7 +49,10 @@ final class SbtSettings(project: Project)
state.customVMEnabled = customVMEnabled
state.customVMPath = customVMPath
state.customSbtStructurePath = customSbtStructurePath

state.localStructureCache = localStructureCachePath
state.remoteStructureCacheUri = remoteStructureCacheUri
state.remoteStructureCacheCredentialsPath = remoteStructureCacheCredentialsPath
state.allowManualDependencyDownload = allowManualDependencyDownload
state
}

Expand All @@ -59,6 +66,10 @@ final class SbtSettings(project: Project)
customVMEnabled = state.customVMEnabled
customVMPath = state.customVMPath
customSbtStructurePath = state.customSbtStructurePath
localStructureCachePath = state.localStructureCache
remoteStructureCacheUri = state.remoteStructureCacheUri
remoteStructureCacheCredentialsPath = state.remoteStructureCacheCredentialsPath
allowManualDependencyDownload = state.allowManualDependencyDownload
}

override def subscribe(listener: ExternalSystemSettingsListener[SbtProjectSettings]): Unit = {
Expand All @@ -79,6 +90,10 @@ final class SbtSettings(project: Project)
customVMEnabled = settings.customVMEnabled
customVMPath = settings.customVMPath
customSbtStructurePath = settings.customSbtStructurePath
localStructureCachePath = settings.localStructureCachePath
remoteStructureCacheUri = settings.remoteStructureCacheUri
remoteStructureCacheCredentialsPath = settings.remoteStructureCacheCredentialsPath
allowManualDependencyDownload = settings.allowManualDependencyDownload
}

def getLinkedProjectSettings(module: Module): Option[SbtProjectSettings] =
Expand Down Expand Up @@ -124,6 +139,18 @@ object SbtSettings {
@BeanProperty
var customSbtStructurePath: String = ""

@BeanProperty
var localStructureCache: String = ""

@BeanProperty
var remoteStructureCacheUri: String = ""

@BeanProperty
var remoteStructureCacheCredentialsPath: String = ""

@BeanProperty
var allowManualDependencyDownload: Boolean = false

private val linkedProjectSettings: util.TreeSet[SbtProjectSettings] = new util.TreeSet[SbtProjectSettings]

@XCollection(style = XCollection.Style.v1, elementTypes = Array(classOf[SbtProjectSettings]))
Expand Down
4 changes: 4 additions & 0 deletions sbt/sbt-impl/resources/messages/SbtBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ sbt.settings.bundled=&Bundled
### org/jetbrains/sbt/settings/SbtSettingsPane.java
sbt.settings.choose.custom.launcher=Choose a Custom Launcher
sbt.settings.choose.sbt.launch.jar=Choose sbt-launch.jar
sbt.settings.choose.cache.directory=Choose Cache Directory
sbt.settings.choose.local.structure.cache.directory=Choose local sbt structure cache directory
sbt.settings.choose.remote.cache.credentials=Choose Remote Cache Credentials
sbt.settings.choose.remote.structure.cache.credentials.file=Choose remote sbt structure cache credentials file

### org/jetbrains/sbt/shell/SbtProcessManager.scala
sbt.shell.disable.version.override=Disable version override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.jetbrains.sbt.project.settings._
import org.jetbrains.sbt.settings.{SbtExternalSystemConfigurable, SbtSettings}

import java.io.File
import java.net.URI
import scala.jdk.CollectionConverters._

class SbtExternalSystemManager
Expand Down Expand Up @@ -84,6 +85,22 @@ object SbtExternalSystemManager {
val vmOptions = getVmOptions(settingsState, jreHome)
val environment = Map.empty ++ getAndroidEnvironmentVariables(projectJdkName)

val localStructureCacheFile =
Option(settingsState.localStructureCache)
.filter(_.nonEmpty)
.map(new File(_))

val remoteStructureCacheUri =
Option(settingsState.remoteStructureCacheUri)
.filter(_.nonEmpty)
.map(v => if (v.endsWith("/")) v else s"$v/")
.map(new URI(_))

val remoteStructureCacheCredentialsFile =
Option(settingsState.remoteStructureCacheCredentialsPath)
.filter(_.nonEmpty)
.map(new File(_))

new SbtExecutionSettings(
realProjectPath,
vmExecutable,
Expand All @@ -92,14 +109,18 @@ object SbtExternalSystemManager {
environment,
customLauncher,
customSbtStructureFile,
localStructureCacheFile,
remoteStructureCacheUri,
remoteStructureCacheCredentialsFile,
projectJdkName,
projectSettings.resolveClassifiers,
projectSettings.resolveJavadocs,
projectSettings.resolveSbtClassifiers,
projectSettings.useSbtShellForImport,
projectSettings.enableDebugSbtShell,
projectSettings.allowSbtVersionOverride,
projectSettings.preferScala2
projectSettings.preferScala2,
settingsState.allowManualDependencyDownload
)
}

Expand Down
Loading