Intellij IDEA editing gradle project file vs project settings

It took a few tries to figure out that the way gradle integration works, is by Intellij scanning the gradle project file, and then creating the project settings from it. What was confusing me, and is still confusing me, is how the IDE fails to pick up certain things. It also seems to spontaneously change things like the src directory. I end up having to go in to the project settings, and fix things like marking the appropriate directory as a source directory, and re-adding the excluded source directories. It seems to ignore the exclude statement from the gradle file.
Am I going about this the right way? Why does my project build fine from the command line using the gradlew command, but often does not inside the IDE? Is it normal having to “fix” various project settings? Are these bugs or incomplete features in Intellij?