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

Cant find ktlintApplyToIdea task #149

Closed
janakagamini opened this issue Oct 12, 2018 · 7 comments
Closed

Cant find ktlintApplyToIdea task #149

janakagamini opened this issue Oct 12, 2018 · 7 comments
Labels

Comments

@janakagamini
Copy link

I've added ktLint to my project like so:

Android Studio 3.2.1
At the top of my module level (app) build.gradle file:

plugins {
    id "org.jlleitschuh.gradle.ktlint" version "6.1.0"
}

I wan't to generate the code styles for my project using ktlintApplyToIdea but I can't find the task. Running ./gradlew tasks | grep kt results only in the following:

ktlintFormat - Runs the ktlint formatter on all kotlin sources in this project.
ktlintCheck - Runs ktlint on all kotlin sources in this project.

I believe I was last able to run ktlintApplyToIdea in version 5x.

@Tapchicoma
Copy link
Collaborator

Strange, I see this two tasks in "Help tasks" section. Can you do ./gradlew tasks and attach here output?

@Tapchicoma
Copy link
Collaborator

Note that this two tasks (ktlintApplyToIdea and ktlintApplyToIdeaGlobally) is only available on the root project, but not in modules.

@janakagamini
Copy link
Author

./gradlew tasks --all | grep kt

ktlintFormat - Runs the ktlint formatter on all kotlin sources in this project.
app:ktlintFormat - Runs the ktlint formatter on all kotlin sources in this project.
ktlintCheck - Runs ktlint on all kotlin sources in this project.
app:ktlintCheck - Runs ktlint on all kotlin sources in this project.
app:ktlintAndroidTestCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestDevCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestDevDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestDevDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestDevFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestStagingCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestStagingDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestStagingDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintAndroidTestStagingFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintDevCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintDevDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintDevDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintDevFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintDevReleaseCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintDevReleaseFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintMainCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintMainFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintReleaseCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintReleaseFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintStagingCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintStagingDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintStagingDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintStagingFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintStagingReleaseCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintStagingReleaseFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestDevCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestDevDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestDevDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestDevFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestDevReleaseCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestDevReleaseFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestReleaseCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestReleaseFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestStagingCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestStagingDebugCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestStagingDebugFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestStagingFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestStagingReleaseCheck - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
app:ktlintTestStagingReleaseFormat - Runs a check against all .kt files to ensure that they are formatted according to ktlint.
Janakas-MBP:gr8-android janaka$ 

./gradlew ktlintApplyToIdea (I used to be able to do this back in 5.x.x)

Parallel execution is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
Task 'ktlintApplyToIdea' not found in root project 'gr8-android'.

Screenshot of Android Studio 3.2.1 Gradle Tool Window
gradle_help_screenshot

Let me know if you need any other info!

@Tapchicoma
Copy link
Collaborator

You need to move:

plugins {
    id "org.jlleitschuh.gradle.ktlint" version "6.1.0"
}

to your project top build.gradle. This will automatically apply this plugin to all modules in the project.

@janakagamini
Copy link
Author

Thank you @Tapchicoma this solved the problem!

Note for anyone else who encounters the same issue with Android Studio:

  1. plugins block should be below the buildscript block.
  2. You must add (as documented) subprojects as well to get the other ktlint tasks added to the app module.
subprojects {
    apply plugin: "org.jlleitschuh.gradle.ktlint" // Version should be inherited from parent
}

@manoellribeiro
Copy link

I had this problem trying to use version 12.1.0 of org.jlleitschuh.gradle:ktlint-gradle. So I found out it happened because org.jlleitschuh.gradle.ktlint-idea last version is 11.6.1. So I just started to use version 11.6.1 and it solved the issue.

@nochill-lp
Copy link

I had this problem trying to use version 12.1.0 of org.jlleitschuh.gradle:ktlint-gradle. So I found out it happened because org.jlleitschuh.gradle.ktlint-idea last version is 11.6.1. So I just started to use version 11.6.1 and it solved the issue.

@manoellribeiro take a look here #726 it was removed on purpose

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

No branches or pull requests

4 participants