[PT-495] Support android kotlin projects #48
[PT-495] Support android kotlin projects #48
Conversation
…kt integration works as well with android
@@ -0,0 +1,78 @@ | |||
package com.novoda.test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically a copy of TestAndroidProject
. Changes are marked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not too important but with the comments I put below, it is possible that these can be 1 single class with different plugin configuration.
Then you can have TestKotlinProject.forAndroid()
to configure the android plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that first but failed (see my comment below). Any help is appreciated since I also would like to get rid of this duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just merged it. On a second thought, I don't think it is worth. Because that way, it will be more complicated.
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.0.1' | ||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.20' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👁🗨
jcenter() | ||
} | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be honest you can also use the plugins
and your withPlugin
method to add these dynamically from test code.
The plugin id is org.jetbrains.kotlin.android
I think also com.android.library
works too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually tried that for the kotlin plugin, but it didn't work. I got this error Extension with name 'android' does not exist
.
And afaik this is because of the order. com.android.library
needs to be applied first and I couldn't find that one here.
.collect { Map.Entry<String, List<String>> entry -> | ||
"""$entry.key { | ||
manifest.srcFile '${Fixtures.ANDROID_MANIFEST}' | ||
kotlin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, if you add your sources to java
folder, you don't need this in test setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.0.1' | ||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.20' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will approve too.
It is up to @tobiasheine to merge or address my comments.
.entrySet() | ||
.collect { Map.Entry<String, List<String>> entry -> | ||
"""$entry.key { | ||
manifest.srcFile '${Fixtures.ANDROID_MANIFEST}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use double quotes just so there's more consistency? you can also just use $x.y
here i believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is printing the entire config. In the generated one we want single quotes if possible.
PT-495
Description
Scope of this PR is to add to make sure the detekt integration works also with android kotlin projects. Turned out that this works out of the box, so this PR just modifies the tests to consider also android kotlin projects.
Tests
TestAndroidKotlinProject
DetektIntegrationTest
to run all existing tests also against aTestAndroidKotlinProject