Skip to content

Commit

Permalink
Create Aspire runnable project
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelldi committed Nov 24, 2023
1 parent 5e8bf4c commit 6cc3dba
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 6 deletions.
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ platformVersion = 2023.3-EAP7-SNAPSHOT
# RD-2023.3
pluginVerifierIdeVersions = RD-2023.3-EAP7

dotnetBuildConfiguration=Debug
dotnetBuildConfiguration = Debug

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand All @@ -31,11 +31,13 @@ gradleVersion = 8.4
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency = false

# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.configuration-cache = true

# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching = true

# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
systemProp.org.gradle.unsafe.kotlin.assignment = true

# Temporary workaround for Kotlin Compiler OutOfMemoryError -> https://jb.gg/intellij-platform-kotlin-oom
kotlin.incremental.useClasspathSnapshot = false

kotlin.daemon.jvmargs=-Xmx1500m -Xms=500m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using JetBrains.ProjectModel;
using JetBrains.ProjectModel.Properties;

namespace AspirePlugin.RunnableProject;

[SolutionComponent]
public class AspireProjectPropertyRequest : IProjectPropertiesRequest
{
public const string IsAspireHost = "IsAspireHost";

public IEnumerable<string> RequestedProperties => new[]
{
IsAspireHost
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using JetBrains.Rider.Model;

namespace AspirePlugin.RunnableProject;

public static class AspireRunnableProjectKinds
{
public static readonly RunnableProjectKind AspireHost = new("AspireHost");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using JetBrains.ProjectModel;
using JetBrains.ProjectModel.Properties;
using JetBrains.ReSharper.Features.Running;
using JetBrains.Rider.Model;
using JetBrains.Util;
using static AspirePlugin.RunnableProject.AspireProjectPropertyRequest;

namespace AspirePlugin.RunnableProject;

[SolutionComponent]
public class AspireRunnableProjectProvider : IRunnableProjectProvider
{
public JetBrains.Rider.Model.RunnableProject? CreateRunnableProject(IProject project, string name, string fullName, IconModel? icon)
{
System.Diagnostics.Debugger.Launch();
if (!project.IsDotNetCoreProject()) return null;

var isAspireHost = project.GetUniqueRequestedProjectProperty(IsAspireHost);
if (isAspireHost.IsNullOrEmpty() || isAspireHost != "true") return null;

return new JetBrains.Rider.Model.RunnableProject(
name,
fullName,
project.ProjectFileLocation.NormalizeSeparators(FileSystemPathEx.SeparatorStyle.Unix),
AspireRunnableProjectKinds.AspireHost,
[],
[],
null,
[]
);
}

public IEnumerable<RunnableProjectKind> HiddenRunnableProjectKinds => EmptyList<RunnableProjectKind>.Instance;
}
3 changes: 2 additions & 1 deletion src/dotnet/aspire-plugin/ZoneMarker.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using JetBrains.Application.BuildScript.Application.Zones;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi.CSharp;

namespace AspirePlugin;

[ZoneMarker]
public class ZoneMarker : IRequire<IProjectModelZone>;
public class ZoneMarker : IRequire<ILanguageCSharpZone>, IRequire<IProjectModelZone>;
2 changes: 1 addition & 1 deletion src/dotnet/aspire-plugin/aspire-plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Rider.SDK" Version="$(SdkVersion)" />
<PackageReference Include="JetBrains.Rider.SDK" Version="$(RiderSDKVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.rafaelldi.aspireplugin.run

import com.intellij.execution.RunManager
import com.intellij.execution.RunnerAndConfigurationSettings
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.jetbrains.rider.model.RunnableProject
import com.jetbrains.rider.run.AutoGeneratedRunConfigurationManager
import com.jetbrains.rider.run.ExternalRunConfigurationGeneratorExtension

class AspireHostRunConfigurationGenerator(private val project: Project) : ExternalRunConfigurationGeneratorExtension {

Check warning on line 11 in src/main/kotlin/com/github/rafaelldi/aspireplugin/run/AspireHostRunConfigurationGenerator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "project" is never used
companion object {
private val LOG = logger<AspireHostRunConfigurationGenerator>()

Check warning on line 13 in src/main/kotlin/com/github/rafaelldi/aspireplugin/run/AspireHostRunConfigurationGenerator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "LOG" is never used
}

override fun generateConfigurations(
runnableProjects: List<RunnableProject>,
autoGeneratedRunConfigurationManager: AutoGeneratedRunConfigurationManager,
runManager: RunManager
): List<Pair<RunnableProject, RunnerAndConfigurationSettings>> {
val applicableProjects = runnableProjects.filter {
it.kind == AspireRunnableProjectKinds.AspireHost
}

return emptyList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.rafaelldi.aspireplugin.run

import com.jetbrains.rider.model.RunnableProjectKind

object AspireRunnableProjectKinds {
val AspireHost = RunnableProjectKind("AspireHost")
}
5 changes: 5 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@

<resource-bundle>messages.AspireBundle</resource-bundle>

<extensions defaultExtensionNs="com.intellij">
<rider.run.configurations.externalRunConfigurationGenerator
implementation="com.github.rafaelldi.aspireplugin.run.AspireHostRunConfigurationGenerator"/>
</extensions>

</idea-plugin>

0 comments on commit 6cc3dba

Please sign in to comment.