or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

artifact-management.mdindex.mdlegacy-repository-system.mdmetadata-processing.mdprofile-management.mdproject-building.mdrepository-operations.mdruntime-information.md

legacy-repository-system.mddocs/

0

# Legacy Repository System

1

2

Main legacy repository system implementation providing comprehensive backward compatibility with Maven2 repository operations.

3

4

## Capabilities

5

6

### LegacyRepositorySystem

7

8

Main legacy repository system implementation that provides the primary interface for all repository operations.

9

10

```java { .api }

11

/**

12

* Main legacy repository system implementation providing Maven2 compatibility

13

* @Component(role = RepositorySystem.class, hint = "default")

14

*/

15

public class LegacyRepositorySystem implements RepositorySystem {

16

/**

17

* Creates an artifact with the specified coordinates

18

* @param groupId artifact group identifier

19

* @param artifactId artifact identifier

20

* @param version artifact version

21

* @param scope dependency scope

22

* @param type artifact type (jar, war, etc.)

23

* @return created Artifact instance

24

*/

25

public Artifact createArtifact(String groupId, String artifactId, String version,

26

String scope, String type);

27

28

/**

29

* Creates an artifact with classifier

30

* @param groupId artifact group identifier

31

* @param artifactId artifact identifier

32

* @param version artifact version

33

* @param scope dependency scope

34

* @param type artifact type

35

* @param classifier artifact classifier

36

* @return created Artifact instance

37

*/

38

public Artifact createArtifactWithClassifier(String groupId, String artifactId, String version,

39

String type, String classifier);

40

41

/**

42

* Creates a dependency artifact

43

* @param dependency dependency information

44

* @return created Artifact instance

45

*/

46

public Artifact createDependencyArtifact(Dependency dependency);

47

48

/**

49

* Creates the default local repository

50

* @return default local ArtifactRepository

51

* @throws InvalidRepositoryException if repository creation fails

52

*/

53

public ArtifactRepository createDefaultLocalRepository() throws InvalidRepositoryException;

54

55

/**

56

* Creates a local repository at the specified path

57

* @param localRepositoryPath path to local repository

58

* @return local ArtifactRepository

59

* @throws InvalidRepositoryException if repository creation fails

60

*/

61

public ArtifactRepository createLocalRepository(String localRepositoryPath)

62

throws InvalidRepositoryException;

63

64

/**

65

* Creates a local repository from URL

66

* @param url repository URL

67

* @return local ArtifactRepository

68

* @throws InvalidRepositoryException if repository creation fails

69

*/

70

public ArtifactRepository createLocalRepository(URL url) throws InvalidRepositoryException;

71

72

/**

73

* Creates a default remote repository

74

* @return default remote ArtifactRepository

75

* @throws InvalidRepositoryException if repository creation fails

76

*/

77

public ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException;

78

79

/**

80

* Resolves artifacts according to the resolution request

81

* @param request artifact resolution request

82

* @return resolution result with resolved artifacts

83

* @throws ArtifactResolutionException if resolution fails

84

*/

85

public ArtifactResolutionResult resolve(ArtifactResolutionRequest request)

86

throws ArtifactResolutionException;

87

88

/**

89

* Publishes (deploys) an artifact to a repository

90

* @param repository target repository

91

* @param source source file to publish

92

* @param artifact artifact metadata

93

* @throws ArtifactNotPublishedException if publication fails

94

*/

95

public void publish(ArtifactRepository repository, File source, Artifact artifact,

96

ArtifactMetadata metadata) throws ArtifactNotPublishedException;

97

98

/**

99

* Installs an artifact to the local repository

100

* @param repository local repository

101

* @param source source file to install

102

* @param artifact artifact metadata

103

* @throws ArtifactInstallationException if installation fails

104

*/

105

public void install(ArtifactRepository repository, File source, Artifact artifact)

106

throws ArtifactInstallationException;

107

108

/**

109

* Injects mirror configurations into repository list

110

* @param repositories list of repositories to modify

111

* @param mirrors list of mirror configurations

112

*/

113

public void injectMirror(List<ArtifactRepository> repositories, List<Mirror> mirrors);

114

115

/**

116

* Injects authentication configurations into repository list

117

* @param repositories list of repositories to modify

118

* @param servers list of server configurations with authentication

119

*/

120

public void injectAuthentication(List<ArtifactRepository> repositories, List<Server> servers);

121

122

/**

123

* Injects proxy configurations into repository list

124

* @param repositories list of repositories to modify

125

* @param proxies list of proxy configurations

126

*/

127

public void injectProxy(List<ArtifactRepository> repositories, List<Proxy> proxies);

128

}

129

```

