-
Notifications
You must be signed in to change notification settings - Fork 28
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
Make the generated BuildConfig recognizable by the IDE #36
Comments
In my Kotlin multi-platform project, I had to specify |
this also works for non multi-platform projects, I'll update the code snippet. |
I believe that a more correct solution is to hook into |
@jasonsparc I know about that tip, but I think you misunderstood the issue's main point here, that task would make |
I'm not sure I understand the problem, but in all my projects the generated class is always visible and accessible to the IDE. Am I missing something? |
@natros That's also what I thought. The only time the generated classes won't be recognized by the IDE is when the various If that's the case, the proper fix should go in the plugin's code, and not in the |
@natros @jasonsparc This wasn't the case for me, If I didn't add the code above to my build script, The IDE wouldn't suggest/auto-complete the generated |
Hmm... I think I have an idea about what problem you're actually facing. Are you using it for kotlin multiplatform? If yes, then I believe that the problem lies in not calling the appropriate Say for example, you're expecting the generated source code to be used for a JS target named What you should instead run is a task named If your JS target is unnamed, I believe the name will instead be just Probably the assumption here is that @rocketraman Please take a look at this too, as you've said you're using it for kotlin multiplatform. @mr3y-the-programmer If the problem persists despite my clarifications, perhaps provide a small demo project to reproduce the issue in a simple and contained way. That way, we could pinpoint the actual issue, determine the root cause, and fix it from the root. |
@jasonsparc Things don't appear to be that simple.
IMO, this is actually doing the right thing for a MPP project as per point 1, as I don't want a separate backend and frontend config -- I want one shared one. |
@rocketraman I didn't say that What's not clear to me is that, how come it won't be recognized by the IDE after such tasks have run? Now, set aside the IDE, does it not work with just building it with the gradle build tool? If it works, then there might be something wrong with the IDE. If it doesn't, then there might be something wrong with the plugin. I'm currently using a multiplatform project, and I can confirm that doing a
I can confirm that after running |
Also, for further context. The hierarchy for my multiplatform sources is something like:
May I kindly ask for you guys to do the same? I find the issue really weird. But I really don't want to dismiss it as it could be a valid issue. Perhaps some kind of incompatible interactions with your plugins? As I said before, a minimal reproduceable demo project would really help, instead of simply proposing a weird hack in the |
@jasonsparc Thanks for the clarification. Digging a bit deeper, a plain vanilla gradle build works fine for me without the extra |
@jasonsparc No, I'm not using the plugin in a multiplatform project, it is a relatively small android app with all the code in a single module I'll create a minimal reproducible project, and I'll inform you |
@jasonsparc Here's a sample project: https://github.com/mr3y-the-programmer/build-config-bug. Steps to reproduce the issue:
Expected result: Now, Uncomment the workaround here at build.gradle#L51, sync the project, and finally rerun build again from the IDE or from the command line, the build should complete successfully from both without any issues. Additional Context: |
Ok after reviewing this, I think the upcoming major release will also fix this. Basically, Android was never supported, because it has its own The plugin was "working" in a detached way (no linked to any source set) because I'm introducing support in the upcoming major release. |
This will be fix on |
Currently, when trying to use the plugin in a project, the generated
BuildConfig
object is inaccessible in code leading to IDE errors (e.gUnresolved reference
) because the IDE isn't aware of its existence.To make the IDE recognizes it, we need to treat the generated source dir the same as the project's main source directories.
it would be helpful to update the README to include this code snippet to avoid this annoying issue.
kotlin.sourceSets { main { kotlin.srcDirs( file("$buildDir/generated/source/buildConfig/main"), ) } }
PR #37 fixes this, and also add the equivalent code snippet for groovy
build.gradle
files.The text was updated successfully, but these errors were encountered: