1
2
3
4
5 package org.apache.maven.model.v4;
6
7 import java.io.ObjectStreamException;
8 import java.nio.file.Path;
9 import java.util.AbstractList;
10 import java.util.ArrayList;
11 import java.util.Collection;
12 import java.util.HashMap;
13 import java.util.Iterator;
14 import java.util.LinkedHashMap;
15 import java.util.List;
16 import java.util.Map;
17 import java.util.Objects;
18 import java.util.function.BinaryOperator;
19 import java.util.function.Function;
20 import java.util.stream.Collectors;
21
22 import org.apache.maven.api.annotations.Generated;
23 import org.apache.maven.api.xml.XmlNode;
24 import org.apache.maven.api.model.Model;
25 import org.apache.maven.api.model.ModelBase;
26 import org.apache.maven.api.model.PluginContainer;
27 import org.apache.maven.api.model.PluginConfiguration;
28 import org.apache.maven.api.model.BuildBase;
29 import org.apache.maven.api.model.Build;
30 import org.apache.maven.api.model.CiManagement;
31 import org.apache.maven.api.model.Notifier;
32 import org.apache.maven.api.model.Contributor;
33 import org.apache.maven.api.model.Dependency;
34 import org.apache.maven.api.model.Developer;
35 import org.apache.maven.api.model.Exclusion;
36 import org.apache.maven.api.model.IssueManagement;
37 import org.apache.maven.api.model.DistributionManagement;
38 import org.apache.maven.api.model.License;
39 import org.apache.maven.api.model.MailingList;
40 import org.apache.maven.api.model.Organization;
41 import org.apache.maven.api.model.PatternSet;
42 import org.apache.maven.api.model.Parent;
43 import org.apache.maven.api.model.Scm;
44 import org.apache.maven.api.model.FileSet;
45 import org.apache.maven.api.model.Resource;
46 import org.apache.maven.api.model.RepositoryBase;
47 import org.apache.maven.api.model.Repository;
48 import org.apache.maven.api.model.DeploymentRepository;
49 import org.apache.maven.api.model.RepositoryPolicy;
50 import org.apache.maven.api.model.Site;
51 import org.apache.maven.api.model.ConfigurationContainer;
52 import org.apache.maven.api.model.Plugin;
53 import org.apache.maven.api.model.PluginExecution;
54 import org.apache.maven.api.model.DependencyManagement;
55 import org.apache.maven.api.model.PluginManagement;
56 import org.apache.maven.api.model.Reporting;
57 import org.apache.maven.api.model.Profile;
58 import org.apache.maven.api.model.Activation;
59 import org.apache.maven.api.model.ActivationProperty;
60 import org.apache.maven.api.model.ActivationOS;
61 import org.apache.maven.api.model.ActivationFile;
62 import org.apache.maven.api.model.ReportPlugin;
63 import org.apache.maven.api.model.ReportSet;
64 import org.apache.maven.api.model.Prerequisites;
65 import org.apache.maven.api.model.Relocation;
66 import org.apache.maven.api.model.Extension;
67 import org.apache.maven.api.model.InputLocation;
68 import org.apache.maven.api.model.InputSource;
69
70 @Generated
71 public class MavenModelVersion {
72
73 public String getModelVersion(Model model) {
74 Objects.requireNonNull(model, "model cannot be null");
75
76
77 if (is_4_1_0(model)) {
78 return "4.1.0";
79 }
80 return "4.0.0";
81 }
82
83 private boolean is_4_1_0(Plugin plugin) {
84 return plugin != null && (
85 plugin.getExecutions().stream().anyMatch(this::is_4_1_0)
86 );
87 }
88 private boolean is_4_1_0(Model model) {
89 return model != null && (
90 is_4_1_0((ModelBase) model)
91 || has(model.isRoot())
92 || has(model.isPreserveModelVersion())
93 || model.getProfiles().stream().anyMatch(this::is_4_1_0)
94 || is_4_1_0(model.getBuild())
95 );
96 }
97 private boolean is_4_1_0(PluginConfiguration pluginConfiguration) {
98 return pluginConfiguration != null && (
99 is_4_1_0((PluginContainer) pluginConfiguration)
100 || is_4_1_0(pluginConfiguration.getPluginManagement())
101 );
102 }
103 private boolean is_4_1_0(ModelBase modelBase) {
104 return modelBase != null && (
105 !modelBase.getSubprojects().isEmpty()
106 );
107 }
108 private boolean is_4_1_0(Activation activation) {
109 return activation != null && (
110 has(activation.getPackaging())
111 );
112 }
113 private boolean is_4_1_0(Profile profile) {
114 return profile != null && (
115 is_4_1_0((ModelBase) profile)
116 || is_4_1_0(profile.getActivation())
117 || is_4_1_0(profile.getBuild())
118 );
119 }
120 private boolean is_4_1_0(PluginExecution pluginExecution) {
121 return pluginExecution != null && (
122 has(pluginExecution.getPriority())
123 );
124 }
125 private boolean is_4_1_0(Extension extension) {
126 return extension != null && (
127 has(extension.getConfiguration())
128 );
129 }
130 private boolean is_4_1_0(PluginContainer pluginContainer) {
131 return pluginContainer != null && (
132 pluginContainer.getPlugins().stream().anyMatch(this::is_4_1_0)
133 );
134 }
135 private boolean is_4_1_0(PluginManagement pluginManagement) {
136 return pluginManagement != null && (
137 is_4_1_0((PluginContainer) pluginManagement)
138 );
139 }
140 private boolean is_4_1_0(Build build) {
141 return build != null && (
142 is_4_1_0((BuildBase) build)
143 || build.getExtensions().stream().anyMatch(this::is_4_1_0)
144 );
145 }
146 private boolean is_4_1_0(BuildBase buildBase) {
147 return buildBase != null && (
148 is_4_1_0((PluginConfiguration) buildBase)
149 );
150 }
151
152 private boolean has(String str) {
153 return str != null;
154 }
155
156 private boolean has(Path path) {
157 return path != null;
158 }
159
160 private boolean has(boolean bool) {
161 return bool;
162 }
163
164 private boolean has(int val) {
165 return val != 0;
166 }
167
168 private boolean has(List<?> list) {
169 return !list.isEmpty();
170 }
171
172 private boolean has(XmlNode node) {
173 return node != null;
174 }
175
176 }