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] Wrong path for generated files #591

Closed
jknazko opened this issue Apr 28, 2020 · 7 comments · Fixed by #779
Closed

[BUG] Wrong path for generated files #591

jknazko opened this issue Apr 28, 2020 · 7 comments · Fixed by #779
Assignees
Labels
bug Something isn't working

Comments

@jknazko
Copy link

jknazko commented Apr 28, 2020

Describe the bug
Transform.newSources generates files in strange global path independent of project location.
I still can reference generated code and project (sometimes) builds fine but code usages in Intellij lights red because generated files are not in source set.

On mac is everything generated into:
~/Library/Application Support/kotlin/daemon/build/generated/source/kap/main

I tried to change environment variable "arrow.meta.generated.source.output" but it only changes relative path within that .../deamon folder

To Reproduce
I did just a small change in helloWorld example
jknazko/arrow-meta-examples@b4ecb91

Doesn't matter if I build the example from IDE or run gradlew from command line result is that helloWorld_Generated.kt and helloWorld_Generated.kt.meta are generated in ~/Library/Application Support/kotlin/daemon

I see class file in IDE but no source
Screenshot 2020-04-28 at 13 55 11

Not sure if this is related or completely different bug but when I make any change to the code after first successful build then it fails with:
Screenshot 2020-04-28 at 11 37 48

I encountered multiple other errors but don't know how to reproduce, whole experience was very random, broken and usually "fixed" with a lot of intellij restarts + clear caches. But Arrow Meta has great potential.

Expected behavior
I would expect all generated files to be created in build folder within the project itself.

Environment
I always get exactly same behaviour, tried multiple gradle versions with:
Intellij IDEA CE 2019.3.3 - kotlin plugin 1.3.61
Intellij IDEA CE 2020.1 - kotlin plugin 1.3.72

I also replicated it on both MacOS and Linux

@jknazko jknazko added the bug Something isn't working label Apr 28, 2020
@russhwolf
Copy link

I also saw this behavior recently when messing with the hello world and using Transform.newSources(). Wasn't sure if it was intentional or not. That said, the incorrectly-located source does still get linked correctly and I was able to compile code that referenced it. It didn't resolve in the IDE, but I'm not sure that was expected.

@rachelcarmena
Copy link
Member

Thanks @jknazko. I think there is a misunderstanding with the environment variable arrow.meta.generated.source.output because I realized that it's being used with 2 different purposes:

  • The production code is just using a virtual file to place the generated source code right now. That's the reason why generated files were found on daemon directory.

  • The testing library is using physical directories to place the generated source code with testing purposes.

Thanks again for raising this issue 🙌

@raulraja
Copy link
Member

new sources should be placed in the same place as kapt places them by default and overridable ideally in the DSL not as an environment variable

@rachelcarmena
Copy link
Member

Solved by @bloderxd via #608.

Thanks @bloderxd !!! 🙌

@alexanderdrw
Copy link

alexanderdrw commented Oct 21, 2020

It looks like #608 didn't fix the strange global default path issue, when I'm using the latest Snapshot it still generates files here /Users/user/Library/Application Support/kotlin/daemon/.... The additional parameter lets me choose where in kotlin/daemon the files are generated, but I'd prefer them to be produced in the same location as kapt like @raulraja mentioned. Even the hello world example produces files here, although it does successfully compile unlike my project.

@rachelcarmena rachelcarmena reopened this Oct 21, 2020
@rachelcarmena
Copy link
Member

Thanks @alexanderdrw 🙌

Just a comment about:

The additional parameter lets me choose where in kotlin/daemon the files are generated

It's possible to provide absolute paths (relative ones have that issue).

@rachelcarmena
Copy link
Member

@jknazko @russhwolf @alexanderdrw a new fix is already available for the current SNAPSHOT and there is a new example to show how it's working:

use-plugin/build/generated/
├── custom
│   └── directory
│       └── NewMultipleSource_Generated_2.kt
└── source
    └── kapt
        └── main
            └── NewMultipleSource_Generated.kt

Please, re-open if you find any problem. Thanks!!

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

Successfully merging a pull request may close this issue.

6 participants