How is the root folder of Multi build project determined in gradle? - gradle

Before projects are built Settings object is created which contains rootDir variable.
rootDir : The root directory of the build. The root directory is the project directory of the root project.
Also the documentation states it can never be null.
File getRootDir()
Returns the root directory of the build. The root directory is the project directory of the root project.
Returns:
The root directory. Never returns null.
I want to know how is rootDir determined in Multi build project. Is it the highest level directory containing build.gradle?

The details can be discovered in test specification
Simple version: it goes up directory hierarchy and searches for settings.gradle file. If it is not found or when started with --no-search-upward it can return current directory. Or you can pass location of settings.gradle using --settings-file.

Related

How to configure Gradle module name in InteliJ IDEA

I have project with numerous of submodules located in different directories:
enter image description here
How you can see, the module name of IDEA (in []) differs from directory root. I've tried to modify it though Project Settings, but after gradle sync it returns to initial state.
Is it possible to configure Gradle to set module name according with directory name?
IDE takes the module name from the Gradle configuration, which is by default a project directory name. If you want to change it you can do so by adding the following in the settings.gradle file:
rootProject.name = 'newProjectName'
See also the Naming recommendations from Gradle.

Gradle files not recognised in new directory structure?

Previously we made a Gradle project in Intellij and all the gradle files were there under the project. However, we have now moved the files in this project to a sub folder, but the Gradle files aren't being recognised. The picture below is the new folder set up where our code from the original project is now in the server folder (where the Gradle files are). When I mark the src folder (under server) as the Sources Root, that is when the dependencies from Gradle aren't recognised.
I figured out that the correct way to go is actually to separate out the client/server folder into two separate modules.

cant get POM file to set the outputDirectoryas as the project root

I have a POM.xml file and when i compile it it spits out the files in a default directory within the project. Is there a way to specify the file output within the
<outputDirectory>.</outputDirectory>
field? I would likle the file output to be in the root of the project folder. i want the output directory to be able to work for multiple users wherever the project is located within a computer.so it must not be specific for a single user. Is this possible?

Reference a path outside the project directory

learning Gradle, and I am running into an issue. I'd like to add the JAR files from the TomcatEE directory to the compilation classpath, and the tomcatEE directory lives outside the project hierarchy on the file system. For example, the tomcatEE directory is "C:/servers/tomcatee/". I want to define a property "tomcarDir" and then add tomcatDir + '/lib/' to the build path, but Gradle insists on appending the project directory to the start. How do I specify an absolute path like this?
I found my error. In my gradle.properties file, I had the path to the tomcat directory enclosed in single quotes. By removing them, Gradle started treating it as an absoolute file path.

How to make GPE see my war directory?

I already have a war directory created through maven and i would like to use that directory instead of src/main/webapp but the target directory is not seen by GPE . Other than project refresh i do not know what wlse to try.
Change Default Output Folder path from Java Build Path-> Source

Resources