Automation Paths
IAutomationPathsApi.
As entry point call paths in a code{ }.
- by Script folder
- by Temp folder
- by BSW Package folder
- by Project folder
- by any parent folder
General Path Resolution
resolvePath(Object).
Note: It does NOT convert relative paths into absolute.
scriptTask("TaskName"){
code{
// Resolves a path and preserve relative paths
Path p = paths.resolvePath("MyFile.txt")
}
}
resolvePath(Path parent, Object path) method resolves a file path relative to supplied parent folder.
This method converts the supplied path based on its type:
- A
CharSequence, includingStringorGString. Interpreted relative to the parent directory. A string that starts withfile:is treated as a file URL. - A
File: If the file is an absolute file, it is returned as is. Otherwise, the file's path is interpreted relative to the parent directory. - A
Path: If the path is an absolute path, it is returned as is. Otherwise, the path is interpreted relative to the parent directory. - A
URIorURL: The URL's path is interpreted as the file path. Currently, onlyfile:URLs are supported. - A
IHasURI: The returned URI is interpreted as defined above. - A
Closure: The closure's return value is resolved recursively. - A
Callable: The callable's return value is resolved recursively. - A
Supplier: The supplier's return value is resolved recursively. - A
Provider: The provider's return value is resolved recursively.
The return type is java.nio.file.Path.
scriptTask("TaskName"){
code{
// Resolves a path relative to the supplied folder
Path parentFolder = Paths.get('.')
Path p = paths.resolvePath(parentFolder, "MyFile.txt")
}
}
Path Resolution by Base Folder
-
getBswPackageRootFolder() -
getScriptFolder() -
getProjectFolder() -
getTempFolder()
Resolution relative to Script Folder
TheresolveScriptPath(Object) method resolves a file path relative to
the script directory of the executed IScript.
This method converts the supplied path same as the resolvePath(Path, Object) method. The return type is java.nio.file.Path.
scriptTask("TaskName"){
code{
// Resolves a path relative to the script folder
Path p = paths.resolveScriptPath("MyFile.txt")
}
}
Resolution relative to Project Folder
TheresolveProjectPath(Object) method resolves a file path relative to the project directory (see
getProjectFolder()) of the current active project.
This method converts the supplied path same as the resolvePath(Path, Object) method. The return type is java.nio.file.Path.
There must be an active project to use this method.
scriptTask("TaskName"){
code{
// Resolves a path relative active project folder
Path p = paths.resolveProjectPath("MyFile.txt")
}
}
Resolution relative to BSW Package Folder
TheresolveBswPackagePath(Object) method resolves a file path relative to the BSW Package directory (see
getBswPackageRootFolder()).
This method converts the supplied path same as the resolvePath(Path, Object) method. The return type is java.nio.file.Path.
scriptTask("TaskName"){
code{
// Resolves a path relative BSW Package folder
Path p = paths.resolveBswPackagePath("MyFile.txt")
}
}
Resolution relative to Temp Folder
TheresolveTempPath(Object) method resolves a file path relative to the script temp directory of the executed
IScript. A new temporary folder is created for each IScriptTask execution.
This method converts the supplied path same as the resolvePath(Path, Object) method. The return type is java.nio.file.Path.
scriptTask("TaskName"){
code{
// Resolves a path relative to the temp folder
Path p = paths.resolveTempPath("MyFile.txt")
}
}
Predefined Path Properties
scriptTask("TaskName"){
code{
scriptLogger.info "Ecuc file path: " + paths.ecucFile
scriptLogger.info "Ecuc folder path: " + paths.ecucFolder
scriptLogger.info "Generator output folder path: " + paths.outputFolder
scriptLogger.info "Autosar folder path: " + paths.autosarFolder
scriptLogger.info "Service SWC folder path: "+ paths.serviceSwcFolder
// not complete list
}
}
scriptTask("TaskName", DV_PROJECT){
code{
// The property OutputFolder is the folder of the generated artifacts
Path folder = paths.outputFolder
}
}
scriptTask("TaskName"){
code{
// The property bswPackageRootFolder is the folder of the used BSW
Path folder = paths.bswPackageRootFolder
}
}