I'm learning Gradle (version 4.10 now) and i am confused with setting path using separators ':' and '/'. In which situations it's propper to use this types? I'm not sure but it looks like colons can be used only when setting dependencies, including projects,adding tasks on the other hand slashes are used to setting paths for ex:
// works
def webappDir = "$projectDir/src/main/webapp"
// doesn't work output: home/projectName/:src:main:webapp
def webappDir = "$projectDir:src:main:webapp"
You have to use '/' character when dealing with resources of type File (as in your example): this is the standard file separator character
// path to the webapp directory
def webappDir = "$projectDir/src/main/webapp"
There are two main situations where you will use ':' character:
When working in a multi-projects build, the character ':' is used to identify a project or a task in the hierarchy : :subProject1
, :subProject:taskA
for example.
A project path has the following pattern: It starts with an optional colon, which denotes the root project. The root project is the only project in a path that is not specified by its name. The rest of a project path is a colon-separated sequence of project names, where the next project is a subproject of the previous project.
More information here : https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:project_and_task_paths
When using the "string notation" for declaring dependencies, you will use ':' as a separator for group/module/version parts, for example: runtime 'org.springframework:spring-core:2.5'
. More information about the dependency notations here: https://docs.gradle.org/current/userguide/dependency_types.html