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

Fix isolated projects compatibility #263

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

lwasyl
Copy link
Contributor

@lwasyl lwasyl commented Aug 28, 2024

No description provided.

Copy link

Diffuse output:

OLD: diffuse-base-file
NEW: ktlint-gradle-plugin.jar

       │          compressed           │          uncompressed          
       ├───────────┬───────────┬───────┼───────────┬───────────┬────────
 JAR   │ old       │ new       │ diff  │ old       │ new       │ diff   
───────┼───────────┼───────────┼───────┼───────────┼───────────┼────────
 class │ 143.5 KiB │ 143.5 KiB │ -26 B │ 294.1 KiB │ 293.9 KiB │ -253 B 
 other │  10.1 KiB │  10.1 KiB │   0 B │  24.9 KiB │  24.9 KiB │    0 B 
───────┼───────────┼───────────┼───────┼───────────┼───────────┼────────
 total │ 153.6 KiB │ 153.5 KiB │ -26 B │   319 KiB │ 318.8 KiB │ -253 B 

 CLASSES │ old │ new │ diff       
─────────┼─────┼─────┼────────────
 classes │  86 │  86 │  0 (+0 -0) 
 methods │ 723 │ 724 │ +1 (+6 -5) 
  fields │ 177 │ 177 │  0 (+1 -1)
JAR
    compressed    │   uncompressed    │                                                                                   
─────────┬────────┼──────────┬────────┤                                                                                   
 size    │ diff   │ size     │ diff   │ path                                                                              
─────────┼────────┼──────────┼────────┼───────────────────────────────────────────────────────────────────────────────────
 1.1 KiB │ -142 B │  1.5 KiB │ -382 B │ ∆ io/github/usefulness/KtlintGradlePlugin_apply_1_recognisedEditorConfigs_2.class 
 1.1 KiB │  +91 B │  1.6 KiB │ +151 B │ ∆ io/github/usefulness/KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1.class 
   5 KiB │  +25 B │ 13.5 KiB │  -22 B │ ∆ io/github/usefulness/KtlintGradlePlugin.class                                   
─────────┼────────┼──────────┼────────┼───────────────────────────────────────────────────────────────────────────────────
 7.2 KiB │  -26 B │ 16.7 KiB │ -253 B │ (total)
CLASSES
METHODS:

   old │ new │ diff       
  ─────┼─────┼────────────
   723 │ 724 │ +1 (+6 -5) 
  
  + io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1 <init>(Project)
  + io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1 invoke(File) → File
  + io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_2 invoke(File) → File
  + kotlin.io.FilesKt resolve(File, String) → File
  + org.gradle.api.Project getProjectDir() → File
  + org.gradle.api.Project getRootProject() → Project
  
  - io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1 <clinit>()
  - io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1 <init>()
  - io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1 invoke(Project) → Project
  - io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_2 invoke(Project) → File
  - org.gradle.api.Project getParent() → Project
  

FIELDS:

   old │ new │ diff      
  ─────┼─────┼───────────
   177 │ 177 │ 0 (+1 -1) 
  
  + io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1 _this_with: Project
  
  - io.github.usefulness.KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1 INSTANCE: KtlintGradlePlugin_apply_1_recognisedEditorConfigs_1

@lwasyl lwasyl marked this pull request as ready for review August 28, 2024 11:04
@mateuszkwiecinski mateuszkwiecinski merged commit 91ae14a into master Aug 28, 2024
18 checks passed
@mateuszkwiecinski mateuszkwiecinski deleted the isolated-projects branch August 28, 2024 11:11
Comment on lines +37 to +38
val recognisedEditorConfigs = generateSequence(projectDir) { if (it == rootProject.projectDir) null else it.parentFile }
.map { it.resolve(".editorconfig") }
Copy link
Contributor Author

@lwasyl lwasyl Aug 28, 2024

Choose a reason for hiding this comment

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

Note that this will now traverse directories and not projects. Previously if projects were set up with custom directories, the plugin would look for the .editorconfig file in the actual project directories. Now it traverses the file system directories from the project directory up to the root project directory.

So e.g. for projects set up to use custom directories (using project(":some-project").projectDir = file("custom/directory"))

: -> .
:foo -> ./projects/custom/directory/foo
:foo:bar -> ./projects/custom/directory/bar

then when applying the plugin in :foo:bar project:

  • previously we'd search for .editorconfig files in ./projects/custom/directory/foo, ./projects/(...)/bar and .
  • now, we'll search for .editorconfig files in ./projects/custom/directory/bar, ./projects/custom/directory, ./projects/custom, ./projects/ and .

(fwiw I think the new behavior is more intuitive and expected)

Copy link
Member

@mateuszkwiecinski mateuszkwiecinski Aug 28, 2024

Choose a reason for hiding this comment

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

  • this supposed to resemble what ktlint does when searching for applicable editorconfigs, so the new behavior can be even considered a fix 👍

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