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

Issue #8 - Add support for Android projects #12

Merged
merged 5 commits into from
Jun 27, 2017

Conversation

Tapchicoma
Copy link
Collaborator

@Tapchicoma Tapchicoma commented Jun 12, 2017

Fix for issue #8: This pull request adds support for Android projects with applied kotlin-android plugin. Also adds applying plugin only to root project - it will scan subprojects and add tasks accordingly.

Android projects apply different kotlin plugin with another structure of
source sets.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Plugin will scan subprojects for kotlin plugins and add corresponding tasks
to subprojects. Also it will create meta check and format tasks in root
project as well - they will trigger corresponding tasks in subprojects.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
@JLLeitschuh
Copy link
Owner

I'd still like to be able to run :[someProject]:ktlintCheck to only validate one project.
I work on projects with a lot of subprojects and there are sometimes cases where you don't care about other projects during your development cycle.

@JLLeitschuh
Copy link
Owner

Thanks for the PR! I'll look over it a bit more in a bit when I have a free moment.

@Tapchicoma
Copy link
Collaborator Author

You can still apply plugin only for subproject. Applying to root project is optional.

README.md Outdated
@@ -61,7 +61,8 @@ ktlint {

This plugin adds two tasks to every source set: `ktlint[source set name]Check` and `ktlint[source set name]Format`.
Additionally, a simple `ktlintCheck` task has also been added that checks all of the source sets for that project.
Similarly, a `ktlintFormat` task has been added that formats all of the source sets.
Similarly, a `ktlintFormat` task has been added that formats all of the source sets. Also same meta tasks are added
to the root project for convenience - they will call related tasks in subprojects.
Copy link
Owner

Choose a reason for hiding this comment

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

Also same meta tasks are added to the root project for convenience - they will call related tasks in subprojects.

So this was not true before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True that user can see tasks from subprojects as well.

Previously when user applied plugin to the root project that contains subprojects - no ktlint tasks are added, but now user can do that - plugin will add tasks for subprojects and add them as a dependency in the root project meta task.

Will make description more understandable.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks! This is the first plugin I've published so it's very likely I did something goofy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 32db797

@@ -1,8 +1,11 @@
package org.jlleitschuh.gradle.ktlint

import com.android.build.gradle.BaseExtension
Copy link
Owner

Choose a reason for hiding this comment

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

Since this is a compileOnly dependency, what happens if com.android.tools.build:gradle:2.3.2 isn't on the classpath?
Won't you get some sort of class not found exception when this class is loaded by the classloader since com.android.build.gradle.BaseExtension isn't on the classpath?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Checked on pure Kotlin project (without any android dependencies) - works ok. When I remove this compileOnly dependency - plugin isn't compiled.

Copy link
Owner

Choose a reason for hiding this comment

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

Okay, thanks for checking!

@JLLeitschuh
Copy link
Owner

Also, would you be so kind as to update the change log with your change listed under the header.

## [Unreleased]

I will update the header when I do a release.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
@Tapchicoma
Copy link
Collaborator Author

Updated CHANGELOG in 704ab7b

@JLLeitschuh
Copy link
Owner

Thank you very much for your contribution!

@JLLeitschuh JLLeitschuh merged commit 79cfe4f into JLLeitschuh:master Jun 27, 2017
@JLLeitschuh JLLeitschuh mentioned this pull request Aug 3, 2017
@Tapchicoma Tapchicoma deleted the issue-8 branch August 4, 2017 20:23
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.

None yet

2 participants