New user confused about out/build folders and gradle

Answered

Hi,

I am new to IDEA and currently using 2018.3.  I have created a JAVA project with Gradle support and a little confused but a few things.

Firstly, the project seems to sometimes build to the "build" folder and other times to the "out" folder.  I cannot see a way of forcing it to the build folder everytime.

Secondly, does the fact the project is set as a gradle project mean the gradle build is being used every time or only when either specifically called as a build/run target or if the delegate setting is checked in the gradle project settings dialog?

I am also building an executable JAR and not sure if that is being built via the artifact option I have set up, or via the jar {} config I set in my build.grade?

I get that if I had no gradle support in the project then the IDE would compile and run itself but I guess I am not sure exactly where the cross over comes in when grade support is part of the project setup, I guess I had assumed all the build would be handled by the gradle set up but it looks to me like I am doing some bits essentially in the IDE make (even though dependancies seem to be being handled via build.gradle settings) and others in the gradle build environment.  The problem then is that I have a sub-folder under resources which is not being copied into the production build environment but I don't know if that's in the IDE setup or because I missed something in the gradle build config.

How do I set this up so that the build is consistent?  I have found the help content on this not clear.  Mostly I just want the build to hit the same output folder structure everytime.

Thanks!

Jez

0
4 comments

Please see https://stackoverflow.com/a/46035904/104891 and http://mrhaki.blogspot.ru/2016/11/gradle-goodness-delegate-build-and-run.html. It should answer all of your questions.

With the build/run delegated to Gradle you should get exactly the same behavior as with the command line Gradle build.

Artifacts can be built using both ways. If you run the artifact build action from the corresponding IDE menu, it's built by IntelliJ IDEA, if you start Gradle task, it's built by Gradle.

0
Avatar
Permanently deleted user

Thanks for the reply.  I had seen the ticket already but not the other links so that does help to a point however I am still a little confused.

If I understand the ticket correctly then basically the gradle build config is not linked to the IDE build unless you specifically tell the IDE to delegate the build to gradle.  Fair enough.  Why then does the IDE take full notice of the dependencies specified in the gradle build config when that delegation option is not checked?  Why have the gradle auto import?

There are also the apparent contradictions picked up in the comments to the stackoverflow info that (a) the IDE make is faster than running the gradle build each time and that (b) the IDE is not looking at the gradle build therefore any specific tasks such as resource filtering cannot be done without specifically delegating the build.

I guess I am misunderstanding the extent of what is meant when adding gradle as a framework to a project.  My assumption would have been that the IDE then becomes aware of the build and either directly uses it for the build/run AND/OR syncs project build options specified in the build configs with the build.gradle file.  If this is not the case then it should be clear in the docs and also clear about why there does seem to be some automatic awareness of the gradle build config such as dependencies.

 

 

0

> Why then does the IDE take full notice of the dependencies specified in the gradle build config when that delegation option is not checked?  Why have the gradle auto import?

Without the dependencies IDE will not be able to provide any code completion, inspections and validation.

IDE does sync its project model with the Gradle model. Delegation is mostly used for some very specific cases that are not supported by the IDE build system out of the box yet.

> My assumption would have been that the IDE then becomes aware of the build and either directly uses it for the build/run AND/OR syncs project build options specified in the build configs with the build.gradle file

Yes, that is how it works.

0
Avatar
Permanently deleted user

Thanks for the comments.  Still a bit in the dark but this does all help shed some light on things.

0

Please sign in to leave a comment.