1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.model.locator;
20
21 import javax.inject.Named;
22 import javax.inject.Singleton;
23
24 import java.io.File;
25 import java.nio.file.Files;
26 import java.nio.file.Path;
27 import java.nio.file.Paths;
28
29
30
31
32
33
34 @Named
35 @Singleton
36 @Deprecated(since = "4.0.0")
37 public class DefaultModelLocator implements ModelLocator {
38
39 @Deprecated
40 @Override
41 public File locatePom(File projectDirectory) {
42 Path path = locatePom(projectDirectory != null ? projectDirectory.toPath() : null);
43 return path != null ? path.toFile() : null;
44 }
45
46 @Override
47 public Path locatePom(Path projectDirectory) {
48 return projectDirectory != null ? projectDirectory : Paths.get(System.getProperty("user.dir"));
49 }
50
51 @Deprecated
52 @Override
53 public File locateExistingPom(File project) {
54 Path path = locateExistingPom(project != null ? project.toPath() : null);
55 return path != null ? path.toFile() : null;
56 }
57
58 @Override
59 public Path locateExistingPom(Path project) {
60 if (project == null || Files.isDirectory(project)) {
61 project = locatePom(project);
62 }
63 if (Files.isDirectory(project)) {
64 Path pom = project.resolve("pom.xml");
65 return Files.isRegularFile(pom) ? pom : null;
66 } else if (Files.isRegularFile(project)) {
67 return project;
68 } else {
69 return null;
70 }
71 }
72 }