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

Rework kotlin class detection in AGP3 #29

Closed
raniejade opened this issue Nov 10, 2017 · 7 comments
Closed

Rework kotlin class detection in AGP3 #29

raniejade opened this issue Nov 10, 2017 · 7 comments
Labels

Comments

@raniejade
Copy link

raniejade commented Nov 10, 2017

Add the kotlin output directory to the classpath Instead of copying kotlin classes to intermediates folder. Was able to do it in Spek's AS plugin by using an API provided by AS3 (see https://github.com/raniejade/spek-idea-plugin/blob/master/plugin-studio3.0/src/main/kotlin/org/jetbrains/spek/studio/SpekAndroidParameterPatcher.kt). Probably the same API is available in AGP3. Some users are reporting issues caused by the copy during dexing, removing the copy tasks fixes the issue.

@mannodermaus
Copy link
Owner

I'm hesitant towards the idea to extend the scope of this plugin to IDE-specific patches, since I'm assuming that a similar workaround would have to be made for IDEA and Studio 2.x versions as well (judging from the linked source).

Could you link some of the issues caused by copying Kotlin output to intermediates? Thanks!

@raniejade
Copy link
Author

Here's one: spekframework/spek#256 (comment). I don't think it's an IDE-specific patch, the JavaArtifact#additionalSourcesDir is probably used somehow in AGP3.

@mannodermaus
Copy link
Owner

Thanks! I'll investigate a little.

@mannodermaus
Copy link
Owner

Another point of concern in applying a patch like this inside the JUnit 5 plugin is the requirement to depend on a local installation of Android Studio. This would be a problem when it comes to our Travis CI builds, since we wouldn't have access to a $localAndroidStudio there.

@raniejade
Copy link
Author

Do you really need the full installation? Is there a way to just pull in AGP3 dependencies?

@mannodermaus
Copy link
Owner

I was just going off the way you reach into the IDE's plugin dependencies to obtain the compileOnly code necessary to provide Spek support. Pretty cool actually! There are some internal APIs inside AGP3 which could theoretically allow somebody to register additional artifacts (by means of ExtraModelInfo), however I'd rather not touch those internals.

Meanwhile, it seems that the Kotlin integration into the IDE has been improved quite a bit in the most recent releases, so that they are detected properly even from the /tmp folders. Also, when working on Kotlin translation earlier, I stumbled upon an interesting fact about the legacy integration between Java and Kotlin. In fact, on projects using AGP2, the Kotlin plugin automatically performs the Copy task itself! This might also have been a cause for accidental duplication of classes. The next version of android-junit5 won't perform any copying on its own anymore, and instead collect its inputs from a new TestRootDirectoryProvider interface, which is contributed to from the Kotlin compilation tasks directly.

@mannodermaus
Copy link
Owner

Released in 1.0.20.

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

2 participants