Creating a Project

The method createProject(Action) creates a new project as specified by the given Closure. Inside the closure the ICreateProjectApi is available.

Mandatory parameters are:

  • projectName
  • projectFolder

The new project is not opened and usable until IProjectRef.openProject(Transformer) is called on the returned IProjectRef.

Creating a new CFG6 project (Minimal Setup)
scriptTask('taskName', DV_APPLICATION) {
  code {
    def newProject = projects.createProject {
      projectName 'NewProject'
      projectFolder paths.resolveTempPath('projectFolder')
    }

    scriptLogger.info("Project created and saved to: $newProject")

    // Now open the project
    newProject.openProject{
        // Inside here the project and project settings can be used
    }
  }
}

The next is a more sophisticated example of creating a project with multiple settings:

Creating a new project (with some optional parameters)
scriptTask('taskName', DV_APPLICATION) {
  code {
    def newProject = projects.createProject {

      projectName 'NewProject'
      projectFolder paths.resolveTempPath('projectFolder')

      author 'projectAuthor'
      version '0.9'
    }
  }
}

++++++

+++The ICreateProjectApi contains the methods to parameterize the creation of a new project.+++

Mandatory Settings

+++

+++

projectName(String)

Specifies the name of the newly created CFG6 project file. The following constraint was applied:

+++

+++

projectFolder(Object)

Specify the folder in which to create the new CFG6 project. The value given here is converted to Path. The following constraints were applied:

Optional Project Settings

+++

+++

Author

The author for the new project can be specified with setAuthor(String). This is an optional parameter defaulting to the name of the currently logged-in user if the parameter is not provided explicitly.

The following constraints apply:

+++

+++

Version

The version for the new project can be specified with setVersion(Object). This is an optional parameter defaulting to "1.0" if the parameter is not provided explicitly. The value given here is converted to IVersion using ScriptConverters.TO_VERSION +++ScriptConverters.TO_VERSION+++.

The following constraints apply:

Target Settings

+++

+++Use getProjectTarget() or projectTarget(Action) to specify the new project's target settings for compiler, derivatives and pin layouts.

+++

+++ICreateProjectTargetApi contains the API to specify the new project's target settings.

+++

+++

Available Derivatives

getAvailableDerivatives() returns all possible input values for setDerivative(DerivativeInfo).

+++

+++

Derivative

Set the derivative for the new project with setDerivative(DerivativeInfo). The new default project derivative refers to the first element in the collection returned by getAvailableDerivatives(). Call setDerivative(DerivativeInfo) if you would like change the derivative.

+++

+++

Available Compilers

getAvailableCompilers() returns all possible input values for setCompiler(ImplementationProperty). Note: the available compilers depend on the currently configured derivative. This method will return the empty collection if no derivative has been configured at the time it is called.

+++

+++

Compiler

Set the compiler for the new project with setCompiler(ImplementationProperty). The new default project compiler refers to the first element in the collection returned by getAvailableCompilers(). Call setCompiler(ImplementationProperty) if you would like change the compiler.

+++

+++

Available Pin Layouts

getAvailablePinLayouts() returns all possible input values for setPinLayout(ImplementationProperty). Note: the available pin layouts depend on the currently configured derivative. This method will return the empty collection if no derivative has been configured at the time it is called.

+++

+++

Pin Layout

Set the pin layout of the selected derivative for the new project with setPinLayout(ImplementationProperty). The new default project pinLayout refers to the first element in the collection returned by getAvailablePinLayouts(). Call setPinLayout(ImplementationProperty) if you would like change the pinLayout.

Project Type Settings

+++

+++

Note: If no projectType settings will be set, the standard type will be used.

Use type(EEnvironmentProjectType) to specify the projects type setting.

+++Use domain(EEnvironmentProjectTypeDomain) to specify the projects domain type setting.+++

Set project type and domain while project creation
import com.vector.cfg.core.project.EEnvironmentProjectTypeDomain
import com.vector.cfg.core.project.EEnvironmentProjectType

scriptTask('taskName', DV_APPLICATION) {

  code {
        def tmpFolder = paths.resolveTempPath('projectFolder')
        def newProject = projects.createProject {
            projectName 'NewProject'
            projectFolder tmpFolder

            // Remove those settings to use the Standard ProjectType
            projectType{
                type EEnvironmentProjectType.SOFTWARE_CLUSTER_CONNECTION
                domain EEnvironmentProjectTypeDomain.GLOBAL_RESOURCE_DB
            }
        }
  }
}

Post Build Settings

+++

+++Use getPostBuild() or postBuild(Action) to specify the new project's post build settings for Post-build selectable and or loadable projects.

+++

+++ICreateProjectPostBuildApi contains the API to specify the new project's post build settings.

+++

+++

Post-build Loadable Support

setLoadable(boolean) sets whether or not to support Post-build loadable for the new project. This is an optional parameter defaulting to false if the parameter is not provided explicitly.

+++

+++

Post-Build Selectable Support

setSelectable(boolean) sets whether or not to support Post-build selectable for the new project. This is an optional parameter defaulting to false if the parameter is not provided explicitly.

Project Folder Settings

+++

+++Use getFolders() or folders(Action) to specify the new project's folders settings.

+++

+++ICreateProjectFolderApi contains the methods to specify the new project's folders settings.

Creating a new CFG6 project with project folder
def newProject = projects.createProject {
  projectName 'NewProject'
  projectFolder projectFolderToSet
  folders {
    applicationComponentFilesFolder tempPath.resolve("applComp")
    autosarFilesFolder tempPath.resolve("autosar")
    ecucFileStructure EEcucFileStructure.SINGLE_FILE
    logFilesFolder tempPath.resolve("logFiles")
    measurementAndCalibrationFilesFolder tempPath.resolve("mAndCal")
    moduleFilesFolder tempPath.resolve("modules")
    serviceComponentFilesFolder tempPath.resolve("serviceComps")
    templatesFolder tempPath.resolve("templates")
    timingExtensionFolder tempPath.resolve("timingExt")
    vttModuleFilesFolder tempPath.resolve("vtt")
  }
}

+++

+++

Module Files Folder

Set the module files folder for the new project with setModuleFilesFolder(Object). This is an optional parameter defaulting to "../Output/Source/GenData" if the parameter is not provided explicitly. The value given here is converted to Path using ScriptConverters.TO_PATH +++ScriptConverters.TO_PATH+++. Normally an absolute path should be given here, which will be relativized to the correct settings file.

The following constraints apply:

+++

+++

Templates Folder

Set the templates folder for the new project with setTemplatesFolder(Object). This is an optional parameter defaulting to "../Output/Source/Templates" if the parameter is not provided explicitly.

The value given here is converted to Path using ScriptConverters.TO_PATH +++ScriptConverters.TO_PATH+++. Normally an absolute path should be given here, which will be relativized to the correct settings file.

The following constraints apply:

+++

+++

Service Components Folder

Set the service component files folder for the new project with setServiceComponentFilesFolder(Object). This is an optional parameter defaulting to "../Output/Config/SoftwareComponents" if the parameter is not provided explicitly.

The value given here is converted to Path using ScriptConverters.TO_PATH +++ScriptConverters.TO_PATH+++. Normally an absolute path should be given here, which will be relativized to the correct settings file.

The following constraints apply:

+++

+++

Application Components Folder

Set the application component files folder for the new project with setApplicationComponentFilesFolder(Object). This is an optional parameter defaulting to "../Config/AppComponents" if the parameter is not provided explicitly.

The value given here is converted to Path using ScriptConverters.TO_PATH +++ScriptConverters.TO_PATH+++. Normally an absolute path should be given here, which will be relativized to the correct settings file.

The following constraints apply:

+++

+++

Log Files Folder

Set the log files folder for the new project with setLogFilesFolder(Object). This is an optional parameter defaulting to "../Output/Log" if the parameter is not provided explicitly.

The value given here is converted to Path using ScriptConverters.TO_PATH +++ScriptConverters.TO_PATH+++. Normally an absolute path should be given here, which will be relativized to the correct settings file.

The following constraints apply:

+++

+++

Measurement And Calibration Files Folder

Set the measurement and calibration files folder for the new project with setMeasurementAndCalibrationFilesFolder(Object). This is an optional parameter defaulting to "../Output/Source/McData" if the parameter is not provided explicitly.

The folder object passed to the method is converted to Path using ScriptConverters.TO_PATH +++ScriptConverters.TO_PATH+++. Normally an absolute path should be given here, which will be relativized to the correct settings file.

The following constraints apply:

+++

+++

AUTOSAR Files Folder

Set the AUTOSAR files folder for the new project with setAutosarFilesFolder(Object). This is an optional parameter defaulting to "../Config/AUTOSAR" if the parameter is not provided explicitly.

The value given here is converted to Path using ScriptConverters.TO_PATH +++ScriptConverters.TO_PATH+++. Normally an absolute path should be given here, which will be relativized to the correct settings file.

The following constraints apply:

ECUC File Structure

+++

+++The literals of EEcucFileStructure define the alternative ECUC file structures supported by the new project. The following alternatives are supported:

+++

+++SINGLE_FILE results in a single ECUC file containing all module configurations.

+++

+++ONE_FILE_PER_MODULE results in a separate ECUC file for each module configuration all located in a common folder.

+++

+++ ONE_FILE_IN_SEPARATE_FOLDER_PER_MODULE results in a separate ECUC file for each module configuration each located in its separate folder.

+++

+++Set the ECUC file structure to use for the new project with the method setEcucFileStructure(EEcucFileStructure). This is an optional parameter defaulting to EEcucFileStructure.SINGLE_FILE if the parameter is not provided explicitly.

External References

+++

+++Use getExternalReferences() ()} or externalReferences(Action) to specify the new project's external references.

+++

+++

DEV Workspace

Set the DaVinci Developer workspace for the new project with setDaVinciDeveloperWorkspace(Object). This is an optional parameter defaulting to
"../Config/AppConfig" if the parameter is not provided explicitly.

The value given here is converted to Path using ScriptConverters.TO_PATH +++ScriptConverters.TO_PATH+++. Normally an absolute path should be given here, which will be relativized to the correct settings file.

The following constraints apply:

Additional BSWMD modules

IProjectAdditionalBswmdApi.getAdditionalBswmd()

Returns the list of path to the additional BSWMD Module Definition folders.

IProjectAdditionalBswmdApi.addAdditionalBswmd(Object)

Adds additional BSWMD files folder. The Path is ignored if it is already present.

IProjectAdditionalBswmdApi.replaceAdditionalBswmd(Object, Object)

Replaces an additional BSWMD files folder. If the #additionalBswmdFolderOld is not present, the #additionalBswmdFolderNew is added at the end similar to addAdditionalBswmd(Object).

IProjectAdditionalBswmdApi.removeAdditionalBswmd(Object)

Removes an additional BSWMD files folder. No change if the path to be removed is absent.

IProjectAdditionalBswmdApi.clearAdditionalBswmds()

Removes all additional BSWMD files folders.