Skip to content

Commit a16eadc

Browse files
committed
Switch to intellij gradle plugin v2
1 parent 856411b commit a16eadc

File tree

10 files changed

+209
-54
lines changed

10 files changed

+209
-54
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
release:
1313
runs-on: ubuntu-latest
1414
env:
15-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1616
steps:
1717
# Check out current repository
1818
- name: Fetch Sources
@@ -23,9 +23,11 @@ jobs:
2323
with:
2424
distribution: zulu
2525
java-version: 17
26+
cache: gradle
2627
- name: Build Plugin
2728
run: |
28-
./gradlew buildPlugin
29+
./gradlew buildPlugin --no-daemon
2930
PKG="$(basename ${{ github.repository }})-${{ github.ref_name }}.zip"
30-
mv build/distributions/*.zip $PKG
31+
ls -l ./build/distributions
32+
mv ./build/distributions/${{ github.repository }}-snapshot.zip "$PKG"
3133
gh release create ${{ github.ref_name }} "./build/distributions/$PKG" --generate-notes

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ build/
1616
out/
1717
!**/src/main/**/out/
1818
!**/src/test/**/out/
19+
.intellijPlatform
1920

2021
### Eclipse ###
2122
.apt_generated
@@ -40,4 +41,4 @@ bin/
4041
.vscode/
4142

4243
### Mac OS ###
43-
.DS_Store
44+
.DS_Store

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Keep a Changelog guide -> https://keepachangelog.com -->
2+
3+
# Java Inner Builder
4+
5+
## [Unreleased]
6+
7+
### Added
8+
9+
## 0.0.1
10+
11+
- Initial release

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
<!-- Plugin description -->
2+
13
# An opinionated Java Inner Builder Generator
24

35
This is a simple Java Inner Builder Generator IntelliJ plugin that generates a
46
builder for a given class. The builder is an inner class of the class it is building.
57

