1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.profiles;
20
21 import java.util.List;
22 import org.apache.maven.model.Activation;
23 import org.apache.maven.model.ActivationFile;
24 import org.apache.maven.model.ActivationProperty;
25 import org.apache.maven.model.Profile;
26 import org.apache.maven.model.Repository;
27
28
29
30
31 @Deprecated
32 public class ProfilesConversionUtils {
33 private ProfilesConversionUtils() {}
34
35 public static Profile convertFromProfileXmlProfile(org.apache.maven.profiles.Profile profileXmlProfile) {
36 Profile profile = new Profile();
37
38 profile.setId(profileXmlProfile.getId());
39
40 profile.setSource("profiles.xml");
41
42 org.apache.maven.profiles.Activation profileActivation = profileXmlProfile.getActivation();
43
44 if (profileActivation != null) {
45 Activation activation = new Activation();
46
47 activation.setActiveByDefault(profileActivation.isActiveByDefault());
48
49 activation.setJdk(profileActivation.getJdk());
50
51 org.apache.maven.profiles.ActivationProperty profileProp = profileActivation.getProperty();
52
53 if (profileProp != null) {
54 ActivationProperty prop = new ActivationProperty();
55
56 prop.setName(profileProp.getName());
57 prop.setValue(profileProp.getValue());
58
59 activation.setProperty(prop);
60 }
61
62 ActivationOS profileOs = profileActivation.getOs();
63
64 if (profileOs != null) {
65 org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS();
66
67 os.setArch(profileOs.getArch());
68 os.setFamily(profileOs.getFamily());
69 os.setName(profileOs.getName());
70 os.setVersion(profileOs.getVersion());
71
72 activation.setOs(os);
73 }
74
75 org.apache.maven.profiles.ActivationFile profileFile = profileActivation.getFile();
76
77 if (profileFile != null) {
78 ActivationFile file = new ActivationFile();
79
80 file.setExists(profileFile.getExists());
81 file.setMissing(profileFile.getMissing());
82
83 activation.setFile(file);
84 }
85
86 profile.setActivation(activation);
87 }
88
89 profile.setProperties(profileXmlProfile.getProperties());
90
91 List repos = profileXmlProfile.getRepositories();
92 if (repos != null) {
93 for (Object repo : repos) {
94 profile.addRepository(convertFromProfileXmlRepository((org.apache.maven.profiles.Repository) repo));
95 }
96 }
97
98 List pluginRepos = profileXmlProfile.getPluginRepositories();
99 if (pluginRepos != null) {
100 for (Object pluginRepo : pluginRepos) {
101 profile.addPluginRepository(
102 convertFromProfileXmlRepository((org.apache.maven.profiles.Repository) pluginRepo));
103 }
104 }
105
106 return profile;
107 }
108
109 private static Repository convertFromProfileXmlRepository(org.apache.maven.profiles.Repository profileXmlRepo) {
110 Repository repo = new Repository();
111
112 repo.setId(profileXmlRepo.getId());
113 repo.setLayout(profileXmlRepo.getLayout());
114 repo.setName(profileXmlRepo.getName());
115 repo.setUrl(profileXmlRepo.getUrl());
116
117 if (profileXmlRepo.getSnapshots() != null) {
118 repo.setSnapshots(convertRepositoryPolicy(profileXmlRepo.getSnapshots()));
119 }
120 if (profileXmlRepo.getReleases() != null) {
121 repo.setReleases(convertRepositoryPolicy(profileXmlRepo.getReleases()));
122 }
123
124 return repo;
125 }
126
127 private static org.apache.maven.model.RepositoryPolicy convertRepositoryPolicy(RepositoryPolicy profileXmlRepo) {
128 org.apache.maven.model.RepositoryPolicy policy = new org.apache.maven.model.RepositoryPolicy();
129 policy.setEnabled(profileXmlRepo.isEnabled());
130 policy.setUpdatePolicy(profileXmlRepo.getUpdatePolicy());
131 policy.setChecksumPolicy(profileXmlRepo.getChecksumPolicy());
132 return policy;
133 }
134 }