Skip to content

Commit

Permalink
Update Gradle and to new (Kotlin based) 2.0 `org.jetbrains.intellij.p…
Browse files Browse the repository at this point in the history
…latform` plugin
  • Loading branch information
ulrichb committed Sep 3, 2024
1 parent ef88681 commit 0b9eb6c
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Shared
50 changes: 0 additions & 50 deletions Src/RiderPlugin/build.gradle

This file was deleted.

79 changes: 79 additions & 0 deletions Src/RiderPlugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
plugins {
id("java")
alias(libs.plugins.kotlinJvm)
id("org.jetbrains.intellij.platform") version "2.0.1" // https://github.com/JetBrains/intellij-platform-gradle-plugin/releases
id("me.filippov.gradle.jvm.wrapper") version "0.14.0" // https://plugins.gradle.org/plugin/me.filippov.gradle.jvm.wrapper
}

val ResharperPluginProjectName: String by project
val ReSharperVersionIdentifier: String by project
val BuildConfiguration: String by project
val ProductVersion: String by project

allprojects {
repositories {
maven { setUrl("https://cache-redirector.jetbrains.com/maven-central") }
}
}

repositories {
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}

tasks.wrapper {
gradleVersion = "8.8"
distributionType = Wrapper.DistributionType.ALL
distributionUrl = "https://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}

version = extra["PluginVersion"] as String

tasks.processResources {
from("dependencies.json") { into("META-INF") }
}

sourceSets {
main {
java.srcDir("src/rider/main/java")
kotlin.srcDir("src/rider/main/kotlin")
resources.srcDir("src/rider/main/resources")
}
}

tasks.compileKotlin {
kotlinOptions { jvmTarget = "17" }
}

dependencies {
intellijPlatform {
rider(ProductVersion)
jetbrainsRuntime()
instrumentationTools()
}
}

tasks.runIde {
// Match Rider's default heap size of 1.5Gb (default for runIde is 512Mb)
maxHeapSize = "1500m"
}

tasks.patchPluginXml {
val changelogText = file("${rootDir}/../../History.md").readText()
val changelogMatches = Regex("(?s)###(.+?)###(.+?)(?=###|\$)").findAll(changelogText)

changeNotes = changelogMatches.map {
val versionTitle = it.groups[1]!!.value
val versionText = it.groups[2]!!.value.replace("(?s)\r?\n".toRegex(), "<br />\n")
"<b>$versionTitle</b>$versionText"
}.take(10).joinToString()
}

tasks.prepareSandbox {
from("${rootDir}/../${ResharperPluginProjectName}/bin/${ReSharperVersionIdentifier}/${BuildConfiguration}") {
include("${ResharperPluginProjectName}*")
into("${rootProject.name}/dotnet")
}
}
15 changes: 13 additions & 2 deletions Src/RiderPlugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Kotlin 1.4 will bundle the stdlib dependency by default, causing problems with the version bundled with the IDE
RiderPluginProjectName=rider-XmlDocInspections

ResharperPluginProjectName=XmlDocInspections.Plugin
ReSharperVersionIdentifier=RD20242
PluginVersion=0.0.0.1
BuildConfiguration=Debug

# https://www.jetbrains.com/intellij-repository/releases
ProductVersion=2024.2

# Kotlin 1.4 will bundle the stdlib dependency by default, causing problems with the version bundled with the IDE
# https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-rc-released/#stdlib-default
kotlin.stdlib.default.dependency=false

org.gradle.jvmargs=-Xmx2048M
# Required to download Rider artifacts from Maven (and not "binary" releases from CDN).
org.jetbrains.intellij.platform.buildFeature.useBinaryReleases=false
10 changes: 10 additions & 0 deletions Src/RiderPlugin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[versions]
kotlin = "1.9.24" # https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
#rdGen = "2024.1.1" # https://github.com/JetBrains/rd/releases

[libraries]
kotlinStdLib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
#rdGen = { group = "com.jetbrains.rd", name = "rd-gen", version.ref = "rdGen" }

[plugins]
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
Binary file modified Src/RiderPlugin/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion Src/RiderPlugin/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
37 changes: 21 additions & 16 deletions Src/RiderPlugin/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -131,7 +129,7 @@ if [ "$darwin" = "true" ]; then
JVM_URL=https://download.oracle.com/java/17/archive/jdk-17.0.3.1_macos-aarch64_bin.tar.gz
JVM_TARGET_DIR=$BUILD_DIR/jdk-17.0.3.1_macos-aarch64_bin-297fa2
;;
*)
*)
die "Unknown architecture $JVM_ARCH"
;;
esac
Expand All @@ -149,7 +147,7 @@ else
JVM_URL=https://download.oracle.com/java/17/archive/jdk-17.0.3.1_linux-aarch64_bin.tar.gz
JVM_TARGET_DIR=$BUILD_DIR/jdk-17.0.3.1_linux-aarch64_bin-319da6
;;
*)
*)
die "Unknown architecture $JVM_ARCH"
;;
esac
Expand Down Expand Up @@ -184,7 +182,7 @@ else
*".zip") unzip "$JVM_TEMP_FILE" -d "$JVM_TARGET_DIR" ;;
*) tar -x -f "$JVM_TEMP_FILE" -C "$JVM_TARGET_DIR" ;;
esac

rm -f "$JVM_TEMP_FILE"

echo "$JVM_URL" >"$JVM_TARGET_DIR/.flag"
Expand Down Expand Up @@ -224,26 +222,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -288,11 +289,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions Src/RiderPlugin/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -133,11 +133,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
4 changes: 0 additions & 4 deletions Src/RiderPlugin/settings.gradle

This file was deleted.

13 changes: 13 additions & 0 deletions Src/RiderPlugin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

pluginManagement {
// Provide repositories to resolve plugins
repositories {
maven { setUrl("https://cache-redirector.jetbrains.com/plugins.gradle.org") }
maven { setUrl("https://cache-redirector.jetbrains.com/maven-central") }
maven { setUrl("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlin-eap") }
}
}

val RiderPluginProjectName: String by settings

rootProject.name = RiderPluginProjectName
1 change: 0 additions & 1 deletion Src/RiderPlugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<p>Tags: rider c# xml doc xmldoc inspection warning</p>
]]></description>
<change-notes>REPLACE ME</change-notes>
<vendor>ulrichb</vendor>

<depends>com.intellij.modules.rider</depends>
Expand Down

0 comments on commit 0b9eb6c

Please sign in to comment.