130

131

### WagonManager

132

133

Interface for managing Wagon transport protocols.

134

135

```java { .api }

136

/**

137

* Interface for managing Wagon transport protocols

138

*/

139

public interface WagonManager {

140

/**

141

* Role constant for Plexus component lookup

142

*/

143

String ROLE = WagonManager.class.getName();

144

145

/**

146

* Gets authentication information for a server ID

147

* @param id server identifier

148

* @return AuthenticationInfo for the server

149

*/

150

AuthenticationInfo getAuthenticationInfo(String id);

151

152

/**

153

* Gets proxy information for a protocol

154

* @param protocol transport protocol

155

* @return ProxyInfo for the protocol

156

*/

157

ProxyInfo getProxy(String protocol);

158

159

/**

160

* Downloads an artifact from a repository

161

* @param artifact artifact to download

162

* @param repository source repository

163

* @throws TransferFailedException if transfer fails

164

* @throws ResourceDoesNotExistException if artifact doesn't exist

165

*/

166

void getArtifact(Artifact artifact, ArtifactRepository repository)

167

throws TransferFailedException, ResourceDoesNotExistException;

168

169

/**

170

* Downloads an artifact from a repository to a destination

171

* @param artifact artifact to download

172

* @param repository source repository

173

* @param destination destination file

174

* @throws TransferFailedException if transfer fails

175

* @throws ResourceDoesNotExistException if artifact doesn't exist

176

*/

177

void getArtifact(Artifact artifact, ArtifactRepository repository, File destination)

178

throws TransferFailedException, ResourceDoesNotExistException;

179

180

/**

181

* Gets the mirror repository for a given repository

182

* @param repository original repository

183

* @return mirror repository or original if no mirror configured

184

*/

185

ArtifactRepository getMirrorRepository(ArtifactRepository repository);

186

187

/**

188

* Uploads an artifact to a repository

189

* @param source source file to upload

190

* @param artifact artifact metadata

191

* @param repository target repository

192

* @throws TransferFailedException if transfer fails

193

*/

194

void putArtifact(File source, Artifact artifact, ArtifactRepository repository)

195

throws TransferFailedException;

196

197

/**

198

* Uploads artifact metadata to a repository

199

* @param metadata artifact metadata to upload

200

* @param repository target repository

201

* @throws TransferFailedException if transfer fails

202

*/

203

void putArtifactMetadata(File metadata, ArtifactMetadata artifactMetadata,

204

ArtifactRepository repository) throws TransferFailedException;

205

}

206

```

207

208

### DefaultWagonManager

209

210

Default implementation of WagonManager.

211

212

```java { .api }

213

/**

214

* Default implementation of WagonManager

215

*/

216

public class DefaultWagonManager implements WagonManager {

217

/**

218

* Gets authentication information for a server ID

219

*/

220

public AuthenticationInfo getAuthenticationInfo(String id);

221

222

/**

223

* Gets proxy information for a protocol

224

*/

225

public ProxyInfo getProxy(String protocol);

226

227

/**

228

* Downloads an artifact from a repository

229

*/

230

public void getArtifact(Artifact artifact, ArtifactRepository repository)

231

throws TransferFailedException, ResourceDoesNotExistException;

232

233

/**

234

* Gets the mirror repository for a given repository

235

*/

236

public ArtifactRepository getMirrorRepository(ArtifactRepository repository);

237

238

/**

239

* Uploads an artifact to a repository

240

*/

241

public void putArtifact(File source, Artifact artifact, ArtifactRepository repository)

242

throws TransferFailedException;

243

}

244

```

245

246

### UpdateCheckManager

247

248

Interface for managing artifact update checks.

249

250

