Coverage Report - org.apache.maven.toolchain.java.DefaultJavaToolChain
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultJavaToolChain
0 %
0/16
0 %
0/8
1,833
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *  http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 
 20  
 package org.apache.maven.toolchain.java;
 21  
 
 22  
 import java.io.File;
 23  
 import org.apache.maven.toolchain.DefaultToolchain;
 24  
 import org.apache.maven.toolchain.model.ToolchainModel;
 25  
 import org.codehaus.plexus.logging.Logger;
 26  
 import org.codehaus.plexus.util.FileUtils;
 27  
 import org.codehaus.plexus.util.Os;
 28  
 
 29  
 /**
 30  
  * @author Milos Kleint
 31  
  */
 32  
 public class DefaultJavaToolChain
 33  
     extends DefaultToolchain
 34  
     implements JavaToolChain
 35  
 {
 36  
 
 37  
     private String javaHome;
 38  
 
 39  
     public static final String KEY_JAVAHOME = "jdkHome"; //NOI18N
 40  
 
 41  
     public DefaultJavaToolChain( ToolchainModel model, Logger logger )
 42  
     {
 43  0
         super( model, "jdk", logger );
 44  0
     }
 45  
 
 46  
     public String getJavaHome( )
 47  
     {
 48  0
         return javaHome;
 49  
     }
 50  
 
 51  
     public void setJavaHome( String javaHome )
 52  
     {
 53  0
         this.javaHome = javaHome;
 54  0
     }
 55  
 
 56  
     public String toString( )
 57  
     {
 58  0
         return "JDK[" + getJavaHome(  ) + "]";
 59  
     }
 60  
 
 61  
     public String findTool( String toolName )
 62  
     {
 63  0
         File toRet = findTool( toolName,
 64  
             new File( FileUtils.normalize( getJavaHome(  ) ) ) );
 65  0
         if ( toRet != null )
 66  
         {
 67  0
             return toRet.getAbsolutePath(  );
 68  
         }
 69  0
         return null;
 70  
     }
 71  
 
 72  
 
 73  
     private static File findTool( String toolName, File installFolder )
 74  
     {
 75  0
         File bin = new File( installFolder, "bin" ); //NOI18N
 76  0
         if ( bin.exists(  ) )
 77  
         {
 78  0
             File tool = new File( bin,
 79  
                 toolName + (Os.isFamily( "windows" ) ? ".exe" : "") ); //NOI18N
 80  0
             if ( tool.exists(  ) )
 81  
             {
 82  0
                 return tool;
 83  
             }
 84  
         }
 85  0
         return null;
 86  
     }
 87  
 }