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

[BUG] Arrow Meta not changing function in Android project #738

Closed
ocampoleandro opened this issue Sep 2, 2020 · 12 comments
Closed

[BUG] Arrow Meta not changing function in Android project #738

ocampoleandro opened this issue Sep 2, 2020 · 12 comments
Labels
bug Something isn't working

Comments

@ocampoleandro
Copy link

Describe the bug
Arrow meta is not hooking up in the build process when working in an android project.

To Reproduce
Steps to reproduce the behavior:

  1. Start a new Android project.
  2. create the modules to integrate the hello world example
  3. Follow the instructions from that example.
  4. Error will show up in the terminal: kotlin.NotImplementedError: An operation is not implemented.

Expected behavior
function helloWorld to be implemented by arrow meta.

Environment (please complete the following information):

  • Kotlin version: 1.3.61 (not working with 1.3.7)
  • Intellij IDEA version: Android studio 4.0
@ocampoleandro ocampoleandro added the bug Something isn't working label Sep 2, 2020
@ocampoleandro ocampoleandro changed the title [BUG] Short description [BUG] Arrow Meta not changing function in Android project Sep 2, 2020
@Starmel
Copy link
Contributor

Starmel commented Sep 3, 2020

Hello! I've working android-arrow demo. Check it out

Probably you need add this library. It's used in generated code for marking as synthetic.

implementation 'io.arrow-kt:arrow-annotations:0.10.5'

And change dependencies type to compile only as is't not required in runtime:

compileOnly project(path: ':create-plugin', configuration: 'shadow')

@ocampoleandro
Copy link
Author

Thanks for the example @Starmel.

I was playing with it, trying to see what is really needed to make my project work (as there is some things in the project you shared which is not needed. At least for a simple hello world example. Like compiler-plugin for example). Something I noticed is that if I create a new module, then set the configuration that is in create-plugin, remove that folder and use the new module, then helloWorld is not changed at compile time, making the app crash with "operation not implemented".

I double check to be sure that I am using in app:build.gradle:
freeCompilerArgs += "-Xplugin=${project.rootDir}/new-module/build/libs/new-module-all.jar"

The reason why I decided to do this is because I could not make it work with my project.

So this makes me wonder if the module create-plugin is created somehow in a way that I do not know? For example, the new-module was created by doing righ-click in the project -> new module -> Java or Kotlin Library.

@Starmel
Copy link
Contributor

Starmel commented Sep 7, 2020

@ocampoleandro

Something I noticed is that if I create a new module, then set the configuration that is in create-plugin, remove that folder and use the new module, then helloWorld is not changed at compile time, making the app crash with "operation not implemented".

Problem may be in the Build Cache. May to try disable Kotlin Incremental build see Gradle properties

kotlin.incremental=false

So this makes me wonder if the module create-plugin is created somehow in a way that I do not know? For example, the new-module was created by doing righ-click in the project -> new module -> Java or Kotlin Library.

create-plugin module is imported from arrow-meta examples

@rachelcarmena
Copy link
Member

Thank you so much @Starmel 🙌

Hi @ocampoleandro, the example has been improved to avoid misunderstandings and to create a new compiler plugin artifact with the right content:

  • create-plugin module creates a new compiler plugin artifact with Arrow Meta Compiler Plugin + Hello World Plugin
  • use-plugin modules uses the new compiler plugin artifact during the compilation and it shows the expected result when running the main method or the existing test

Please, re-open this issue with a link to your workspace in case it still raises any error. Thanks!!

@ocampoleandro
Copy link
Author

Hi @rachelcarmena Thanks for the update.

I have just one doubt regarding the module "create-plugin". As I mentioned previously, I was trying to create this module from scratch with Android Studio without success (the plugin does not hook in the build process). Then @Starmel mentioned that the module "create-plugin" in his example is imported from arrow-meta examples, which I guess it was created using Intellij.

So what I did is to create from scratch the module "create-plugin" with Intellij, and then import it with Android Studio. In this case I could make it work.

So my question is: is it possible that Arrow Meta has some issue when creating the module from Android Studio?

@rachelcarmena
Copy link
Member

Hi @ocampoleandro 🙌 please, could you share the first step?

I was trying to create this module from scratch with Android Studio without success (the plugin does not hook in the build process)

Thank you so much!!

@rachelcarmena rachelcarmena reopened this Sep 22, 2020
@ocampoleandro
Copy link
Author

ocampoleandro commented Sep 22, 2020

@rachelcarmena Do you mean how I create the module?

the new-module was created by doing righ-click in the project -> new module -> Java or Kotlin Library -> default values with kotlin. Then I just changed the build.gradle file in that module with the values from the Arrow Meta example.

The module imported was done by righ-click in the project -> new module -> import gradle project.

@rachelcarmena
Copy link
Member

Thanks @ocampoleandro 🙌 please, could it be possible to review your workspace in a repository? It would be very useful to reproduce your error and review the source code. Thanks again!

@ocampoleandro
Copy link
Author

Yes!
here I pushed the code: https://github.com/ocampoleandro/arrow-meta-android-example

In app:build.gradle you will see the next lines:

freeCompilerArgs += "-Xplugin=${project.rootDir}/create-plugin/build/libs/create-plugin-all.jar"
//freeCompilerArgs += "-Xplugin=${project.rootDir}/custom-create-plugin/build/libs/custom-create-plugin-all.jar"

create-plugin: module imported from Intellij.
custom-create-plugin: module created form AS.

Thanks for the help!

@rachelcarmena
Copy link
Member

Great @ocampoleandro 🙌

Both directories, create-plugin and custom-create-plugin have the same content. In case you want to use custom-create-plugin, replace this piece of configuration in app:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
    compileTask -> compileTask.dependsOn ":custom-create-plugin:createNewPlugin"
}

to create the artifact of the compiler plugin that will be used during compilation.

Please, could you confirm if that's the reason of kotlin.NotImplementedError with custom-create-plugin? Thank you so much!!

@ocampoleandro
Copy link
Author

@rachelcarmena you are right! that fixed the problem.
Thanks for the help and sorry for my dummy mistake :P.

@rachelcarmena
Copy link
Member

Nothing to apologize 🙌 Thank you so much for letting us know that it's fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants