-
Notifications
You must be signed in to change notification settings - Fork 156
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
Prototype use of ide-starter with gradle-profiler #548
Draft
asodja
wants to merge
3
commits into
master
Choose a base branch
from
asodja/java17-with-java11
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
plugins { | ||
id("profiler.embedded-library") | ||
} | ||
|
||
description = "Api for IDE provisioning capabilities for Gradle profiler" | ||
|
||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(8)) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
subprojects/ide-provisioning-api/src/main/java/org/gradle/profiler/ide/CommandChain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.gradle.profiler.ide; | ||
|
||
public interface CommandChain { | ||
CommandChain importGradleProject(); | ||
CommandChain waitForSmartMode(); | ||
CommandChain exitApp(); | ||
void run(); | ||
} |
6 changes: 6 additions & 0 deletions
6
subprojects/ide-provisioning-api/src/main/java/org/gradle/profiler/ide/RunIdeContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.gradle.profiler.ide; | ||
|
||
public interface RunIdeContext { | ||
RunIdeContext withSystemProperty(String key, String value); | ||
CommandChain withCommands(); | ||
} |
5 changes: 5 additions & 0 deletions
5
subprojects/ide-provisioning-api/src/main/java/org/gradle/profiler/ide/RunIdeStarter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.gradle.profiler.ide; | ||
|
||
public interface RunIdeStarter { | ||
RunIdeContext newContext(String projectLocation, String ideLocation); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
plugins { | ||
id("profiler.embedded-library") | ||
kotlin("jvm") version "1.9.22" | ||
} | ||
|
||
description = "IDE provisioning capabilities for Gradle profiler" | ||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(project(":ide-provisioning-api")) | ||
implementation(libs.ideStarter) { | ||
exclude(group = "io.ktor") | ||
} | ||
implementation("org.kodein.di:kodein-di-jvm:7.20.2") | ||
testImplementation(libs.bundles.testDependencies) | ||
testImplementation(libs.commonIo) | ||
} |
30 changes: 30 additions & 0 deletions
30
subprojects/ide-provisioning/src/main/kotlin/org/gradle/profiler/ide/CommandChainImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.gradle.profiler.ide | ||
|
||
import com.intellij.ide.starter.ide.IDETestContext | ||
import com.intellij.tools.ide.performanceTesting.commands.exitApp | ||
import com.intellij.tools.ide.performanceTesting.commands.importGradleProject | ||
import com.intellij.tools.ide.performanceTesting.commands.waitForSmartMode | ||
|
||
class CommandChainImpl(private val context: IDETestContext) : CommandChain { | ||
|
||
private var commandChain = com.intellij.tools.ide.performanceTesting.commands.CommandChain() | ||
|
||
override fun importGradleProject(): CommandChain { | ||
commandChain = commandChain.importGradleProject() | ||
return this | ||
} | ||
|
||
override fun waitForSmartMode(): CommandChain { | ||
commandChain = commandChain.waitForSmartMode() | ||
return this | ||
} | ||
|
||
override fun exitApp(): CommandChain { | ||
commandChain = commandChain.exitApp() | ||
return this | ||
} | ||
|
||
override fun run() { | ||
context.runIDE(commands = commandChain) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
subprojects/ide-provisioning/src/main/kotlin/org/gradle/profiler/ide/RunIdeContextImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.gradle.profiler.ide | ||
|
||
import com.intellij.ide.starter.ide.IDETestContext | ||
|
||
class RunIdeContextImpl(private val context: IDETestContext) : RunIdeContext { | ||
override fun withSystemProperty(key: String, value: String): RunIdeContext { | ||
context.applyVMOptionsPatch { | ||
addSystemProperty(key, value) | ||
} | ||
return this | ||
} | ||
|
||
override fun withCommands(): CommandChain { | ||
return CommandChainImpl(context) | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
subprojects/ide-provisioning/src/main/kotlin/org/gradle/profiler/ide/RunIdeStarterImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.gradle.profiler.ide | ||
|
||
import com.intellij.ide.starter.ide.IDETestContext | ||
import com.intellij.ide.starter.ide.IdeDistributionFactory | ||
import com.intellij.ide.starter.ide.IdeInstaller | ||
import com.intellij.ide.starter.ide.InstalledIde | ||
import com.intellij.ide.starter.ide.installer.ExistingIdeInstaller | ||
import com.intellij.ide.starter.ide.installer.IdeInstallerFile | ||
import com.intellij.ide.starter.models.IdeInfo | ||
import com.intellij.ide.starter.models.TestCase | ||
import com.intellij.ide.starter.path.GlobalPaths | ||
import com.intellij.ide.starter.process.exec.ProcessExecutor | ||
import com.intellij.ide.starter.project.LocalProjectInfo | ||
import com.intellij.ide.starter.runner.TestContainer | ||
import com.intellij.ide.starter.runner.TestContainerImpl | ||
import com.intellij.openapi.util.SystemInfo | ||
import com.intellij.openapi.util.io.FileUtil | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import kotlin.io.path.div | ||
import kotlin.io.path.name | ||
import kotlin.time.Duration.Companion.minutes | ||
|
||
class RunIdeStarterImpl : RunIdeStarter { | ||
override fun newContext(projectLocation: String, ideLocation: String): RunIdeContext { | ||
val testVersion = "2023.2.3" | ||
val ideInfo = IdeInfo( | ||
productCode = "IC", | ||
version = "2023.2", | ||
// buildNumber = testVersion, | ||
executableFileName = "idea", | ||
fullName = "IntelliJ IDEA Community", | ||
platformPrefix = "idea", | ||
// getInstaller = { _ -> ExistingIdeInstaller(Paths.get(ideLocation)) } | ||
) | ||
val testCase = TestCase( | ||
ideInfo, | ||
LocalProjectInfo(Paths.get(projectLocation)), | ||
) | ||
val context = Starter.newContext("test", testCase) | ||
return RunIdeContextImpl(context) | ||
} | ||
|
||
class ExistingIdeInstaller(private val installedIdePath: Path) : IdeInstaller { | ||
override fun install(ideInfo: IdeInfo, includeRuntimeModuleRepository: Boolean): Pair<String, InstalledIde> { | ||
val ideInstaller = IdeInstallerFile(installedIdePath, "locally-installed-ide") | ||
val installDir = GlobalPaths.instance | ||
.getCacheDirectoryFor("builds") / "${ideInfo.productCode}-${ideInstaller.buildNumber}" | ||
installDir.toFile().deleteRecursively() | ||
val installedIde = installedIdePath.toFile() | ||
val destDir = installDir.resolve(installedIdePath.name).toFile() | ||
if (SystemInfo.isMac) { | ||
ProcessExecutor("copy app", null, 5.minutes, emptyMap(), listOf("ditto", installedIde.absolutePath, destDir.absolutePath)).start() | ||
} | ||
else { | ||
FileUtil.copyDir(installedIde, destDir) | ||
} | ||
return Pair( | ||
ideInstaller.buildNumber, | ||
IdeDistributionFactory.installIDE(installDir.toFile(), ideInfo.executableFileName) | ||
) | ||
} | ||
} | ||
|
||
private object Starter { | ||
private fun newTestContainer(): TestContainer<*> { | ||
return TestContainerImpl() | ||
} | ||
|
||
fun newContext(testName: String, testCase: TestCase<*>, preserveSystemDir: Boolean = false): IDETestContext = | ||
newTestContainer().initializeTestContext( | ||
testName = testName, | ||
testCase = testCase, | ||
preserveSystemDir = preserveSystemDir | ||
) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...e-provisioning/src/main/resources/META-INF/services/org.gradle.profiler.ide.RunIdeStarter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.profiler.ide.RunIdeStarterImpl |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 This is looks like leaked to API implementation details. Not sure that it's reasonable for API client to manipulate
Command
terms for running an IDE. Client wants just to invokefun sync(project, ide)
, probably add some VM arguments, but that's it.WDYT?