Issue on project settings sync studio vs IDEA 15

Hi
Each time studio process my projects, it resets project settings in IDEA in a way that make the project unbuildable in the IDE : the project compiler output path is empty, and the modules are defined as inheriting project compiler output path. So when launching a make, IDEA complains about it has no output for the compiler.

Looking at the config it seems that studio uses a compiler output path for each module (core, global, gui, web, etc.) but this is not sync with IDEA config.

Worse : I tried to set manually the ouput path at module level, but each time studio is assembiling the project it reset the settings of each module to inherit project compile output path.

Or maybe IDEA should never be used to build the project but only studio is ? That would be awkward.

Thanks for your help.

Mike

Hi Mike,
Let me explain how it works.

  • Studio does not deal with IDE project files directly, it just runs Gradle’s “idea” (or “eclipse”) task which creates *.ipr, *.iml files. The same can be done from the command line.
  • The project files are configured in such a way that IDEA output is different from Gradle output which is used for building the application. It is done intentionally because entity classes produced by Gradle are enhanced (their bytecode is modified for ORM), and IDEA otherwise rewrites them. So when working with Studio and IDE, you have two sets of compiled classes - one produced by Gradle and one produced by IDEA. We find this approach more robust because we are sure that the target JARs are always built from the output of a single tool (Gradle) and do not depend on what compiler settings are set in IDEA.
  • You can build and run the application from Studio or from the command line. When you compile in IDEA, it doesn’t affect the application classes, but it is useful for checking that your code is correct.
  • When connected to the running application from IDEA debugger, you can use JVM hot-deploy: just recompile a current class (Ctrl-Shift-F9) and IDEA will offer to deploy it if possible. If the compilation fails due to “cannot find symbol” errors, compile the whole project first (Ctrl-F9).

Hope it helps.

Thanks for the answer, that makes sense.

Seems to me that the more simple is to stick to gradle even in IDEA then.

Michael

Sorry for the double post, I just saw that my project settings (compile output path) have been reset once again., but I may have a lead.

When in Studio I clic on “create or update IDEA files” on my project I have the below error, this might explain the issue. Any suggestion ?

Is there any additional log I can send to help ? NB : the application is working, and I can develop and build it in studio normally. Only IDEA is at stake.

[13:46:14.469] Creating/updating IDEA project files
:ideaModule :ideaProject :ideaWorkspace FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:ideaWorkspace’. > No such field: size for class: org.codehaus.groovy.runtime.NullObject * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 0.638 secs [13:46:15.165] Task ‘idea’ failed
groovy.lang.MissingFieldException: No such field: size for class: org.codehaus.groovy.runtime.NullObject

Maybe something is broken in the XML of the existing project files. We can try to find out if you run gradle with “–stacktrace” option:


gradle idea --stacktrace

But you can also try to re-create IDEA files from scratch: run “Build > Remove IDEA project files”, then again “Create or update IDEA project files”. If it doesn’t help, send us Gradle stacktrace output please.

Strangely I launched “gradle idea” from IDEA and it worked.
Then I tried again “create or update IDEA files” from studio and… it worked.
So issue is closed.
Next time I would like to set the “–stacktrace” directly in studio in order to help you find out, is it possible ?

No, it’s impossible now. Only from the command line.