// Path: msbuild-maven-plugin/src/main/java/uk/org/raje/maven/plugin/msbuild/configuration/BuildPlatform.java
// public class BuildPlatform
// {
//     /**
//      * String constant for platform name 'Win32'
//      */
//     private static final String PLATFORM_WIN32 = "Win32";
//     /**
//      * Constant for the default platform name.
//      */
//     public static final String DEFAULT_PLATFORM = PLATFORM_WIN32;
// 
//     /**
//      * Construct a default BuildPlatform.
//      */
//     public BuildPlatform()
//     {
//         name = DEFAULT_PLATFORM;
//         configurations = new ArrayList<BuildConfiguration>( Arrays.asList( RELEASE_CONFIGURATION ) );
//     }
// 
//     /**
//      * Construct a BuildPlatform with the specified name.
//      * @param name the platform name
//      */
//     public BuildPlatform( String name )
//     {
//         this.name = name;
//         configurations = new ArrayList<BuildConfiguration>( Arrays.asList( RELEASE_CONFIGURATION ) );
//     }
// 
//     @Override
//     public String toString()
//     {
//         return name;
//     }
// 
//     @Override
//     public int hashCode()
//     {
//         return name.hashCode();
//     }
// 
//     @Override
//     public boolean equals( Object o )
//     {
//         if ( name != null && name.equals( ( ( BuildPlatform ) o ).name ) )
//         {
//             return true;
//         }
//         return false;
//     }
// 
//     /**
//      * Get the name of this platform
//      * @return the platform name
//      */
//     public String getName()
//     {
//         return name;
//     }
// 
//     /**
//      * Get the list of BuildConfiguration's for this platform
//      * @return the build configurations
//      */
//     public List<BuildConfiguration> getConfigurations()
//     {
//         if ( configurations.isEmpty() )
//         {
//             configurations.add( new BuildConfiguration() );
//         }
//         return configurations;
//     }
// 
//     /**
//      * Test if this platform is named 'Win32'
//      * @return true if this platform Win32
//      */
//     public boolean isWin32()
//     {
//         return PLATFORM_WIN32.equals( name );
//     }
// 
//     /**
//      * Check the configurations and mark one as primary.
//      * @throws MojoExecutionException if duplicate configuration names are found
//      */
//     public void identifyPrimaryConfiguration() throws MojoExecutionException
//     {
//         Set<String> configurationNames = new HashSet<String>();
//         for ( BuildConfiguration configuration : configurations )
//         {
//             if ( configurationNames.contains( configuration.getName() ) )
//             {
//                 throw new MojoExecutionException( "Duplicate configuration '" + configuration.getName()
//                         + "' for '" + getName() + "', configuration names must be unique" );
//             }
//             configurationNames.add( configuration.getName() );
//             configuration.setPrimary( false );
//         }
//         if ( configurations.contains( RELEASE_CONFIGURATION ) )
//         {
//             configurations.get( configurations.indexOf( RELEASE_CONFIGURATION ) ).setPrimary( true );
//         }
//         else if ( configurations.contains( DEBUG_CONFIGURATION ) )
//         {
//             configurations.get( configurations.indexOf( DEBUG_CONFIGURATION ) ).setPrimary( true );
//         }
//         else
//         {
//             configurations.get( 0 ).setPrimary( true );
//         }
//     }
//     
//     private static final BuildConfiguration RELEASE_CONFIGURATION = new BuildConfiguration( "Release" );
//     private static final BuildConfiguration DEBUG_CONFIGURATION = new BuildConfiguration( "Debug" );
// 
//     @Parameter
//     private String name;
//     
//     @Parameter
//     private List<BuildConfiguration> configurations;
// }


import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import uk.org.raje.maven.plugin.msbuild.configuration.BuildPlatform;
/*
 * Copyright 2013 Andrew Everitt, Andrew Heckford, Daniele Masato
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.org.raje.maven.plugin.msbuild;




/**
 * Collection of utilities used by Mojo's in the msbuild-maven-plugin.
 */
public class MojoHelper 
{
    // no instances
    private MojoHelper()
    {
    }
    
    /**
     * Validates the path to a command-line tool.
     * @param toolPath the configured tool path from the POM
     * @param toolName the name of the tool, used for logging messages
     * @param logger a Log to write messages to
     * @throws FileNotFoundException if the tool cannot be found
     */
    public static void validateToolPath( File toolPath, String toolName, Log logger ) 
            throws FileNotFoundException
    {
        logger.debug( "Validating path for " + toolName );
        
        if ( toolPath == null )
        {
            logger.error( "Missing " + toolName + " path" );
            throw new FileNotFoundException();
        }
        
        if ( !toolPath.exists() || !toolPath.isFile() )
        {
            logger.error( "Could not find " + toolName + " at " + toolPath );
            throw new FileNotFoundException( toolPath.getAbsolutePath() );
        }
        
        logger.debug( "Found " + toolName + " at " + toolPath );
    }    
        
