Skip to content

Commit

Permalink
Merge pull request #10 from picimako/040
Browse files Browse the repository at this point in the history
v0.4.0
  • Loading branch information
picimako authored Sep 19, 2024
2 parents 0a687f9 + 89138a3 commit bf70fa8
Show file tree
Hide file tree
Showing 18 changed files with 1,688 additions and 56 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ jobs:
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
# Build plugin
- name: Build plugin
run: ./gradlew buildPlugin
Expand Down Expand Up @@ -171,7 +169,7 @@ jobs:

# Run Verify Plugin task and IntelliJ Plugin Verifier tool
- name: Run Plugin Verification tasks
run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}

# Collect Plugin Verifier Result
- name: Collect Plugin Verifier Result
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea
.qodana
build
.intellijPlatform
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## [Unreleased]

## [0.4.0]
### Changed
- New supported IDE version range: 2024.2 - 2024.3.*.
- Updated the project to use the IntelliJ Platform Gradle Plugin 2.0.
- Updated the project to use JDK 21.

## [0.3.0]
### Changed
- Updated Lucene to 9.11.1.
Expand All @@ -13,7 +19,7 @@
- Updated Lucene to 9.11.0.
- Changed the file chooser dialog in the *Open Index*, *Create Index* dialogs and the *Custom Analyzer* panel to an IntelliJ one to provide
a smoother user experience.
- Replaced the previous GIF loading icon to a sharper SVG one.
- Replaced the previous GIF loading icon with a sharper SVG one.

## [0.1.0]
### Added
Expand Down
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

Many classes are reused from the Luke subproject of the Apache Lucene (https://github.com/apache/lucene) project.
Those classes are placed under the 'com.picimako.org.apache.lucene.luke...' package structure corresponding
to their original packages.
Those classes are placed either under the 'com.picimako.org.apache.lucene.luke...' package structure corresponding
to their original packages, or in their original packages when no other option is available.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ The tool can be opened with the menu action at `Tools` / `Luke - Lucene Toolbox`
feature with the same name, and it opens on a new editor tab.
Only one Luke editor tab can be open at once, calling the action again focuses on the already open Luke editor.

## IntelliJ 2024.2+ and JDK 21 support

Starting from Lucas v0.4.0, the plugin is built on JDK 21 as required by the IntelliJ Platform.

Since some parts of Lucene use preview features from Java 21, namely the Foreign Function and Memory API,
and lucene-core includes Java 19, 20 and 21 variants of some classes using that API,
there are a few workarounds in the plugin to make sure those classes are available, and work with Java 21 properly.

For users of Lucas, make sure you add the `--enable-preview` JVM argument to the IDE's custom VM options
under `Help` > `Edit Custom VM Options...`, and then restart your IDE. This may or may not have side effects
to how your IDE operates.

## Differences to Luke

Main differences between Lucas and Luke:
- Opening the Luke tab in the IDE doesn't open up the **Open Index** dialog automatically. A plugin setting might be added in a future release to toggle this.
- Luke's themes are removed. The plugin uses the theme currently set in the IDE.
Expand Down
110 changes: 73 additions & 37 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
import org.apache.tools.ant.filters.*
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML

fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)
import org.jetbrains.intellij.platform.gradle.tasks.RunIdeTask

plugins {
id("java") // Java support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
}

group = properties("pluginGroup").get()
version = properties("pluginVersion").get()
group = providers.gradleProperty("pluginGroup").get()
version = providers.gradleProperty("pluginVersion").get()

// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
kotlin {
jvmToolchain(21)
}

// Configure project's dependencies
repositories {
mavenCentral()
// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
intellijPlatform {
defaultRepositories()
}
}

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
//Lucene

//In case one wants to open in index using AssertingCodec in that index,
// add implementation("org.apache.lucene:lucene-test-framework:$luceneVersion")

val luceneVersion = "9.11.1"

implementation("org.apache.lucene:lucene-core:$luceneVersion")
Expand All @@ -46,47 +58,34 @@ dependencies {
runtimeOnly("org.apache.lucene:lucene-analysis-stempel:$luceneVersion")
runtimeOnly("org.apache.lucene:lucene-suggest:$luceneVersion")

//In case one wants to open in index using AssertingCodec in that index,
// add implementation("org.apache.lucene:lucene-test-framework:$luceneVersion")
}
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html

// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
kotlin {
jvmToolchain(17)
}
intellijPlatform {
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))

// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
pluginName = properties("pluginName")
version = properties("platformVersion")
type = properties("platformType")
// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
}
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
repositoryUrl = properties("pluginRepositoryUrl")
}

tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
instrumentationTools()
pluginVerifier()
zipSigner()
}
}