68
Based from [InnerBuilder](https://github.com/analytically/innerbuilder) with stripped down features.
9+
<!-- Plugin description end -->
710

811
```java
912
public class Person {

build.gradle.kts

Lines changed: 143 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,155 @@
1+
import org.jetbrains.changelog.Changelog
2+
import org.jetbrains.changelog.markdownToHTML
3+
import org.jetbrains.intellij.platform.gradle.Constants.Constraints
4+
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
5+
16
plugins {
2-
id("java")
3-
id("org.jetbrains.kotlin.jvm") version "1.9.24"
4-
id("org.jetbrains.intellij") version "1.17.3"
7+
id("java") // Java support
8+
alias(libs.plugins.kotlin) // Kotlin support
9+
alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
10+
alias(libs.plugins.changelog) // Gradle Changelog Plugin
11+
alias(libs.plugins.qodana) // Gradle Qodana Plugin
12+
alias(libs.plugins.kover) // Gradle Kover Plugin
513
}
614

7-
group = "com.github.junkfactory"
8-
version = "1.0-SNAPSHOT"
15+
group = providers.gradleProperty("pluginGroup").get()
16+
version = providers.gradleProperty("pluginVersion").get()
17+
18+
// Set the JVM language level used to build the project.
19+
kotlin {
20+
jvmToolchain(17)
21+
}
922

23+
// Configure project's dependencies
1024
repositories {
11-
mavenCentral()
25+
mavenCentral()
26+
27+
// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
28+
intellijPlatform {
29+
defaultRepositories()
30+
}
31+
}
32+
33+
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
34+
dependencies {
35+
testImplementation(libs.junit)
36+
37+
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
38+
intellijPlatform {
39+
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
40+
41+
// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
42+
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
43+
44+
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
45+
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
46+
47+
instrumentationTools()
48+
pluginVerifier()
49+
zipSigner()
50+
testFramework(TestFrameworkType.Platform)
51+
bundledPlugin("com.intellij.java")
52+
}
53+
}
54+
55+
// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
56+
intellijPlatform {
57+
pluginConfiguration {
58+
version = providers.gradleProperty("pluginVersion")
59+
60+
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
61+
description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
62+
val start = "<!-- Plugin description -->"
63+
val end = "<!-- Plugin description end -->"
64+
65+
with(it.lines()) {
66+
if (!containsAll(listOf(start, end))) {
67+
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
68+
}
69+
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
70+
}
71+
}
72+
73+
val changelog = project.changelog // local variable for configuration cache compatibility
74+
// Get the latest available change notes from the changelog file
75+
changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion ->
76+
with(changelog) {
77+
renderItem(
78+
(getOrNull(pluginVersion) ?: getUnreleased())
79+
.withHeader(false)
80+
.withEmptySections(false),
81+
Changelog.OutputType.HTML,
82+
)
83+
}
84+
}
85+
86+
ideaVersion {
87+
sinceBuild = providers.gradleProperty("pluginSinceBuild")
88+
untilBuild = providers.gradleProperty("pluginUntilBuild")
89+
}
90+
}
91+
92+
signing {
93+
certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN")
94+
privateKey = providers.environmentVariable("PRIVATE_KEY")
95+
password = providers.environmentVariable("PRIVATE_KEY_PASSWORD")
96+
}
97+
98+
publishing {
99+
token = providers.environmentVariable("PUBLISH_TOKEN")
100+
// The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
101+
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
102+
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
103+
channels = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
104+
}
105+
106+
pluginVerification {
107+
ides {
108+
recommended()
109+
}
110+
}
12111
}
13112

14-
// Configure Gradle IntelliJ Plugin
15-
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
16-
intellij {
17-
version.set("2023.2.6")
18-
type.set("IC") // Target IDE Platform
113+
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
114+
changelog {
115+
groups.empty()
116+
repositoryUrl = providers.gradleProperty("pluginRepositoryUrl")
117+
}
19118

20-
plugins.set(listOf("com.intellij.java"))
119+
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
120+
kover {
121+
reports {
122+
total {
123+
xml {
124+
onCheck = true
125+
}
126+
}
127+
}
21128
}
22129

23130
tasks {
24-
// Set the JVM compatibility versions
25-
withType<JavaCompile> {
26-
sourceCompatibility = "17"
27-
targetCompatibility = "17"
28-
}
29-
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
30-
kotlinOptions.jvmTarget = "17"
31-
}
32-
33-
patchPluginXml {
34-
sinceBuild.set("232")
35-
untilBuild.set("242.*")
36-
}
37-
38-
signPlugin {
39-
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
40-
privateKey.set(System.getenv("PRIVATE_KEY"))
41-
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
42-
}
43-
44-
publishPlugin {
45-
token.set(System.getenv("PUBLISH_TOKEN"))
46-
}
131+
wrapper {
132+
gradleVersion = providers.gradleProperty("gradleVersion").get()
133+
}
134+
135+
publishPlugin {
136+
dependsOn(patchChangelog)
137+
}
138+
}
139+
140+
val runIdeForUiTests by intellijPlatformTesting.runIde.registering {
141+
task {
142+
jvmArgumentProviders += CommandLineArgumentProvider {
143+
listOf(
144+
"-Drobot-server.port=8082",
145+
"-Dide.mac.message.dialogs.as.sheets=false",
146+
"-Djb.privacy.policy.text=<!--999.999-->",
147+
"-Djb.consents.confirmation.enabled=false",
148+
)
149+
}
150+
}
151+
152+
plugins {
153+
robotServerPlugin(Constraints.LATEST_VERSION)
154+
}
47155
}

gradle.properties

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
2+
pluginGroup=com.github.junkfactory.innerbuilder
3+
pluginName=Java Inner Builder
4+
pluginRepositoryUrl=https://github.com/junkfactory/java-inner-builder
5+
# SemVer format -> https://semver.org
6+
pluginVersion=snapshot
7+
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
8+
pluginSinceBuild=232
9+
pluginUntilBuild=242.*
10+
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
11+
platformType=IC
12+
platformVersion=2023.2.7
13+
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
14+
# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
15+
platformPlugins=
16+
# Example: platformBundledPlugins = com.intellij.java
17+
platformBundledPlugins=
18+
# Gradle Releases -> https://github.com/gradle/gradle/releases
19+
gradleVersion=8.9
120
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
221
kotlin.stdlib.default.dependency=false
322
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html

gradle/libs.versions.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[versions]
2+
# libraries
3+
junit = "4.13.2"
4+
5+
# plugins
6+
changelog = "2.2.1"
7+
intelliJPlatform = "2.0.0"
8+
kotlin = "1.9.24"
9+
kover = "0.8.1"
10+
qodana = "2024.1.5"
11+
12+
[libraries]
13+
junit = { group = "junit", name = "junit", version.ref = "junit" }
14+
15+
[plugins]
16+
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
17+
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
18+
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
19+
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
20+
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

settings.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
pluginManagement {
2-
repositories {
3-
mavenCentral()
4-
gradlePluginPortal()
5-
}
1+
plugins {
2+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
63
}
7-
84
rootProject.name = "java-inner-builder"

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,10 @@
1313
Java Inner Builder
1414
</vendor>
1515

16-
<!-- Description of the plugin displayed on the Plugin Page and IDE Plugin Manager.
17-
Simple HTML elements (text formatting, paragraphs, and lists) can be added inside of <![CDATA[ ]]> tag.
18-
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-description -->
19-
<description><![CDATA[
20-
An opinionated Java inner builder generator
21-
]]></description>
22-
2316
<!-- Product and plugin compatibility requirements.
2417
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
2518
<depends>com.intellij.modules.platform</depends>
26-
<depends>com.intellij.modules.java</depends>
19+
<depends>com.intellij.java</depends>
2720

2821
<!-- Extension points defined by the plugin.
2922
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->

0 commit comments

Comments
 (0)