@Override
    public void generateInstructions(JpsArtifactOutputPackagingElement element,
                                     ArtifactCompilerInstructionCreator instructionCreator,
                                     ArtifactInstructionsBuilderContext builderContext) {
      final JpsArtifact artifact = element.getArtifactReference().resolve();
      if (artifact == null) return;

      Set<JpsArtifact> parentArtifacts = builderContext.getParentArtifacts();
      List<JpsPackagingElement> customLayout = getCustomArtifactLayout(artifact, parentArtifacts);

      final String outputPath = artifact.getOutputPath();
      if (StringUtil.isEmpty(outputPath) || customLayout != null) {
        try {
          if (builderContext.enterArtifact(artifact)) {
            if (customLayout != null) {
              LayoutElementBuildersRegistry.this.generateInstructions(customLayout, instructionCreator, builderContext);
            }
            else {
              generateSubstitutionInstructions(element, instructionCreator, builderContext);
            }
          }
        }
        finally {
          builderContext.leaveArtifact(artifact);
        }
        return;
      }

      final JpsPackagingElement rootElement = artifact.getRootElement();
      final File outputDir = new File(outputPath);
      if (rootElement instanceof JpsArchivePackagingElement) {
        final String fileName = ((JpsArchivePackagingElement)rootElement).getArchiveName();
        instructionCreator.addFileCopyInstruction(new File(outputDir, fileName), fileName);
      }
      else {
        instructionCreator.addDirectoryCopyInstructions(outputDir);
      }
    }
@Override
    public void generateInstructions(JpsArtifactOutputPackagingElement element,
                                     ArtifactCompilerInstructionCreator instructionCreator,
                                     ArtifactInstructionsBuilderContext builderContext)