```java { .api }

251

/**

252

* Interface for managing artifact update checks

253

*/

254

public interface UpdateCheckManager {

255

/**

256

* Role constant for Plexus component lookup

257

*/

258

String ROLE = UpdateCheckManager.class.getName();

259

260

/**

261

* Checks if an artifact needs to be updated

262

* @param artifact artifact to check

263

* @param repository repository to check against

264

* @param file local file representing the artifact

265

* @return true if artifact needs update

266

*/

267

boolean isUpdateRequired(Artifact artifact, ArtifactRepository repository, File file);

268

269

/**

270

* Records that an artifact was checked for updates

271

* @param artifact artifact that was checked

272

* @param repository repository that was checked

273

* @param file local file representing the artifact

274

*/

275

void touch(Artifact artifact, ArtifactRepository repository, File file);

276

277

/**

278

* Checks if metadata needs to be updated

279

* @param metadata metadata to check

280

* @param repository repository to check against

281

* @param file local metadata file

282

* @return true if metadata needs update

283

*/

284

boolean isUpdateRequired(ArtifactMetadata metadata, ArtifactRepository repository, File file);

285

286

/**

287

* Records that metadata was checked for updates

288

* @param metadata metadata that was checked

289

* @param repository repository that was checked

290

* @param file local metadata file

291

*/

292

void touch(ArtifactMetadata metadata, ArtifactRepository repository, File file);

293

}

294

```

295

296

### DefaultUpdateCheckManager

297

298

Default implementation of UpdateCheckManager.

299

300

```java { .api }

301

/**

302

* Default implementation of UpdateCheckManager

303

*/

304

public class DefaultUpdateCheckManager implements UpdateCheckManager {

305

/**

306

* Checks if an artifact needs to be updated

307

*/

308

public boolean isUpdateRequired(Artifact artifact, ArtifactRepository repository, File file);

309

310

/**

311

* Records that an artifact was checked for updates

312

*/

313

public void touch(Artifact artifact, ArtifactRepository repository, File file);

314

315

/**

316

* Checks if metadata needs to be updated

317

*/

318

public boolean isUpdateRequired(ArtifactMetadata metadata, ArtifactRepository repository, File file);

319

320

/**

321

* Records that metadata was checked for updates

322

*/

323

public void touch(ArtifactMetadata metadata, ArtifactRepository repository, File file);

324

}

325

```

326

327

## Conflict Resolution

328

329

### ConflictResolver

330

331

Interface for resolving conflicts between artifact versions.

332

333

```java { .api }

334

/**

335

* Interface for resolving conflicts between artifact versions

336

*/

337

public interface ConflictResolver {

338

/**

339

* Role constant for Plexus component lookup

340

*/

341

String ROLE = ConflictResolver.class.getName();

342

343

/**

344

* Resolves conflict between two resolution nodes

345

* @param node1 first conflicting node

346

* @param node2 second conflicting node

347

* @return ResolutionNode representing the resolved choice

348

* @throws ConflictResolverException if resolution fails

349

*/

350

ResolutionNode resolveConflict(ResolutionNode node1, ResolutionNode node2)

351

throws ConflictResolverException;

352

}

353

```

354

355

### ConflictResolverFactory

356

357

Factory for creating conflict resolver instances.

358

359

```java { .api }

360

/**

361

* Factory for creating conflict resolver instances

362

*/

363

public interface ConflictResolverFactory {

364

/**

365

* Role constant for Plexus component lookup

366

*/

367

String ROLE = ConflictResolverFactory.class.getName();

368

369

/**

370

* Creates a conflict resolver by hint

371

* @param hint resolver type hint

372

* @return ConflictResolver instance

373

* @throws ConflictResolverNotFoundException if resolver not found

374

*/

375

ConflictResolver getConflictResolver(String hint) throws ConflictResolverNotFoundException;

376

}

377

```

378

379

### Conflict Resolution Strategies

380

381

```java { .api }

382

/**

383

* Chooses the nearest version in the dependency tree

384

*/

385

public class NearestConflictResolver implements ConflictResolver {

386

public ResolutionNode resolveConflict(ResolutionNode node1, ResolutionNode node2);

387

}

388

389

/**

390

* Chooses the newest version among conflicting artifacts

391

*/

392

public class NewestConflictResolver implements ConflictResolver {

393

public ResolutionNode resolveConflict(ResolutionNode node1, ResolutionNode node2);

394

}

395

396

/**

397

* Chooses the oldest version among conflicting artifacts

398

*/

399

public class OldestConflictResolver implements ConflictResolver {

400

public ResolutionNode resolveConflict(ResolutionNode node1, ResolutionNode node2);

401

}

402

403

/**

404

* Chooses the farthest version in the dependency tree

405

*/

406

public class FarthestConflictResolver implements ConflictResolver {

407

public ResolutionNode resolveConflict(ResolutionNode node1, ResolutionNode node2);

408

}

409

```

