Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Plan: Add support for reading ktlint version from ktlint-plugins.properties

  • Create a utility class/function to read ktlint-plugins.properties file
  • Update KtlintExtension to check for ktlint-plugins.properties and set version convention
  • Add tests for the new functionality
  • Update documentation in README.md
  • Run broader tests to ensure nothing breaks
  • Final code review and security check
  • Manual verification of the feature
  • Address code review feedback
  • Update CHANGELOG with actual PR number

Code Review Feedback Addressed

All feedback from @JLLeitschuh has been addressed:

  1. ✅ Updated readKtlintVersionFromPropertiesFile() to use java.util.Properties API instead of manual parsing
  2. ✅ Removed extra whitespace in test file (5 locations in KtlintPluginsPropertiesTest.kt)
  3. ✅ Added entry to CHANGELOG.md under [Unreleased] section
  4. ✅ Updated CHANGELOG with actual PR number Add support for ktlint-plugins.properties version synchronization #1001

Changes Summary

PluginUtil.kt:

  • Replaced manual line-by-line parsing with standard java.util.Properties.load() API
  • More robust and follows Java conventions

KtlintPluginsPropertiesTest.kt:

  • Removed leading blank lines in appendText() blocks for cleaner test code

CHANGELOG.md:

All tests pass (unit and integration), and ktlint code style checks are clean.

Original prompt

Objective:

To add support for optionally extracting the ktlint version from the ktlint-plugins.properties file, if it exists in the project. This feature should ensure a smoother user experience as it aligns the ktlint version used in the Gradle plugin with the version specified in this properties file, when present.


Background:

The ktlint IntelliJ plugin has introduced the functionality to read/write the ktlint tool version in a file named ktlint-plugins.properties. It is located in the ktlint-plugin/src/main/kotlin/com/nbadal/ktlint/KtlintPluginsPropertiesReader.kt directory of the ktlint plugin repository.

By leveraging this file in ktlint-gradle, users can identify the version of ktlint being used by IntelliJ directly and configure it correctly within their Gradle builds.


Requirements:

  • Determine File Presence: Check for the existence of the ktlint-plugins.properties file within the project directory.
  • Integrate Version Logic: Read the ktlint_version (or equivalent property that specifies the version, if present) from this file.
  • Set as Convention: If this file exists and the ktlint_version property is present:
    • Use it to set the value of the ktlint version in the Gradle extension automatically.
    • Allow an explicit configuration in the Gradle script to override this value.
  • Fallback Behavior: If the ktlint-plugins.properties file is missing or the ktlint_version property is not found, retain the current behavior of the plugin (manually setting the version where required).
  • Documentation Update: Provide clear documentation in the project README explaining this new behavior and its benefits for maintaining consistency between the plugin and IntelliJ usage.

References:


This pull request was created as a result of the following prompt from Copilot chat.

Objective:

To add support for optionally extracting the ktlint version from the ktlint-plugins.properties file, if it exists in the project. This feature should ensure a smoother user experience as it aligns the ktlint version used in the Gradle plugin with the version specified in this properties file, when present.


Background:

The ktlint IntelliJ plugin has introduced the functionality to read/write the ktlint tool version in a file named ktlint-plugins.properties. It is located in the ktlint-plugin/src/main/kotlin/com/nbadal/ktlint/KtlintPluginsPropertiesReader.kt directory of the ktlint plugin repository.

By leveraging this file in ktlint-gradle, users can identify the version of ktlint being used by IntelliJ directly and configure it correctly within their Gradle builds.


Requirements:

  • Determine File Presence: Check for the existence of the ktlint-plugins.properties file within the project directory.
  • Integrate Version Logic: Read the ktlint_version (or equivalent property that specifies the version, if present) from this file.
  • Set as Convention: If this file exists and the ktlint_version property is present:
    • Use it to set the value of the ktlint version in the Gradle extension automatically.
    • Allow an explicit configuration in the Gradle script to override this value.
  • Fallback Behavior: If the ktlint-plugins.properties file is missing or the ktlint_version property is not found, retain the current behavior of the plugin (manually setting the version where required).
  • Documentation Update: Provide clear documentation in the project README explaining this new behavior and its benefits for maintaining consistency between the plugin and IntelliJ usage.

References:



💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add support for extracting ktlint version from properties file Add support for ktlint-plugins.properties version synchronization Nov 13, 2025
Copilot AI requested a review from JLLeitschuh November 13, 2025 20:22
Copilot finished work on behalf of JLLeitschuh November 13, 2025 20:22
Copy link
Owner

@JLLeitschuh JLLeitschuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot In addition to these review comments, please also add an entry to the CHANGELOG linking back to this pull request


buildGradle.appendText(
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove this extra white space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extra whitespace in commit de73ef6.


buildGradle.appendText(
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove this extra white space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extra whitespace in commit de73ef6.


buildGradle.appendText(
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove this extra white space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extra whitespace in commit de73ef6.


buildGradle.appendText(
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove this extra white space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extra whitespace in commit de73ef6.


buildGradle.appendText(
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove this extra white space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extra whitespace in commit de73ef6.

Copy link
Contributor Author

Copilot AI commented Nov 13, 2025

@copilot In addition to these review comments, please also add an entry to the CHANGELOG linking back to this pull request

Added CHANGELOG entry under [Unreleased] section in commit de73ef6. The PR number placeholder (#TBD) can be updated when the PR is merged.

Copilot AI requested a review from JLLeitschuh November 13, 2025 21:12
Copilot finished work on behalf of JLLeitschuh November 13, 2025 21:12
@JLLeitschuh JLLeitschuh marked this pull request as ready for review November 13, 2025 21:47
@JLLeitschuh
Copy link
Owner

@copilot please use this pull request number #1001 in the CHANGELOG

Copy link
Contributor Author

Copilot AI commented Nov 14, 2025

@copilot please use this pull request number #1001 in the CHANGELOG

Updated CHANGELOG with PR #1001 in commit e97a8bd.

Copilot finished work on behalf of JLLeitschuh November 14, 2025 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants