Skip to main content
Version: Next

Project dependencies

Project dependencies ( {projectFile : 4D.File} ) : Object

ParameterTypeDescription
projectFile4D.File→.4DProject or .4dz file whose dependencies must be resolved. If omitted, the current project is used.
Function resultObject←Object containing the root project file and its dependencies in compilation order.
History
ReleaseChanges
21 R6Added

Description​

Project dependencies returns the current project's dependencies, or the dependencies of the project file passed in projectFile. The dependencies are returned in the order required to compile them before the root project.

The command uses the project's dependencies.json file to determine the dependency order. In a dependency graph where multiple components depend on the same component, the shared dependency is returned only once and before its dependents. Dependency cycles do not prevent the command from returning a result; they are reported as warnings.

note

The command does not retrieve, download, or install dependencies. Dependency retrieval remains the responsibility of the dependency manager.

The command throws a standard 4D error if the root project's dependencies.json file exists but cannot be read, contains invalid JSON, or has an invalid manifest structure (these errors are not returned in a dependency's errors collection).

Function result​

The object returned by Project dependencies contains the following properties:

PropertyTypeDescription
projectFile4D.File or NullRoot project file to compile last (.4DProject or .4dz). Same value as passed in the projectFile parameter or current project file if omitted. Null if none was found.
dependenciesCollectionDependencies in the order required for compilation. Each dependency is listed once.
dependencies[].projectFile4D.File or Null.4DProject or .4dz file for the dependency. Null if the dependency is not available.
dependencies[].nameTextDependency project name.
dependencies[].errorsCollectionErrors for this dependency. These can describe a corrupted or invalid component, a network failure while retrieving it, or a missing component folder.
dependencies[].warningsCollectionNon-blocking dependency issues. This property is returned only when at least one warning is present. Warnings can report inconsistencies, dependency cycles, and warnings recorded by the dependency manager.

Example​

Compile the interpreted dependencies in the required order, then compile the root project with those dependencies declared as components:

var $dependency : Object

// Resolve the current project's dependencies in compilation order
var $deps:=Project dependencies

// Compile each available dependency before the project that uses it
For each ($dependency; $deps.dependencies)
// Skip dependencies that could not be resolved or have errors.
If (($dependency.projectFile#Null) && \
($dependency.errors=Null) && \
($dependency.projectFile.extension=".4DProject"))

$options:={components: $dependency.components; targets: ["x86_64_generic"]}

var $result:=Compile project($dependency.projectFile; $options)

If (Not($result.success))
ALERT("Failed to compile dependency: "+$dependency.name)
return
End if

End if
End for each

// Compile the root project
var $options:={components: $deps.dependencies; targets: ["x86_64_generic"]}
$result:=Compile project($deps.projectFile; $options)
If ($result.success)
ALERT("Project compiled successfully.")
Else
ALERT("Failed to compile the root project.")
End if

See also​

Compile project
COMPONENT LIST Monitoring Project Dependencies

Properties​

Command number1868
Thread safeyes