410

411

## Usage Examples

412

413

### Basic Repository System Usage

414

415

```java

416

import org.apache.maven.repository.legacy.LegacyRepositorySystem;

417

import org.apache.maven.artifact.Artifact;

418

import org.apache.maven.artifact.repository.ArtifactRepository;

419

420

// Create repository system instance

421

LegacyRepositorySystem repositorySystem = new LegacyRepositorySystem();

422

423

// Create local repository

424

try {

425

ArtifactRepository localRepo = repositorySystem.createDefaultLocalRepository();

426

System.out.println("Local repository: " + localRepo.getUrl());

427

428

// Create remote repository

429

ArtifactRepository remoteRepo = repositorySystem.createDefaultRemoteRepository();

430

System.out.println("Remote repository: " + remoteRepo.getUrl());

431

432

} catch (InvalidRepositoryException e) {

433

System.err.println("Repository creation failed: " + e.getMessage());

434

}

435

```

436

437

### Artifact Creation and Resolution

438

439

```java

440

// Create artifacts

441

Artifact artifact = repositorySystem.createArtifact(

442

"org.apache.commons",

443

"commons-lang3",

444

"3.12.0",

445

"compile",

446

"jar"

447

);

448

449

Artifact classifiedArtifact = repositorySystem.createArtifactWithClassifier(

450

"org.apache.commons",

451

"commons-lang3",

452

"3.12.0",

453

"jar",

454

"sources"

455

);

456

457

// Resolve artifacts

458

ArtifactResolutionRequest request = new ArtifactResolutionRequest();

459

request.setArtifact(artifact);

460

request.setLocalRepository(localRepository);

461

request.setRemoteRepositories(Arrays.asList(remoteRepository));

462

463

try {

464

ArtifactResolutionResult result = repositorySystem.resolve(request);

465

466

if (result.isSuccess()) {

467

System.out.println("Artifact resolved successfully");

468

Set<Artifact> resolvedArtifacts = result.getArtifacts();

469

System.out.println("Resolved " + resolvedArtifacts.size() + " artifacts");

470

} else {

471

System.err.println("Resolution failed");

472

for (Exception exception : result.getExceptions()) {

473

System.err.println(" " + exception.getMessage());

474

}

475

}

476

477

} catch (ArtifactResolutionException e) {

478

System.err.println("Resolution error: " + e.getMessage());

479

}

480

```

481

482

### Mirror and Authentication Configuration

483

484

```java

485

import org.apache.maven.settings.Mirror;

486

import org.apache.maven.settings.Server;

487

488

// Configure mirrors

489

List<Mirror> mirrors = new ArrayList<>();

490

Mirror centralMirror = new Mirror();

491

centralMirror.setId("central-mirror");

492

centralMirror.setMirrorOf("central");

493

centralMirror.setUrl("https://repo.company.com/maven2/");

494

mirrors.add(centralMirror);

495

496

// Apply mirror configuration

497

List<ArtifactRepository> repositories = Arrays.asList(centralRepo, otherRepo);

498

repositorySystem.injectMirror(repositories, mirrors);

499

500

// Configure authentication

501

List<Server> servers = new ArrayList<>();

502

Server server = new Server();

503

server.setId("central-mirror");

504

server.setUsername("user");

505

server.setPassword("password");

506

servers.add(server);

507

508

// Apply authentication configuration

509

repositorySystem.injectAuthentication(repositories, servers);

510

511

System.out.println("Mirror and authentication configured");

512

```

513

514

### Wagon Manager Usage

515

516

```java

517

import org.apache.maven.repository.legacy.WagonManager;

518

import org.apache.maven.repository.legacy.DefaultWagonManager;

519

import org.apache.maven.wagon.authentication.AuthenticationInfo;

520

import org.apache.maven.wagon.proxy.ProxyInfo;

521

522

// Use wagon manager for transport operations

523

WagonManager wagonManager = new DefaultWagonManager();

524

525

// Get authentication info

526

AuthenticationInfo authInfo = wagonManager.getAuthenticationInfo("server-id");

527

if (authInfo != null) {

528

System.out.println("Authentication configured for server");

529

}

530

531

// Get proxy info

532

ProxyInfo proxyInfo = wagonManager.getProxy("http");

533

if (proxyInfo != null) {

534

System.out.println("Proxy configured: " + proxyInfo.getHost());

535

}

536

537

// Download artifact

538

try {

539

wagonManager.getArtifact(artifact, repository);

540

System.out.println("Artifact downloaded successfully");

541

} catch (TransferFailedException | ResourceDoesNotExistException e) {

542

System.err.println("Download failed: " + e.getMessage());

543

}

544

```

