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

src/main/kotlin not working out of the box #524

Open
VincentJoshuaET opened this issue Sep 1, 2021 · 11 comments
Open

src/main/kotlin not working out of the box #524

VincentJoshuaET opened this issue Sep 1, 2021 · 11 comments

Comments

@VincentJoshuaET
Copy link

As of Android Studio Arctic Fox and Android Gradle Plugin 7.0, we do not need to specify the source directories for java:

https://stackoverflow.com/questions/41467453/renaming-java-directory-to-kotlin-in-android-studio

You should also support this out of the box for ktlint.

@Tapchicoma
Copy link
Collaborator

Sorry, I don't get what is the issue? Plugin does not do such renaming and should not do.

@drymarau
Copy link

drymarau commented Sep 8, 2021

Experiencing a similar issue when using AGP 7.0 and 10.1.0 version of this plugin. It looks like AGP introduced another source set called kotlin which includes both src/main/kotlin and src/main/java. src/main/kotlin is not included in the java source set though.

If understand it correctly, this plugin only looks at the java source set at the moment:

val androidSourceSet = sourceSet.java as DefaultAndroidSourceDirectorySet

Workaround for now is to add Kotlin directories to java source set (or keep the sources in src/main/java):

android.sourceSets.configureEach {
    java.srcDirs("src/$name/kotlin")
}

@VincentJoshuaET
Copy link
Author

Experiencing a similar issue when using AGP 7.0 and 10.1.0 version of this plugin. It looks like AGP introduced another source set called kotlin which includes both src/main/kotlin and src/main/java. src/main/kotlin is not included in the java source set though.

If understand it correctly, this plugin only looks at the java source set at the moment:

val androidSourceSet = sourceSet.java as DefaultAndroidSourceDirectorySet

Workaround for now is to add Kotlin directories to java source set (or keep the sources in src/main/java):

android.sourceSets.configureEach {
    java.srcDirs("src/$name/kotlin")
}

Thanks for explaining what my issue is.

@Goooler
Copy link
Contributor

Goooler commented Dec 15, 2021

Maybe we should support the "src/$name/kotlin" by default ?

@eduardbosch
Copy link

The kotlinter plugin fixed this issue in this PR jeremymailen/kotlinter-gradle#229

Should this ktlint plugin fix the issue too?

@JLLeitschuh
Copy link
Owner

PRs are welcome to resolve this issue, please do include test coverage.

@saran2020
Copy link

saran2020 commented Mar 31, 2022

What do we intend to do about this issue? I see that the PR #558 has no movement for 2+ months now.

@StylianosGakis
Copy link

If this is something that is not going to be addressed soon or isn't being actively worked on at this moment, I'd really like to see it in the readme. I've unfortunately wasted way too much time thinking my setup was wrong and the fix was to simply rename the dir from kotlin to java. I am sure that there's more people out there who have also come across this bug unfortunately. Would you accept a contribution to the README if I were to write a sentence about this bug until it's resolved?

StylianosGakis added a commit to HedvigInsurance/android that referenced this issue Jul 5, 2022
More context:
src/main/kotlin not working out of the box #524
JLLeitschuh/ktlint-gradle#524
StylianosGakis added a commit to HedvigInsurance/android that referenced this issue Jul 5, 2022
More context:
src/main/kotlin not working out of the box
JLLeitschuh/ktlint-gradle#524
@JLLeitschuh
Copy link
Owner

PRs are welcome to address this problem. Please see the pinned comment regarding the current maintenance status of this project

@StylianosGakis
Copy link

Right, I was referring to merging a PR with some explanatory text, perhaps as an entry to the FAQ which would mention that you need to name the file java and that kotlin doesn't work.
As far as solving the problem itself there seems to have been some work here #558 but no activity lately. Definitely not familiar enough with fixing something like that to tackle it myself.

@Goooler
Copy link
Contributor

Goooler commented Jan 20, 2024

This should be fixed by #733.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants