or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

build-config.mdcore-model.mddependencies.mdindex.mdmodel-merging.mdprofiles.mdproject-metadata.mdrepositories.mdutility-classes.mdxml-io.md

dependencies.mddocs/

0

# Dependency Management

1

2

Classes for managing project dependencies, dependency scopes, exclusions, and dependency management sections. These classes handle all aspects of Maven's dependency resolution and management system.

3

4

## Capabilities

5

6

### Dependency

7

8

Represents a single project dependency with its coordinates, scope, and configuration options.

9

10

```java { .api }

11

public class Dependency {

12

// Core coordinates

13

public String getGroupId();

14

public void setGroupId(String groupId);

15

public String getArtifactId();

16

public void setArtifactId(String artifactId);

17

public String getVersion();

18

public void setVersion(String version);

19

public String getType();

20

public void setType(String type);

21

public String getClassifier();

22

public void setClassifier(String classifier);

23

24

// Dependency configuration

25

public String getScope();

26

public void setScope(String scope);

27

public String getSystemPath();

28

public void setSystemPath(String systemPath);

29

public boolean isOptional();

30

public String getOptional();

31

public void setOptional(String optional);

32

33

// Exclusions

34

public List<Exclusion> getExclusions();

35

public void setExclusions(List<Exclusion> exclusions);

36

public void addExclusion(Exclusion exclusion);

37

public void removeExclusion(Exclusion exclusion);

38

39

// Utility methods

40

public String getManagementKey();

41

public String toString();

42

public Dependency clone();

43

public InputLocation getLocation(Object key);

44

public void setLocation(Object key, InputLocation location);

45

}

46

```

47

48

**Usage Example:**

49

50

```java

51

Dependency dependency = new Dependency();

52

dependency.setGroupId("junit");

53

dependency.setArtifactId("junit");

54

dependency.setVersion("4.13.2");

55

dependency.setScope("test");

56

57

// Add exclusion

58

Exclusion exclusion = new Exclusion();

59

exclusion.setGroupId("org.hamcrest");

60

exclusion.setArtifactId("hamcrest-core");

61

dependency.addExclusion(exclusion);

62

63

model.addDependency(dependency);

64

```

65

66

### DependencyManagement

67

68

Container for managing default dependency versions and configurations that can be inherited by child modules.

69

70

```java { .api }

71

public class DependencyManagement {

72

public List<Dependency> getDependencies();

73

public void setDependencies(List<Dependency> dependencies);

74

public void addDependency(Dependency dependency);

75

public void removeDependency(Dependency dependency);

76

77

// Utility methods

78

public DependencyManagement clone();

79

public InputLocation getLocation(Object key);

80

public void setLocation(Object key, InputLocation location);

81

}

82

```

83

84

**Usage Example:**

85

86

```java

87

DependencyManagement depMgmt = new DependencyManagement();

88

89

Dependency managedDep = new Dependency();

90

managedDep.setGroupId("org.springframework");

91

managedDep.setArtifactId("spring-core");

92

managedDep.setVersion("5.3.21");

93

94

depMgmt.addDependency(managedDep);

95

model.setDependencyManagement(depMgmt);

96

```

97

98

### Exclusion

99

100

Represents a dependency exclusion, used to exclude transitive dependencies.

101

102

```java { .api }

103

public class Exclusion {

104

public String getGroupId();

105

public void setGroupId(String groupId);

106

public String getArtifactId();

107

public void setArtifactId(String artifactId);

108

109

// Utility methods

110

public String toString();

111

public Exclusion clone();

112

public InputLocation getLocation(Object key);

113

public void setLocation(Object key, InputLocation location);

114

}

115

```

116

117

**Common Dependency Scopes:**

118

119

- `compile` (default): Available in all classpaths

120

- `provided`: Available at compile time but not packaged

121

- `runtime`: Not needed at compile time but required at runtime

122

- `test`: Only available for test compilation and execution

123

- `system`: Similar to provided but must specify systemPath

124

- `import`: Only used in dependencyManagement for importing POM dependencies