Skip to content

Commit 3cf8881

Browse files
committed
Builder class always being added (#11)
* Builder class always being added * Upgrade setup-gradle to v4 * Add back description in plugin.xml
1 parent 8850562 commit 3cf8881

File tree

7 files changed

+54
-169
lines changed

7 files changed

+54
-169
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757

5858
# Setup Gradle
5959
- name: Setup Gradle
60-
uses: gradle/actions/setup-gradle@v3
60+
uses: gradle/actions/setup-gradle@v4
6161
with:
6262
gradle-home-cache-cleanup: true
6363

@@ -117,7 +117,7 @@ jobs:
117117

118118
# Setup Gradle
119119
- name: Setup Gradle
120-
uses: gradle/actions/setup-gradle@v3
120+
uses: gradle/actions/setup-gradle@v4
121121
with:
122122
gradle-home-cache-cleanup: true
123123

@@ -159,7 +159,7 @@ jobs:
159159

160160
# Setup Gradle
161161
- name: Setup Gradle
162-
uses: gradle/actions/setup-gradle@v3
162+
uses: gradle/actions/setup-gradle@v4
163163
with:
164164
gradle-home-cache-cleanup: true
165165

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
# Setup Gradle
4040
- name: Setup Gradle
41-
uses: gradle/actions/setup-gradle@v3
41+
uses: gradle/actions/setup-gradle@v4
4242
with:
4343
gradle-home-cache-cleanup: true
4444

build.gradle.kts

Lines changed: 34 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,47 @@
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-
61
plugins {
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
2+
id("java")
3+
id("org.jetbrains.kotlin.jvm") version "1.9.25"
4+
id("org.jetbrains.intellij") version "1.17.4"
135
}
146

15-
group = providers.gradleProperty("pluginGroup").get()
7+
group = "com.github.junkfactory"
168
version = providers.gradleProperty("pluginVersion").get()
179

18-
// Set the JVM language level used to build the project.
19-
kotlin {
20-
jvmToolchain(17)
21-
}
22-
23-
// Configure project's dependencies
2410
repositories {
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-
}
11+
mavenCentral()
11112
}
11213

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-
}
14+
// Configure Gradle IntelliJ Plugin
15+
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
16+
intellij {
17+
version.set("2024.1.7")
18+
type.set("IC") // Target IDE Platform
11819

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-
}
20+
plugins.set(listOf("com.intellij.java"))
12821
}
12922

13023
tasks {
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-
}
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("241")
35+
untilBuild.set("243.*")
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+
}
15547
}

gradle.properties

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
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=243.*
10-
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
11-
platformType=IC
12-
platformVersion=243.15521.24
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
201
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
212
kotlin.stdlib.default.dependency=false
223
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
234
org.gradle.configuration-cache=true
245
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
256
org.gradle.caching=true
7+
pluginVersion = snapshot

settings.gradle.kts

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

src/main/java/com/github/junkfactory/innerbuilder/generators/InnerBuilderGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public GenerationResult generate() {
6060
.build();
6161
var result = generatorFactory.createBuilderClassGenerator(generatorParams, params).generate();
6262
generationResult.merge(result);
63-
targetClass.add(builderClass);
6463
var codeStyleManager = generatorParams.psi().codeStyleManager();
6564
generationResult.when(ANNOTATIONS_ADDED, () -> codeStyleManager.shortenClassReferences(targetClass));
6665
generationResult.when(IMPORTS_ADDED, () -> codeStyleManager.removeRedundantImports((PsiJavaFile) file));
@@ -155,7 +154,7 @@ private PsiMethod generateTargetConstructor(final PsiClass targetClass, final Ps
155154
private PsiClass findOrCreateBuilderClass(final PsiClass targetClass) {
156155
var builderClass = targetClass.findInnerClassByName(BUILDER_CLASS_NAME, false);
157156
if (builderClass == null) {
158-
return createBuilderClass(targetClass);
157+
return (PsiClass) targetClass.add(createBuilderClass(targetClass));
159158
}
160159

161160
return builderClass;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
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+
23+
1624
<!-- Product and plugin compatibility requirements.
1725
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
1826
<depends>com.intellij.modules.platform</depends>

0 commit comments

Comments
 (0)