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

IntelliJ IDEA interoperability #42

Open
Jolanrensen opened this issue Jun 22, 2022 · 5 comments
Open

IntelliJ IDEA interoperability #42

Jolanrensen opened this issue Jun 22, 2022 · 5 comments
Assignees

Comments

@Jolanrensen
Copy link

What a cool concept this is!
Not only does it allow me to change source code for Java files, but also for Kotlin and Scala files (which is what I use it for at the moment).

However, I do seem to have some issues to make IntelliJ understand what's happening in my multi-module maven project.

The current problem I'm having: when running mvn compile, all works well. The tests work, I can hit run in IntelliJ on a file (which is not delegated to maven because that fails in multi module projects because of the other module's package being "not available on maven central") and I get the properly modified sources.
However, when I change the source code in a module that contains bits that need preprocessing and I hit run on a file in another module that uses it, the preprocessing won't take place and it won't work anymore (since IntelliJ then skips maven).

Is there any way to make IntelliJ somehow aware of this preprocessor, like it is for annotation processors, so that it always gets preprocessed before executing?
Or would I for instance have to switch to Gradle for better multi-module support?

If a plugin would be needed for this, something similar already exists for a JCP-like preprocessor:
https://github.com/FalseHonesty/intellij-preprocessor which also does nice highlighting and such. It's just a bit out of date, but autocomplete and highlighting might actually be a nice feature for JCP too :).

@raydac raydac self-assigned this Jun 24, 2022
@Jolanrensen
Copy link
Author

As an update: It works better in Gradle! IntelliJ correctly uses JCP in multi module projects. The only downside is that a run/compile is needed to view code changes from other modules. That doesn't happen live.

@Jolanrensen
Copy link
Author

Jolanrensen commented Jul 4, 2022

One other thing I noticed is that IntelliJ incorrectly marks the source directories, making the project harder to work with. If I configure the project like here, I need to unmark build/java-comment-preprocessor/preprocess and mark /src/main/kotlin as sources root (similar with test folders).

I did try to use the idea plugin and:

idea.module {
    sourceDirs = mutableSetOf(File("./src/main/kotlin"))
}

but to no avail...

Any tips in this regard? Can I somehow revert my code sourceSets when the building/deploying is finished?

Edit: I updated the same example.

@Jolanrensen
Copy link
Author

With the updated example, the folders are marked correctly, but IntelliJ still skips the preprocessing defined in gradle, instead opting for an incremental build :(

@Jolanrensen
Copy link
Author

Jolanrensen commented Jul 6, 2022

@raydac My current state: Inside the preprocess task: outputs.upToDateWhen { target.get().exists() } to make sure it rebuilds after a clean.
But the only way I can get the compilation to work reliably is by

tasks.compileKotlin {
    dependsOn(preprocessMain)
    outputs.upToDateWhen { false }
}

It seems that IntelliJ skips the compilation preprocessing step instead doing an incremental update, but it does check the outputs.upToDateWhen predicates.
So, question: How can I get the outcoming files to properly implement upToDateWhen in either the preprocess task configuration or compileKotlin, to return false when there were any file changes?

@Jolanrensen
Copy link
Author

Jolanrensen commented Jul 6, 2022

outputs.upToDateWhen { preprocessMain.outcomingFiles.files.isEmpty() } is now my go to.

Incremental build support for Gradle might actually be nice to speed up JCP builds!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants