Class InstantiationCommands

java.lang.Object
net.ssehub.easy.standalone.cmd.InstantiationCommands

public final class InstantiationCommands extends Object
Static commands for instantiating projects via the command line or by a build tool. Files/Folders to be passed in through this interface shall be absolute! This class considers ProjectNameMapper.
Before calling any of the methods here, EASy must be loaded via calling LowlevelCommands.startEASy().
Author:
El-Sharkawy
  • Constructor Details

    • InstantiationCommands

      private InstantiationCommands()
      Should prevent instantiation of this utility class.
  • Method Details

    • instantiateSelf

      public static void instantiateSelf(File project) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException
      Instantiates the given project. The project must:
      • be a valid EASy project with the usual configuration files and folders.
      • contain a frozen configuration
      • contain VIL script which can be applied to itself
      Parameters:
      project - The toplevel absolute folder of the project (must have a valid EASy structure)
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if the project could not be loaded, e.g. if the project has no valid EASy structure.
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
    • instantiateSelf

      public static void instantiateSelf(File project, Map<String,Object> arguments) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException
      Instantiates the given project. The project must:
      • be a valid EASy project with the usual configuration files and folders.
      • contain a frozen configuration
      • contain VIL script which can be applied to itself
      Parameters:
      project - The toplevel absolute folder of the project (must have a valid EASy structure)
      arguments - a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if the project could not be loaded, e.g. if the project has no valid EASy structure.
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
    • instantiateSelf

      public static void instantiateSelf(File project, File ivmlFile) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException, net.ssehub.easy.producer.core.persistence.PersistenceException
      Instantiates the given project. The project must:
      • contain VIL script which can be applied to itself, which uses the usual EASy naming convention for VIL scripts in Version 0.
      This method is a convenience wrapper for instantiateSelf(File, File, Map) with null as arguments.
      Parameters:
      project - The toplevel absolute folder of the project
      ivmlFile - A frozen configuration, which should be used for instantiation.
      Throws:
      net.ssehub.easy.basics.modelManagement.ModelManagementException - In case that the available information may be come inconsistent due to this update
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if at least one of the IVML or VIL files could not be loaded.
    • instantiateSelf

      public static void instantiateSelf(File project, File ivmlFile, Map<String,Object> arguments) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException, net.ssehub.easy.producer.core.persistence.PersistenceException
      Instantiates the given project. The project must:
      • contain VIL script which can be applied to itself, which uses the usual EASy naming convention for VIL scripts in Version 0.
      Parameters:
      project - The toplevel absolute folder of the project
      ivmlFile - A frozen configuration, which should be used for instantiation.
      arguments - a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)
      Throws:
      net.ssehub.easy.basics.modelManagement.ModelManagementException - In case that the available information may be come inconsistent due to this update
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if at least one of the IVML or VIL files could not be loaded.
    • instantiateSelf

      public static void instantiateSelf(File project, File ivmlFile, File buildScriptFile) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException, net.ssehub.easy.producer.core.persistence.PersistenceException
      Instantiates the given project.
      It's not necessary that the project has a valid EASy structure. This method is a convenience wrapper for instantiateSelf(File, File, File, Map) with null as arguments.
      Parameters:
      project - The toplevel absolute folder of the project
      ivmlFile - A frozen configuration, which should be used for instantiation.
      buildScriptFile - The main build script (starting point) which should be used for instantiation.
      Throws:
      net.ssehub.easy.basics.modelManagement.ModelManagementException - In case that the available information may become inconsistent due to this update
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if at least one of the IVML or VIL files could not be loaded.
    • instantiateSelf

      public static void instantiateSelf(File project, File ivmlFile, File buildScriptFile, Map<String,Object> arguments) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException, net.ssehub.easy.producer.core.persistence.PersistenceException
      Instantiates the given project.
      It's not necessary that the project has a valid EASy structure.
      Parameters:
      project - The toplevel absolute folder of the project
      ivmlFile - A frozen configuration, which should be used for instantiation.
      buildScriptFile - The main build script (starting point) which should be used for instantiation.
      arguments - a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)
      Throws:
      net.ssehub.easy.basics.modelManagement.ModelManagementException - In case that the available information may become inconsistent due to this update
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if at least one of the IVML or VIL files could not be loaded.
    • createArgumentProvider

      private static net.ssehub.easy.producer.core.mgmt.VilArgumentProvider createArgumentProvider(Map<String,Object> arguments)
      Creates an argument provider and registers it with VilArgumentProvider if necessary.
      Parameters:
      arguments - the arguments to be passed to VIL (may be null)
      Returns:
      the argument provider if one was created and registered, null else
    • instantiate

      public static void instantiate(File projectSource, File projectTarget) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException, IOException
      Instantiates the project projectTarget, while using source files (and IVML/VIL information) provided by projectSource. The following conditions must be hold:
      1. Both projects must exist and have a valid EASy project structure with the usual configuration files, IDs, and folders.
      2. projectTarget must contain a contain a frozen configuration.
      3. projectTarget must contain VIL script.
      4. projectSource must contain a infrastructure, which cen be instantiated, e.g. annotated source files.
      If projectTarget does not exist, this method will create the folder. In this case, 2.) and 3.) must be included in projectSource. This method is a convenience wrapper for instantiate(File, File, Map) with null as arguments.
      Parameters:
      projectSource - The toplevel absolute folder of an EASy project (must have a valid EASy structure), which serves as a basis for instantiation.
      projectTarget - The toplevel absolute folder of an EASy project (must have a valid EASy structure), which should be instantiated.
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if one of the projects could not be loaded, e.g. if the project has no valid EASy structure.
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
      IOException - If source or destination is invalid, or if an IO error occurs during copying
    • instantiate

      public static void instantiate(File projectSource, File projectTarget, Map<String,Object> arguments) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException, IOException
      Instantiates the project projectTarget, while using source files (and IVML/VIL information) provided by projectSource. The following conditions must be hold:
      1. Both projects must exist and have a valid EASy project structure with the usual configuration files, IDs, and folders.
      2. projectTarget must contain a contain a frozen configuration.
      3. projectTarget must contain VIL script.
      4. projectSource must contain a infrastructure, which cen be instantiated, e.g. annotated source files.
      If projectTarget does not exist, this method will create the folder. In this case, 2.) and 3.) must be included in projectSource.
      Parameters:
      projectSource - The toplevel absolute folder of an EASy project (must have a valid EASy structure), which serves as a basis for instantiation.
      projectTarget - The toplevel absolute folder of an EASy project (must have a valid EASy structure), which should be instantiated.
      arguments - a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if one of the projects could not be loaded, e.g. if the project has no valid EASy structure.
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
      IOException - If source or destination is invalid, or if an IO error occurs during copying
    • instantiateEASyProjects

      private static void instantiateEASyProjects(File projectSource, File projectTarget, Map<String,Object> arguments) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException
      Instantiates the project projectTarget, while using source files (and IVML/VIL information) provided by projectSource. The following conditions must be hold:
      • Both projects must exist and have a valid EASy project structure with the usual configuration files, IDs, and folders.
      • projectTarget must contain a contain a frozen configuration.
      • projectTarget must contain VIL script.
      • projectSource must contain a infrastructure, which can be instantiated, e.g. annotated source files.
      Parameters:
      projectSource - The toplevel absolute folder of an EASy project (must have a valid EASy structure), which serves as a basis for instantiation.
      projectTarget - The toplevel absolute folder of an EASy project (must have a valid EASy structure), which should be instantiated.
      arguments - a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if one of the projects could not be loaded, e.g. if the project has no valid EASy structure.
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
    • instantiate

      public static void instantiate(File projectSource, File projectTarget, File ivmlFile, File scriptFile) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, SecurityException, net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException, IOException
      Uses projectSource to instantiate projectTarget. The folder projectTarget will be created, if it does not exist. This method is a convenience wrapper for instantiate(File, File, File, File, Map) with null as arguments.
      Parameters:
      projectSource - An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.
      projectTarget - An absolute folder/project where the files should be instantiated in. The folder will be created if it does not exist.
      ivmlFile - The model definition including its frozen configuration, which should be used for instantiation. (Must be inside either of projectSource or projectTarget).
      scriptFile - The main build script (starting point) which should be used for instantiation. (Must be inside either of projectSource or projectTarget).
      Throws:
      SecurityException - If projectTarget does not exist, a security manager exists, and its SecurityManager.checkWrite(java.lang.String) method does not permit projectTarget directory to be created
      net.ssehub.easy.basics.modelManagement.ModelManagementException - In case that the available information may become inconsistent due to this update
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if at least one of the IVML or VIL files could not be loaded.
      IOException - If source or destination is invalid, or if an IO error occurs during copying
    • instantiate

      public static void instantiate(File projectSource, File projectTarget, File ivmlFile, File scriptFile, Map<String,Object> arguments) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, SecurityException, net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException, IOException
      Uses projectSource to instantiate projectTarget. The folder projectTarget will be created, if it does not exist.
      Parameters:
      projectSource - An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.
      projectTarget - An absolute folder/project where the files should be instantiated in. The folder will be created if it does not exist.
      ivmlFile - The model definition including its frozen configuration, which should be used for instantiation. (Must be inside either of projectSource or projectTarget).
      scriptFile - The main build script (starting point) which should be used for instantiation. (Must be inside either of projectSource or projectTarget).
      arguments - a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)
      Throws:
      SecurityException - If projectTarget does not exist, a security manager exists, and its SecurityManager.checkWrite(java.lang.String) method does not permit projectTarget directory to be created
      net.ssehub.easy.basics.modelManagement.ModelManagementException - In case that the available information may become inconsistent due to this update
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if at least one of the IVML or VIL files could not be loaded.
      IOException - If source or destination is invalid, or if an IO error occurs during copying
    • createPLPsAndInstantiate

      private static void createPLPsAndInstantiate(File projectSource, File projectTarget, net.ssehub.easy.varModel.model.Project ivmlProject, net.ssehub.easy.instantiation.core.model.buildlangModel.Script buildScript, Map<String,Object> arguments) throws net.ssehub.easy.instantiation.core.model.common.VilException
      Creates two (temporary) PLPInfos, links them (sets prede-/successor), and instantiates the successor.
      Parameters:
      projectSource - An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.
      projectTarget - An existing absolute folder/project where the files should be instantiated in.
      ivmlProject - A loaded configuration, which should be used for instantiation (Must not be null).
      buildScript - A loaded build script, which should be used for instantiation (Must not be null).
      arguments - a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
    • instantiate

      public static void instantiate(File projectSource, File projectTarget, ModelLoadDefinition ivmlDefinition, ModelLoadDefinition vilDefinition) throws net.ssehub.easy.producer.core.persistence.PersistenceException, IOException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException
      Uses projectSource to instantiate projectTarget. The folder projectTarget will be created, if it does not exist. This method is a convenience wrapper for instantiate(File, File, ModelLoadDefinition, ModelLoadDefinition, Map) with null as arguments.
      Parameters:
      projectSource - An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.
      projectTarget - An absolute folder/project where the files should be instantiated in. The folder will be created if it does not exist.
      ivmlDefinition - A (model name, version) pair for specifying which Project should be used for instantantion. The Project must be located inside of projectTarget or projectSource. This method first tries to load the Project from the projectTarget before it tries to load the Project from the projectSource.
      vilDefinition - A (model name, version) pair for specifying which Script should be used for instantantion. The Script must be located inside of projectTarget or projectSource. This method first tries to load the Script from the projectTarget before it tries to load the Script from the projectSource.
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if at least one of the IVML or VIL files could not be loaded.
      IOException - If source or destination is invalid, or if an IO error occurs during copying
      net.ssehub.easy.basics.modelManagement.ModelManagementException - In case that the available information may become inconsistent due to this update
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
    • instantiate

      public static void instantiate(File projectSource, File projectTarget, ModelLoadDefinition ivmlDefinition, ModelLoadDefinition vilDefinition, Map<String,Object> arguments) throws net.ssehub.easy.producer.core.persistence.PersistenceException, IOException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException
      Uses projectSource to instantiate projectTarget. The folder projectTarget will be created, if it does not exist.
      Parameters:
      projectSource - An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.
      projectTarget - An absolute folder/project where the files should be instantiated in. The folder will be created if it does not exist.
      ivmlDefinition - A (model name, version) pair for specifying which Project should be used for instantantion. The Project must be located inside of projectTarget or projectSource. This method first tries to load the Project from the projectTarget before it tries to load the Project from the projectSource.
      vilDefinition - A (model name, version) pair for specifying which Script should be used for instantantion. The Script must be located inside of projectTarget or projectSource. This method first tries to load the Script from the projectTarget before it tries to load the Script from the projectSource.
      arguments - a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if at least one of the IVML or VIL files could not be loaded.
      IOException - If source or destination is invalid, or if an IO error occurs during copying
      net.ssehub.easy.basics.modelManagement.ModelManagementException - In case that the available information may become inconsistent due to this update
      net.ssehub.easy.instantiation.core.model.common.VilException - In case that artifact operations or script execution fails
    • checkIsNestedFile

      private static boolean checkIsNestedFile(File possibleParent, File maybeChild)
      Checks whether maybeChild is nested inside of possibleParent.
      Parameters:
      possibleParent - A folder which may contain maybeChild.
      maybeChild - A file or folder which should be located inside of possibleParent.
      Returns:
      true if maybeChild is nested inside of possibleParent, false otherwise.
      See Also:
    • createTargetFolder

      private static void createTargetFolder(File projectSource, File projectTarget) throws net.ssehub.easy.producer.core.persistence.PersistenceException, IOException
      Creates projectTarget if it does not exist. Copies also all configuration files, i.e. the EASy folder from projectSource to projectTarget.
      Parameters:
      projectSource - A EASy project which contains a EASy folder with IVML/VIL files.
      projectTarget - The folder which shall be created.
      Throws:
      net.ssehub.easy.producer.core.persistence.PersistenceException - Will be thrown if the folder could not be created.
      IOException - If source or destination is invalid, or if an IO error occurs during copying