From c0d24a3d465a24c8f3d067cb22681df55a78f3ab Mon Sep 17 00:00:00 2001 From: Denys Digtiar Date: Wed, 25 Sep 2024 13:35:23 +1000 Subject: [PATCH 1/3] Migrate from Gradle IntelliJ Plugin (v1) to IntelliJ Platform Gradle Plugin (v2) --- .gitignore | 5 ++ build.gradle | 197 ++++++++++++++++++++++++---------------------- gradle.properties | 4 +- 3 files changed, 107 insertions(+), 99 deletions(-) diff --git a/.gitignore b/.gitignore index 07b79b4..2982956 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,8 @@ gradle-app.setting # gradle/wrapper/gradle-wrapper.properties .idea + +# Manualy added +## Cache directory of the IntelliJ Platform Gradle Plugin +## https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-cachePath +.intellijPlatform/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1d38b52..b85d6b4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,11 @@ import java.nio.file.Files import java.util.stream.Collectors +import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask +import org.jetbrains.intellij.platform.gradle.TestFrameworkType plugins { id 'java' - id 'org.jetbrains.intellij' version '1.17.3' + id 'org.jetbrains.intellij.platform' version '2.0.1' } group = "org.kohsuke.stapler.idea" @@ -17,12 +19,21 @@ java { repositories { mavenCentral() + intellijPlatform { + defaultRepositories() + } maven { url "https://repo.jenkins-ci.org/releases/" } } dependencies { + intellijPlatform { + create(ideaType, ideaVersion) + bundledPlugins(platformPlugins.tokenize(',')*.trim()) + + testFramework TestFrameworkType.Platform.INSTANCE + } implementation('org.jenkins-ci:commons-jexl:1.1-jenkins-20111212') { // Provided by the Platform exclude group: "commons-logging", module: "commons-logging" @@ -45,105 +56,99 @@ tasks.withType(JavaCompile) { } } -// See https://github.com/JetBrains/gradle-intellij-plugin/ +// See https://github.com/JetBrains/intellij-platform-gradle-plugin // https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension // https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html // https://plugins.jetbrains.com/docs/marketplace/product-versions-in-use-statistics.html // https://www.jetbrains.com/idea/download/other.html -intellij { - version = ideaVersion - type = ideaType - plugins = platformPlugins.tokenize(',')*.trim() -} - -patchPluginXml { - sinceBuild = "223.00" - untilBuild = "" - pluginDescription = extractPluginDescription() - changeNotes = """ -

3.0.4

- -

3.0.3

- -

3.0.2

- -

3.0.1

- -

3.0.0

- -

2.1.0

- -

2.0.8

-

Plugin is renamed from "Stapler Framework Support" to "Jenkins Development Support"

-

2.0.7

- -

2.0.6

- -

2.0.5

- -

2.0.4

- -

2.0.3

- -

2.0.2

- -

2.0.1

- - """ -} - -runPluginVerifier { - subsystemsToCheck = "without-android" -} +intellijPlatform { + pluginConfiguration { + description = extractPluginDescription() + changeNotes = """ +

3.0.4

+ +

3.0.3

+ +

3.0.2

+ +

3.0.1

+ +

3.0.0

+ +

2.1.0

+ +

2.0.8

+

Plugin is renamed from "Stapler Framework Support" to "Jenkins Development Support"

+

2.0.7

+ +

2.0.6

+ +

2.0.5

+ +

2.0.4

+ +

2.0.3

+ +

2.0.2

+ +

2.0.1

