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