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