+ + """ + ideaVersion { + sinceBuild = "223.00" + untilBuild = "" + } -listProductsReleases { - sinceVersion = sinceIdeaVersion ?: ideaVersion + pluginVerification { + subsystemsToCheck = VerifyPluginTask.Subsystems.WITHOUT_ANDROID + } + } } publishPlugin { @@ -156,8 +161,8 @@ String extractPluginDescription() { def final start = "" def final end = "" try (def lines = Files.lines(file("README.md").toPath())) { - def description = lines.dropWhile({it != start}) - .takeWhile({it != end}) + def description = lines.dropWhile({ it != start }) + .takeWhile({ it != end }) .collect(Collectors.joining('\n')) if (!description) { throw GradleException("Plugin description section not found in README.md:\n$start ... $end") diff --git a/gradle.properties b/gradle.properties index 65a6ed3..3526843 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,6 @@ # used for intellij build, see https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-version ideaVersion=2022.3 -# specific property for runPluginVerifier to override during runtime `-PsinceIdeaVersion=2022.1` -sinceIdeaVersion= # see https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-type for list of accepted types ideaType=IC -platformPlugins=properties,java +platformPlugins=com.intellij.properties,com.intellij.java intellijPublishToken= \ No newline at end of file From 2e60947dd811220e92a47638a6213d689754c443 Mon Sep 17 00:00:00 2001 From: Denys Digtiar Date: Wed, 25 Sep 2024 16:07:13 +1000 Subject: [PATCH 2/3] Migrate from Gradle IntelliJ Plugin (v1) to IntelliJ Platform Gradle Plugin (v2) * Add missing instrumentation and verification dependencies * Adjust `ideaVersion` compatibility based on new verifier expectations * Complete configuration of plugin verification * Adjust `Jenkinsfile` appropriately * Remove some `@NotNull` annotations which were breaking compilation --- .run/idea-stapler-plugin [runIde].run.xml | 3 ++- Jenkinsfile | 2 +- build.gradle | 14 ++++++++++++-- .../org/kohsuke/stapler/idea/GotoViewAction.java | 6 +++--- .../stapler/idea/JellyTagLibReferenceProvider.java | 4 ++-- ...taplerCustomJellyTagLibraryXmlNSDescriptor.java | 4 ++-- ...erCustomJellyTagfileXmlAttributeDescriptor.java | 2 +- ...plerCustomJellyTagfileXmlElementDescriptor.java | 2 +- .../extension/LeafPsiStructureViewTreeElement.java | 2 +- .../kohsuke/stapler/idea/psi/ref/TagReference.java | 2 +- 10 files changed, 26 insertions(+), 15 deletions(-) diff --git a/.run/idea-stapler-plugin [runIde].run.xml b/.run/idea-stapler-plugin [runIde].run.xml index 2039010..0441270 100644 --- a/.run/idea-stapler-plugin [runIde].run.xml +++ b/.run/idea-stapler-plugin [runIde].run.xml @@ -4,7 +4,7 @@ @@ -18,6 +18,7 @@ true true false + false \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 3208cba..98ba3b4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { stage('Verify Plugin') { steps { script { - String command = "gradlew ${gradleOptions.join ' '} verifyPlugin runPluginVerifier" + String command = "gradlew ${gradleOptions.join ' '} verifyPlugin" if (isUnix()) { command = "./" + command } diff --git a/build.gradle b/build.gradle index b85d6b4..6b44e60 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { } group = "org.kohsuke.stapler.idea" -version = "3.0.4" +version = "3.0.5-SNAPSHOT" java { toolchain { @@ -32,6 +32,11 @@ dependencies { create(ideaType, ideaVersion) bundledPlugins(platformPlugins.tokenize(',')*.trim()) + // Required for runIDE task + instrumentationTools() + // Required for verifyPlugin task + pluginVerifier() + testFramework TestFrameworkType.Platform.INSTANCE } implementation('org.jenkins-ci:commons-jexl:1.1-jenkins-20111212') { @@ -142,11 +147,16 @@ intellijPlatform { """ ideaVersion { sinceBuild = "223.00" - untilBuild = "" + // To keep the open upper bound v2 of gradle plugin expects this option omitted instead of set to "" + // untilBuild = "" } pluginVerification { subsystemsToCheck = VerifyPluginTask.Subsystems.WITHOUT_ANDROID + + ides { + recommended() + } } } } diff --git a/src/main/java/org/kohsuke/stapler/idea/GotoViewAction.java b/src/main/java/org/kohsuke/stapler/idea/GotoViewAction.java index 94881e3..072bbd3 100644 --- a/src/main/java/org/kohsuke/stapler/idea/GotoViewAction.java +++ b/src/main/java/org/kohsuke/stapler/idea/GotoViewAction.java @@ -114,7 +114,7 @@ public void saveInitialCheckBoxState(boolean state) { @NotNull @Override - public String @NotNull [] getNames(boolean checkBoxState) { + public String[] getNames(boolean checkBoxState) { List r = new ArrayList<>(); for (PsiPackage pkg : viewPackages) { for (PsiDirectory dir : pkg.getDirectories()) { @@ -130,7 +130,7 @@ public void saveInitialCheckBoxState(boolean state) { @Override @NotNull - public Object @NotNull [] getElementsByName(@NotNull String name, boolean checkBoxState, @NotNull String pattern) { + public Object[] getElementsByName(@NotNull String name, boolean checkBoxState, @NotNull String pattern) { for (PsiPackage pkg : viewPackages) { for (PsiDirectory dir : pkg.getDirectories()) { for (PsiFile file : dir.getFiles()) { @@ -144,7 +144,7 @@ public void saveInitialCheckBoxState(boolean state) { @Override @NotNull - public String @NotNull [] getSeparators() { + public String[] getSeparators() { return ArrayUtil.EMPTY_STRING_ARRAY; } diff --git a/src/main/java/org/kohsuke/stapler/idea/JellyTagLibReferenceProvider.java b/src/main/java/org/kohsuke/stapler/idea/JellyTagLibReferenceProvider.java index aa58dac..0744b36 100644 --- a/src/main/java/org/kohsuke/stapler/idea/JellyTagLibReferenceProvider.java +++ b/src/main/java/org/kohsuke/stapler/idea/JellyTagLibReferenceProvider.java @@ -36,7 +36,7 @@ public class JellyTagLibReferenceProvider extends PsiReferenceProvider { */ @Override @NotNull - public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement e, @NotNull ProcessingContext processingContext) { + public PsiReference[] getReferencesByElement(@NotNull PsiElement e, @NotNull ProcessingContext processingContext) { /* This was the old way of marking references to tag files, but with the custom XmlNSDescriptor this is no longer necessary @@ -139,7 +139,7 @@ public PsiFile resolve() { @Override @NotNull - public Object @NotNull [] getVariants() { + public Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } }); diff --git a/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagLibraryXmlNSDescriptor.java b/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagLibraryXmlNSDescriptor.java index 331c919..65d5c0d 100644 --- a/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagLibraryXmlNSDescriptor.java +++ b/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagLibraryXmlNSDescriptor.java @@ -99,7 +99,7 @@ private XmlElementDescriptor getElementDescriptor(String localName) { */ @Override @NotNull - public XmlElementDescriptor @NotNull [] getRootElementsDescriptors(@Nullable XmlDocument document) { + public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable XmlDocument document) { List r = new ArrayList<>(); for(PsiFile f : dir.getFiles()) { if(!isTagFile(f)) continue; @@ -153,7 +153,7 @@ public void init(PsiElement element) { } @Override - public Object @NotNull [] getDependencies() { + public Object[] getDependencies() { return new Object[]{dir}; } diff --git a/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagfileXmlAttributeDescriptor.java b/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagfileXmlAttributeDescriptor.java index 92ce1b1..01d9e7a 100644 --- a/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagfileXmlAttributeDescriptor.java +++ b/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagfileXmlAttributeDescriptor.java @@ -99,7 +99,7 @@ public void init(PsiElement element) { } @Override - public Object @NotNull [] getDependencies() { + public Object[] getDependencies() { return new Object[]{def.tag}; } } diff --git a/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagfileXmlElementDescriptor.java b/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagfileXmlElementDescriptor.java index 7285a02..b152660 100644 --- a/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagfileXmlElementDescriptor.java +++ b/src/main/java/org/kohsuke/stapler/idea/descriptor/StaplerCustomJellyTagfileXmlElementDescriptor.java @@ -172,7 +172,7 @@ public void init(PsiElement element) { } @Override - public Object @NotNull [] getDependencies() { + public Object[] getDependencies() { return new Object[] {nsDescriptor,tagFile}; } diff --git a/src/main/java/org/kohsuke/stapler/idea/extension/LeafPsiStructureViewTreeElement.java b/src/main/java/org/kohsuke/stapler/idea/extension/LeafPsiStructureViewTreeElement.java index 326e999..1c4104b 100644 --- a/src/main/java/org/kohsuke/stapler/idea/extension/LeafPsiStructureViewTreeElement.java +++ b/src/main/java/org/kohsuke/stapler/idea/extension/LeafPsiStructureViewTreeElement.java @@ -35,7 +35,7 @@ public Object getValue() { } @Override - public TreeElement @NotNull [] getChildren() { + public TreeElement[] getChildren() { return TreeElement.EMPTY_ARRAY; } diff --git a/src/main/java/org/kohsuke/stapler/idea/psi/ref/TagReference.java b/src/main/java/org/kohsuke/stapler/idea/psi/ref/TagReference.java index 3e779b0..4ec4c6b 100644 --- a/src/main/java/org/kohsuke/stapler/idea/psi/ref/TagReference.java +++ b/src/main/java/org/kohsuke/stapler/idea/psi/ref/TagReference.java @@ -80,7 +80,7 @@ public XmlFile resolve() { @NotNull @Override - public Object @NotNull [] getVariants() { + public Object[] getVariants() { // // not sure how to use this // // -> this is used apparently as a quick completion. // // try typing " Date: Tue, 22 Oct 2024 15:08:09 +1000 Subject: [PATCH 3/3] Pick up a new Gradle Plugin version and doc links --- build.gradle | 17 ++++++++--------- gradle.properties | 9 ++++++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 6b44e60..af98fb4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,15 @@ +// IntelliJ plugins are built with https://github.com/JetBrains/intellij-platform-gradle-plugin +// which is documented at https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html + +import org.jetbrains.intellij.platform.gradle.TestFrameworkType +import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask + import java.nio.file.Files import java.util.stream.Collectors -import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask -import org.jetbrains.intellij.platform.gradle.TestFrameworkType plugins { id 'java' - id 'org.jetbrains.intellij.platform' version '2.0.1' + id 'org.jetbrains.intellij.platform' version '2.1.0' } group = "org.kohsuke.stapler.idea" @@ -61,12 +65,7 @@ tasks.withType(JavaCompile) { } } -// See https://github.com/JetBrains/intellij-platform-gradle-plugin -// https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension - -// https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -// https://plugins.jetbrains.com/docs/marketplace/product-versions-in-use-statistics.html -// https://www.jetbrains.com/idea/download/other.html +// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html intellijPlatform { pluginConfiguration { description = extractPluginDescription() diff --git a/gradle.properties b/gradle.properties index 3526843..3a71594 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,13 @@ -# used for intellij build, see https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-version +# https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html +# https://plugins.jetbrains.com/docs/marketplace/product-versions-in-use-statistics.html +# https://www.jetbrains.com/idea/download/other.html +# used for intellij build, see https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#dependenciesParametrizePlatform ideaVersion=2022.3 # see https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-type for list of accepted types ideaType=IC + +# https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#plugins platformPlugins=com.intellij.properties,com.intellij.java + +# https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-tasks.html#publishPlugin intellijPublishToken= \ No newline at end of file