patchPluginXml {
version = properties("pluginVersion")
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
intellijPlatform {
pluginConfiguration {
version = providers.gradleProperty("pluginVersion")

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

with (it.lines()) {
with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
Expand All @@ -96,7 +95,7 @@ tasks {

val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes = properties("pluginVersion").map { pluginVersion ->
changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
Expand All @@ -106,6 +105,43 @@ tasks {
)
}
}

ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = providers.gradleProperty("pluginUntilBuild")
}
}

pluginVerification {
ides {
recommended()
}
}
}

//Required for classes in 'org.apache.lucene.store' because they use JDK 21 Preview features.
// Without this option, finding those classes would fail during the IDE's run.
tasks.named<RunIdeTask>("runIde") {
jvmArgumentProviders += CommandLineArgumentProvider {
listOf("--enable-preview")
}
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
repositoryUrl = providers.gradleProperty("pluginRepositoryUrl")
}

tasks {
wrapper {
gradleVersion = providers.gradleProperty("gradleVersion").get()
}

//Required for classes in 'org.apache.lucene.store' because they use JDK 21 Preview features.
// Without this option, the build would fail.
compileJava {
options.compilerArgs.add("--enable-preview")
}

// Process UTF8 property files to unicode escapes.
Expand Down
13 changes: 8 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ pluginGroup = com.picimako.lucas
pluginName = Lucas
pluginRepositoryUrl = https://github.com/picimako/lucas
# SemVer format -> https://semver.org
pluginVersion = 0.3.0
pluginVersion = 0.4.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 241
pluginUntilBuild = 242.*
pluginSinceBuild = 242
pluginUntilBuild = 243.*

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IC
platformVersion = 2024.1
platformVersion = 2024.2

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins =

# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins =

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.8
gradleVersion = 8.9

# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency = false
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[versions]
# libraries
annotations = "24.1.0"
junit = "4.13.2"

# plugins
kotlin = "1.9.24"
changelog = "2.2.0"
gradleIntelliJPlugin = "1.17.4"
kotlin = "1.9.25"
changelog = "2.2.1"
intelliJPlatform = "2.0.1"

[libraries]
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
junit = { group = "junit", name = "junit", version.ref = "junit" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" }
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/com/picimako/lucas/ProjectStartupActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.picimako.lucas;

import com.intellij.ide.BrowserUtil;
import com.intellij.ide.util.RunOnceUtil;
import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.ProjectActivity;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Performs actions on project startup.
*/
public final class ProjectStartupActivity implements ProjectActivity {

@Override
public @Nullable Object execute(@NotNull Project project, @NotNull Continuation<? super Unit> continuation) {
RunOnceUtil.runOnceForApp("Lucas v0.4.0 - JDK 21", () -> {
var notification = NotificationGroupManager.getInstance().getNotificationGroup("Lucas JDK 21 Configuration")
.createNotification("Lucas v0.4.0 is built on JDK 21, and it requires manual configuration which is detailed in the documentation.", NotificationType.WARNING)
.setSubtitle("Lucas JDK 21 Configuration")
.addAction(new AnAction("Open Documentation") {

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
BrowserUtil.browse("https://github.com/picimako/lucas/blob/main/README.md#intellij-20242-and-jdk-21-support");
}
});

Notifications.Bus.notify(notification, project);
});

return Unit.INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
import org.apache.lucene.luke.util.LoggerFactory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.FSLockFactory;
import org.apache.lucene.store.LockFactory;
import org.apache.lucene.store.MMapDirectory;
import org.apache.lucene.store.NIOFSDirectory;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.NamedThreadFactory;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -282,7 +287,7 @@ protected Void doInBackground() throws Exception {
setOKActionEnabled(false);

try {
Directory dir = FSDirectory.open(path);
Directory dir = open(path, FSLockFactory.getDefault());
IndexTools toolsModel = new IndexToolsFactory().newInstance(dir);

if (dataDirTF.getText().isEmpty()) {
Expand Down Expand Up @@ -355,5 +360,18 @@ protected void done() {
private void clearDataDir(ActionEvent e) {
dataDirTF.setText("");
}

/**
* Just like {@link FSDirectory#open(Path)}, but allows you to also specify a custom {@link LockFactory}.
* <p>
* LICENSE NOTE: This is copied from {@link FSDirectory} to be able to create a custom {@code MMapDirectory} instance.
*/
private static FSDirectory open(Path path, LockFactory lockFactory) throws IOException {
if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
return new MMapDirectory(path, lockFactory);
} else {
return new NIOFSDirectory(path, lockFactory);
}
}
}
}
Loading

0 comments on commit bf70fa8

Please sign in to comment.