545

546

### Update Check Management

547

548

```java

549

import org.apache.maven.repository.legacy.UpdateCheckManager;

550

import org.apache.maven.repository.legacy.DefaultUpdateCheckManager;

551

552

// Manage update checks

553

UpdateCheckManager updateManager = new DefaultUpdateCheckManager();

554

File localArtifactFile = new File(localRepo.getBasedir(), "path/to/artifact.jar");

555

556

// Check if update is required

557

boolean updateRequired = updateManager.isUpdateRequired(artifact, remoteRepository, localArtifactFile);

558

559

if (updateRequired) {

560

System.out.println("Artifact needs update");

561

// Perform update...

562

563

// Record that we checked

564

updateManager.touch(artifact, remoteRepository, localArtifactFile);

565

} else {

566

System.out.println("Artifact is up to date");

567

}

568

```

569

570

### Conflict Resolution

571

572

```java

573

import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;

574

import org.apache.maven.repository.legacy.resolver.conflict.NearestConflictResolver;

575

import org.apache.maven.repository.legacy.resolver.conflict.NewestConflictResolver;

576

577

// Use different conflict resolution strategies

578

ConflictResolver nearestResolver = new NearestConflictResolver();

579

ConflictResolver newestResolver = new NewestConflictResolver();

580

581

// Resolve conflicts between nodes

582

ResolutionNode node1 = // ... create first conflicting node

583

ResolutionNode node2 = // ... create second conflicting node

584

585

try {

586

ResolutionNode nearestChoice = nearestResolver.resolveConflict(node1, node2);

587

ResolutionNode newestChoice = newestResolver.resolveConflict(node1, node2);

588

589

System.out.println("Nearest resolver chose: " + nearestChoice.getArtifact());

590

System.out.println("Newest resolver chose: " + newestChoice.getArtifact());

591

592

} catch (ConflictResolverException e) {

593

System.err.println("Conflict resolution failed: " + e.getMessage());

594

}

595

```

596

597

### Complete Repository Workflow

598

599

```java

600

public void performRepositoryOperations() {

601

try {

602

// Initialize repository system

603

LegacyRepositorySystem repoSystem = new LegacyRepositorySystem();

604

605

// Set up repositories

606

ArtifactRepository localRepo = repoSystem.createDefaultLocalRepository();

607

ArtifactRepository remoteRepo = repoSystem.createDefaultRemoteRepository();

608

609

// Configure mirrors and authentication

610

configureMirrorsAndAuth(repoSystem, Arrays.asList(remoteRepo));

611

612

// Create and resolve artifact

613

Artifact artifact = repoSystem.createArtifact(

614

"junit", "junit", "4.13.2", "test", "jar"

615

);

616

617

ArtifactResolutionRequest request = new ArtifactResolutionRequest();

618

request.setArtifact(artifact);

619

request.setLocalRepository(localRepo);

620

request.setRemoteRepositories(Arrays.asList(remoteRepo));

621

622

ArtifactResolutionResult result = repoSystem.resolve(request);

623

624

if (result.isSuccess()) {

625

// Install to local repository

626

File artifactFile = artifact.getFile();

627

repoSystem.install(localRepo, artifactFile, artifact);

628

System.out.println("Artifact installed successfully");

629

}

630

631

} catch (Exception e) {

632

System.err.println("Repository operation failed: " + e.getMessage());

633

}

634

}

635

```

636

637

## Migration Notes

638

639

The Legacy Repository System is deprecated and maintained only for backward compatibility. Modern Maven 3.x applications should use:

640

641

- Eclipse Aether for dependency resolution

642

- `org.apache.maven.repository.RepositorySystem` (modern interface)

643

- Standard Maven 3.x dependency injection instead of Plexus components

644

- `org.apache.maven.execution.MavenExecutionRequest` for configuration