    /**
     * Check that we have a valid set of platforms.
     * If no platforms are configured we create 1 default platform.
     * @param platforms the list of BuildPlatform's to validate
     * @return the passed in list or a new list with a default platform added
     * @throws MojoExecutionException if the configuration is invalid.
     */
// Path: msbuild-maven-plugin/src/main/java/uk/org/raje/maven/plugin/msbuild/configuration/BuildPlatform.java
// public class BuildPlatform
// {
//     /**
//      * String constant for platform name 'Win32'
//      */
//     private static final String PLATFORM_WIN32 = "Win32";
//     /**
//      * Constant for the default platform name.
//      */
//     public static final String DEFAULT_PLATFORM = PLATFORM_WIN32;
// 
//     /**
//      * Construct a default BuildPlatform.
//      */
//     public BuildPlatform()
//     {
//         name = DEFAULT_PLATFORM;
//         configurations = new ArrayList<BuildConfiguration>( Arrays.asList( RELEASE_CONFIGURATION ) );
//     }
// 
//     /**
//      * Construct a BuildPlatform with the specified name.
//      * @param name the platform name
//      */
//     public BuildPlatform( String name )
//     {
//         this.name = name;
//         configurations = new ArrayList<BuildConfiguration>( Arrays.asList( RELEASE_CONFIGURATION ) );
//     }
// 
//     @Override
//     public String toString()
//     {
//         return name;
//     }
// 
//     @Override
//     public int hashCode()
//     {
//         return name.hashCode();
//     }
// 
//     @Override
//     public boolean equals( Object o )
//     {
//         if ( name != null && name.equals( ( ( BuildPlatform ) o ).name ) )
//         {
//             return true;
//         }
//         return false;
//     }
// 
//     /**
//      * Get the name of this platform
//      * @return the platform name
//      */
//     public String getName()
//     {
//         return name;
//     }
// 
//     /**
//      * Get the list of BuildConfiguration's for this platform
//      * @return the build configurations
//      */
//     public List<BuildConfiguration> getConfigurations()
//     {
//         if ( configurations.isEmpty() )
//         {
//             configurations.add( new BuildConfiguration() );
//         }
//         return configurations;
//     }
// 
//     /**
//      * Test if this platform is named 'Win32'
//      * @return true if this platform Win32
//      */
//     public boolean isWin32()
//     {
//         return PLATFORM_WIN32.equals( name );
//     }
// 
//     /**
//      * Check the configurations and mark one as primary.
//      * @throws MojoExecutionException if duplicate configuration names are found
//      */
//     public void identifyPrimaryConfiguration() throws MojoExecutionException
//     {
//         Set<String> configurationNames = new HashSet<String>();
//         for ( BuildConfiguration configuration : configurations )
//         {
//             if ( configurationNames.contains( configuration.getName() ) )
//             {
//                 throw new MojoExecutionException( "Duplicate configuration '" + configuration.getName()
//                         + "' for '" + getName() + "', configuration names must be unique" );
//             }
//             configurationNames.add( configuration.getName() );
//             configuration.setPrimary( false );
//         }
//         if ( configurations.contains( RELEASE_CONFIGURATION ) )
//         {
//             configurations.get( configurations.indexOf( RELEASE_CONFIGURATION ) ).setPrimary( true );
//         }
//         else if ( configurations.contains( DEBUG_CONFIGURATION ) )
//         {
//             configurations.get( configurations.indexOf( DEBUG_CONFIGURATION ) ).setPrimary( true );
//         }
//         else
//         {
//             configurations.get( 0 ).setPrimary( true );
//         }
//     }
//     
//     private static final BuildConfiguration RELEASE_CONFIGURATION = new BuildConfiguration( "Release" );
//     private static final BuildConfiguration DEBUG_CONFIGURATION = new BuildConfiguration( "Debug" );
// 
//     @Parameter
//     private String name;
//     
//     @Parameter
//     private List<BuildConfiguration> configurations;
// }


// Path: msbuild-maven-plugin/src/main/java/uk/org/raje/maven/plugin/msbuild/MojoHelper.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import uk.org.raje.maven.plugin.msbuild.configuration.BuildPlatform;

/*
 * Copyright 2013 Andrew Everitt, Andrew Heckford, Daniele Masato
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.org.raje.maven.plugin.msbuild;




/**
 * Collection of utilities used by Mojo's in the msbuild-maven-plugin.
 */
public class MojoHelper 
{
    // no instances
    private MojoHelper()
    {
    }
    
    /**
     * Validates the path to a command-line tool.
     * @param toolPath the configured tool path from the POM
     * @param toolName the name of the tool, used for logging messages
     * @param logger a Log to write messages to
     * @throws FileNotFoundException if the tool cannot be found
     */
    public static void validateToolPath( File toolPath, String toolName, Log logger ) 
            throws FileNotFoundException
    {
        logger.debug( "Validating path for " + toolName );
        
        if ( toolPath == null )
        {
            logger.error( "Missing " + toolName + " path" );
            throw new FileNotFoundException();
        }
        
        if ( !toolPath.exists() || !toolPath.isFile() )
        {
            logger.error( "Could not find " + toolName + " at " + toolPath );
            throw new FileNotFoundException( toolPath.getAbsolutePath() );
        }
        
        logger.debug( "Found " + toolName + " at " + toolPath );
    }    
        
    /**
     * Check that we have a valid set of platforms.
     * If no platforms are configured we create 1 default platform.
     * @param platforms the list of BuildPlatform's to validate
     * @return the passed in list or a new list with a default platform added
     * @throws MojoExecutionException if the configuration is invalid.
     */
    public static List<BuildPlatform> validatePlatforms( List<BuildPlatform> platforms ) throws MojoExecutionException