Skip to content
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

Migrate from Gradle IntelliJ Plugin (v1) to IntelliJ Platform Gradle Plugin (v2) #188

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
3 changes: 2 additions & 1 deletion .run/idea-stapler-plugin [runIde].run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--debug" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
Expand All @@ -18,6 +18,7 @@
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
216 changes: 115 additions & 101 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// 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

plugins {
id 'java'
id 'org.jetbrains.intellij' version '1.17.3'
id 'org.jetbrains.intellij.platform' version '2.1.0'
}

group = "org.kohsuke.stapler.idea"
version = "3.0.4"
version = "3.0.5-SNAPSHOT"

java {
toolchain {
Expand All @@ -17,12 +23,26 @@ java {

repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
maven {
url "https://repo.jenkins-ci.org/releases/"
}
}

dependencies {
intellijPlatform {
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') {
// Provided by the Platform
exclude group: "commons-logging", module: "commons-logging"
Expand All @@ -45,105 +65,99 @@ tasks.withType(JavaCompile) {
}
}

// See https://github.com/JetBrains/gradle-intellij-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 = """
<h3>3.0.4</h3>
<ul>
<li>🐛 Clean up API usage to remain compatible with 2024.2</li>
</ul>
<h3>3.0.3</h3>
<ul>
<li>👻 Compatibility baseline is changed to 2022.3 which also changes Java level to 17. No functional changes are expected.</li>
<li>🚀 Report custom tag attributes that are marked deprecated.</li>
</ul>
<h3>3.0.2</h3>
<ul>
<li>✍️ Usages of Apache commons-lang2 are removed for IntelliJ compatibility reasons</li>
<li>📦 Build tools are upgrade</li>
<li><a href="https://github.com/jenkinsci/idea-stapler-plugin/releases/tag/3.0.2">GitHub Release Notes</a></li>
</ul>
<h3>3.0.1</h3>
<ul>
<li>🚀 Update Jelly Tag Library XSDs.</li>
<li>🚀 Add support for groovy views as well as help files in the structure view.</li>
<li>🚀 Offer this plugin when a project has dependency on org.jenkins-ci.main:jenkins-core</li>
<li><a href="https://github.com/jenkinsci/idea-stapler-plugin/releases/tag/3.0.1">GitHub Release Notes</a></li>
</ul>
<h3>3.0.0</h3>
<ul>
<li>💥 Unused Stapler Facet is removed. You might get a warning about it from IntelliJ. Unreadable facet can be safely removed.</li>
<li>🚀 Add 'since' attribute to the 'attribute' tag of the Stapler tag library</li>
<li>🐛 Fix exception caused by i18n with single-quote</li>
<li><a href="https://github.com/jenkinsci/idea-stapler-plugin/releases/tag/3.0.0">GitHub Release Notes</a></li>
</ul>
<h3>2.1.0</h3>
<ul>
<li>🎉 <strong>Views are shown in the Class' Structure tool window.</strong></li>
<li>🎉 Jelly is now its own separate file type with its own icon</li>
<li>🚀 A file template is added for a Jenkins Jelly View</li>
<li>🐛 Fix "IllegalArgumentException: Invalid range specified: (1, -1)" when editing style attribute in Jelly files</li>
</ul>
<h3>2.0.8</h3>
<h4>Plugin is renamed from "Stapler Framework Support" to "Jenkins Development Support"</h4>
<h3>2.0.7</h3>
<ul>
<li>Fix the <code>StackOverflowError</code> in Stapler Custom Jelly Taglibrary</li>
<li><code>*.jellytag</code> extension is recognized as Jelly. Stapler supports it for Jelly Taglibraries</li>
<li><code>stapler.xsd</code> is formatted to improve readability</li>
</ul>
<h3>2.0.6</h3>
<ul>
<li>Switch from deprecated imperative File Type definition to the declarative one. Internal change. No functional changes are expected.</li>
</ul>
<h3>2.0.5</h3>
<ul>
<li>Compatibility baseline is changed to 2020.3 which also changes Java level to 11. No functional changes are expected.</li>
</ul>
<h3>2.0.4</h3>
<ul>
<li>Avoid <code>java.lang.NullPointerException</code> at <code>org.kohsuke.stapler.idea.JellyDocumentationProvider.generateDoc()</code>
by short-circuiting on <code>null</code> in the nullable parameter.
</li>
</ul>
<h3>2.0.3</h3>
<ul>
<li>Revert Jelly file type introduced in 2.0.1. It turned out that there is regression in Intellij 2021.2 which
prevents adding extensions to existing File Types (IDEA-277310). Attempt to work it around caused more issues than
it fixed. Regression should be fixed in 2021.3. Meanwhile *.jelly can be manually added to XML file type.</li>
</ul>
<h3>2.0.2</h3>
<ul>
<li>Deprecation scheduled for removal are addressed to maintain compatibility with 2021.3 onward</li>
</ul>
<h3>2.0.1</h3>
<ul>
<li>JEXL Inspection crashes are fixed by addressing logger initialization issue in JEXL</li>
<li>Restore the association between *.jelly extension and XML language</li>
</ul>
"""
}
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
intellijPlatform {
pluginConfiguration {
description = extractPluginDescription()
changeNotes = """
<h3>3.0.4</h3>
<ul>
<li>🐛 Clean up API usage to remain compatible with 2024.2</li>
</ul>
<h3>3.0.3</h3>
<ul>
<li>👻 Compatibility baseline is changed to 2022.3 which also changes Java level to 17. No functional changes are expected.</li>
<li>🚀 Report custom tag attributes that are marked deprecated.</li>
</ul>
<h3>3.0.2</h3>
<ul>
<li>✍️ Usages of Apache commons-lang2 are removed for IntelliJ compatibility reasons</li>
<li>📦 Build tools are upgrade</li>
<li><a href="https://github.com/jenkinsci/idea-stapler-plugin/releases/tag/3.0.2">GitHub Release Notes</a></li>
</ul>
<h3>3.0.1</h3>
<ul>
<li>🚀 Update Jelly Tag Library XSDs.</li>
<li>🚀 Add support for groovy views as well as help files in the structure view.</li>
<li>🚀 Offer this plugin when a project has dependency on org.jenkins-ci.main:jenkins-core</li>
<li><a href="https://github.com/jenkinsci/idea-stapler-plugin/releases/tag/3.0.1">GitHub Release Notes</a></li>
</ul>
<h3>3.0.0</h3>
<ul>
<li>💥 Unused Stapler Facet is removed. You might get a warning about it from IntelliJ. Unreadable facet can be safely removed.</li>
<li>🚀 Add 'since' attribute to the 'attribute' tag of the Stapler tag library</li>
<li>🐛 Fix exception caused by i18n with single-quote</li>
<li><a href="https://github.com/jenkinsci/idea-stapler-plugin/releases/tag/3.0.0">GitHub Release Notes</a></li>
</ul>
<h3>2.1.0</h3>
<ul>
<li>🎉 <strong>Views are shown in the Class' Structure tool window.</strong></li>
<li>🎉 Jelly is now its own separate file type with its own icon</li>
<li>🚀 A file template is added for a Jenkins Jelly View</li>
<li>🐛 Fix "IllegalArgumentException: Invalid range specified: (1, -1)" when editing style attribute in Jelly files</li>
</ul>
<h3>2.0.8</h3>
<h4>Plugin is renamed from "Stapler Framework Support" to "Jenkins Development Support"</h4>
<h3>2.0.7</h3>
<ul>
<li>Fix the <code>StackOverflowError</code> in Stapler Custom Jelly Taglibrary</li>
<li><code>*.jellytag</code> extension is recognized as Jelly. Stapler supports it for Jelly Taglibraries</li>
<li><code>stapler.xsd</code> is formatted to improve readability</li>
</ul>
<h3>2.0.6</h3>
<ul>
<li>Switch from deprecated imperative File Type definition to the declarative one. Internal change. No functional changes are expected.</li>
</ul>
<h3>2.0.5</h3>
<ul>
<li>Compatibility baseline is changed to 2020.3 which also changes Java level to 11. No functional changes are expected.</li>
</ul>
<h3>2.0.4</h3>
<ul>
<li>Avoid <code>java.lang.NullPointerException</code> at <code>org.kohsuke.stapler.idea.JellyDocumentationProvider.generateDoc()</code>
by short-circuiting on <code>null</code> in the nullable parameter.
</li>
</ul>
<h3>2.0.3</h3>
<ul>
<li>Revert Jelly file type introduced in 2.0.1. It turned out that there is regression in Intellij 2021.2 which
prevents adding extensions to existing File Types (IDEA-277310). Attempt to work it around caused more issues than
it fixed. Regression should be fixed in 2021.3. Meanwhile *.jelly can be manually added to XML file type.</li>
</ul>
<h3>2.0.2</h3>
<ul>
<li>Deprecation scheduled for removal are addressed to maintain compatibility with 2021.3 onward</li>
</ul>
<h3>2.0.1</h3>
<ul>
<li>JEXL Inspection crashes are fixed by addressing logger initialization issue in JEXL</li>
<li>Restore the association between *.jelly extension and XML language</li>
</ul>
"""
ideaVersion {
sinceBuild = "223.00"
// To keep the open upper bound v2 of gradle plugin expects this option omitted instead of set to ""
// untilBuild = ""
}

runPluginVerifier {
subsystemsToCheck = "without-android"
}
pluginVerification {
subsystemsToCheck = VerifyPluginTask.Subsystems.WITHOUT_ANDROID

listProductsReleases {
sinceVersion = sinceIdeaVersion ?: ideaVersion
ides {
recommended()
}
}
}
}

publishPlugin {
Expand All @@ -156,8 +170,8 @@ String extractPluginDescription() {
def final start = "<!-- Plugin description -->"
def final end = "<!-- Plugin description 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")
Expand Down
13 changes: 9 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +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
# 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

# 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=
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/stapler/idea/GotoViewAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void saveInitialCheckBoxState(boolean state) {

@NotNull
@Override
public String @NotNull [] getNames(boolean checkBoxState) {
public String[] getNames(boolean checkBoxState) {
List<String> r = new ArrayList<>();
for (PsiPackage pkg : viewPackages) {
for (PsiDirectory dir : pkg.getDirectories()) {
Expand All @@ -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()) {
Expand All @@ -144,7 +144,7 @@ public void saveInitialCheckBoxState(boolean state) {

@Override
@NotNull
public String @NotNull [] getSeparators() {
public String[] getSeparators() {
return ArrayUtil.EMPTY_STRING_ARRAY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -139,7 +139,7 @@ public PsiFile resolve() {

@Override
@NotNull
public Object @NotNull [] getVariants() {
public Object[] getVariants() {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<XmlElementDescriptor> r = new ArrayList<>();
for(PsiFile f : dir.getFiles()) {
if(!isTagFile(f)) continue;
Expand Down Expand Up @@ -153,7 +153,7 @@ public void init(PsiElement element) {
}

@Override
public Object @NotNull [] getDependencies() {
public Object[] getDependencies() {
return new Object[]{dir};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void init(PsiElement element) {
}

@Override
public Object @NotNull [] getDependencies() {
public Object[] getDependencies() {
return new Object[]{def.tag};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void init(PsiElement element) {
}

@Override
public Object @NotNull [] getDependencies() {
public Object[] getDependencies() {
return new Object[] {nsDescriptor,tagFile};
}

Expand Down
Loading