1 package org.apache.maven.api;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.nio.file.Path;
23 import java.util.List;
24 import java.util.Optional;
25
26 import org.apache.maven.api.annotations.Experimental;
27 import org.apache.maven.api.annotations.Nonnull;
28 import org.apache.maven.api.model.Build;
29 import org.apache.maven.api.model.Model;
30
31 /**
32 * Interface representing a Maven project.
33 * Projects can be built using the {@link org.apache.maven.api.services.ProjectBuilder} service.
34 *
35 * @since 4.0
36 */
37 @Experimental
38 public interface Project
39 {
40
41 @Nonnull
42 String getGroupId();
43
44 @Nonnull
45 String getArtifactId();
46
47 @Nonnull
48 String getVersion();
49
50 @Nonnull
51 String getPackaging();
52
53 @Nonnull
54 Artifact getArtifact();
55
56 @Nonnull
57 Model getModel();
58
59 @Nonnull
60 default Build getBuild()
61 {
62 Build build = getModel().getBuild();
63 return build != null ? build : Build.newInstance();
64 }
65
66 /**
67 * Returns the path to the pom file for this project.
68 * A project is usually read from the file system and this will point to
69 * the file. In some cases, a transient project can be created which
70 * will not point to an actual pom file.
71 * @return the path of the pom
72 */
73 @Nonnull
74 Optional<Path> getPomPath();
75
76 @Nonnull
77 default Optional<Path> getBasedir()
78 {
79 return getPomPath().map( Path::getParent );
80 }
81
82 @Nonnull
83 List<DependencyCoordinate> getDependencies();
84
85 @Nonnull
86 List<DependencyCoordinate> getManagedDependencies();
87
88 @Nonnull
89 default String getId()
90 {
91 return getModel().getId();
92 }
93
94 boolean isExecutionRoot();
95
96 @Nonnull
97 Optional<Project> getParent();
98
99 @Nonnull
100 List<RemoteRepository> getRemoteProjectRepositories();
101
102 @Nonnull
103 List<RemoteRepository> getRemotePluginRepositories();
104
105 }