Automation Paths

Available through the Execution Context during Script Task execution. Script tasks could resolve relative and absolute file system paths with the IAutomationPathsApi.

As entry point call paths in a code{ }.

There are multiple ways to resolve relative paths:
  • by Script folder
  • by Temp folder
  • by BSW Package folder
  • by Project folder
  • by any parent folder

General Path Resolution

Resolves a file path and preserves the relative path resolvePath(Object). Note: It does NOT convert relative paths into absolute.
Resolves a path with the resolvePath() method
scriptTask("TaskName"){
    code{
       // Resolves a path and preserve relative paths
       Path p = paths.resolvePath("MyFile.txt")
    }
}
The 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, including String or GString. Interpreted relative to the parent directory. A string that starts with file: 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 URI or URL: The URL's path is interpreted as the file path. Currently, only file: 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.

Resolves a path with the resolvePath() method
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

The resolveScriptPath(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.

Resolves a path with the resolveScriptPath() method
scriptTask("TaskName"){
    code{
       // Resolves a path relative to the script folder
       Path p = paths.resolveScriptPath("MyFile.txt")
    }
}

Resolution relative to Project Folder

The resolveProjectPath(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.

Resolves a path with the resolveProjectPath() method
scriptTask("TaskName"){
    code{
       // Resolves a path relative active project folder
       Path p = paths.resolveProjectPath("MyFile.txt")
    }
}

Resolution relative to BSW Package Folder

The resolveBswPackagePath(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.

Resolves a path with the resolveBswPackagePath() method
scriptTask("TaskName"){
    code{
       // Resolves a path relative BSW Package folder
       Path p = paths.resolveBswPackagePath("MyFile.txt")
    }
}

Resolution relative to Temp Folder

The resolveTempPath(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.

Resolves a path with the resolveTempPath() method
scriptTask("TaskName"){
    code{
       // Resolves a path relative to the temp folder
       Path p = paths.resolveTempPath("MyFile.txt")
    }
}

Predefined Path Properties

Resolves predefined path variables
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
    }
}
Get the project output folder path
scriptTask("TaskName", DV_PROJECT){
    code{
       // The property OutputFolder is the folder of the generated artifacts
       Path folder = paths.outputFolder
    }
}
Get the BSW Package folder path
scriptTask("TaskName"){
    code{
       // The property bswPackageRootFolder is the folder of the used BSW
       Path folder = paths.bswPackageRootFolder
    }
}