Distributing Files


In the "Files" step of the install4j IDE, you define your distribution tree, collecting files from different places to be distributed in the generated media files. In addition, you can optionally define installation components.

On the "Define Distribution Tree" step, you add and edit the structural elements that make up the distribution tree. You can create your own directory structure and "mount" directories from your file system or add single files into arbitrary directories. With drag and drop and double-clicking on nodes you can modify an existing distribution tree.

On the "View Results" step, you then see the actual file tree as it will be collected and distributed by the generated media files. Go to this step to check whether your actions on the "Define Distribution Tree" step actually produce the desired results.

Root container nodes

The top-level nodes in the distribution tree are called file sets. There is one "Default file set" node that cannot be deleted or renamed. The relative paths of all files that are added to a file set must be unique. See the help topic on file sets and installation components for more information on how to use file sets.

Within a single file set, it causes an error at build time if the installation paths for two files collide. For example, if you have added the contents of two different directories into the same folder in the distribution tree and both directories contain a file file.txt, building the project will fail with a corresponding error message. In this case, you have to exclude the file in one of the directory entries. This is only an issue for files, sub-directory hierarchies on the other hand are merged and can overlap between multiple directory entries and explicitly added folders.

You can create new file sets with the  New File Set action in the  add menu on the right side. Each file set has its own "Installation directory" root. If you define custom roots that should be present in multiple file sets, you have to duplicate them.

The child nodes of a file set are called installation roots. Their location is resolved when the installer runs. There are two types of roots:

Content nodes

Adding files to the distribution tree is done with the  Add Files And Directories action in the  add menu on the right side or in the context menu. In the first step of the file wizard you choose the source or the files:

Folder nodes

Fixed folder nodes can occur below the root nodes to build nested directory structures. Using the "Edit entry" action on a fixed folder node allows you to edit the unix mode of the folder.

Usually, a directory structure will be copied from a staged distribution directory, but fixed folders are useful under several circumstances. For example, if you want to apply different top-level prefix directories, you can add corresponding folder.

Also, fixed folders and single files in fixed folders have a higher precedence than folders and files from directory entries. In this way, you override settings for certain folders or files. For example, if a "contents of a directory" node includes the file a/b/c.txt, you can manually add nested folders a and b and then add the single file node c.txt. You could then set a different overwrite or uninstall policy for the file. Also, you could override the Unix mode of the directories.

Compiler variables as directory or file names

Using compiler variables as directory or file names in the distribution tree allows you to make compile-time conditional includes. The following rules apply:

For conditions that are evaluated at runtime or for adding platform dependent files, you should use files sets instead.

File options

On the "File options" step, a number of settings determine the behavior of the installer and uninstaller. When files are already present, you can choose a number of strategies for the "Install files" actions by changing the "Default overwrite policy". Similarly, the "Uninstall files" action decides what to do for installed files based on the "Default uninstall policy" setting. On Unix, the "Install files" action assigns permissions to installed files and directories as configured in the default Unix file and directory modes on this step. All these options can be overridden in the configuration of the content nodes.

Other available options concern the compilation phase. You can choose the source of the file modification times, specify a global pattern of files and directories that should be ignored when collecting files and select a strategy for what should happen if some specified files are missing at build time.