buildframework/helium/sf/java/core/src/com/nokia/helium/core/ant/types/HlmFinalTargetDef.java
changeset 628 7c4a911dc066
parent 587 85df38eb4012
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5  * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:  
    14  * Description:  
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18  
       
    19 package com.nokia.helium.core.ant.types;
    18 package com.nokia.helium.core.ant.types;
    20 
    19 
       
    20 import java.util.Hashtable;
       
    21 
       
    22 import org.apache.log4j.Logger;
    21 import org.apache.tools.ant.Project;
    23 import org.apache.tools.ant.Project;
    22 import org.apache.tools.ant.Target;
    24 import org.apache.tools.ant.Target;
    23 import java.util.Hashtable;
    25 import org.apache.tools.ant.types.DataType;
    24 import org.apache.log4j.Logger;
       
    25 
    26 
       
    27 import com.nokia.helium.core.ant.PostBuildAction;
    26 
    28 
    27 /**
    29 /**
    28  * Class to execute the final target as post operation.
    30  * Class to execute the final target as post build action.
       
    31  * 
       
    32  * @ant.type name="finaltargetdef" category="Core"
    29  */
    33  */
    30 public class HlmFinalTargetDef extends HlmPostDefImpl
    34 public class HlmFinalTargetDef extends DataType implements PostBuildAction {
    31 {
       
    32     private Logger log = Logger.getLogger(HlmFinalTargetDef.class);
    35     private Logger log = Logger.getLogger(HlmFinalTargetDef.class);
    33     
    36 
    34     /**
    37     /**
    35      * This post action will execute the final target if any to be executed.
    38      * This post action will execute the final target if any to be executed.
       
    39      * 
    36      * @param prj
    40      * @param prj
    37      * @param module
    41      * @param module
    38      * @param targetNames
    42      * @param targetNames
    39      * 
    43      * 
    40      */
    44      */
    41     public void execute(Project prj, String module, String[] targetNames) {
    45     @SuppressWarnings("unchecked")
    42         String finalTargetName = prj.getProperty("hlm.target.final");
    46     public void executeOnPostBuild(Project project, String[] targetNames) {
    43         log.debug("Calling final target" + finalTargetName);
    47         String finalTargetName = project.getProperty("hlm.target.final");
       
    48         log.debug("Calling final target : " + finalTargetName);
    44         if (finalTargetName != null) {
    49         if (finalTargetName != null) {
    45             Hashtable targets = prj.getTargets();
    50             // verify the target exists.
    46             Target finalTarget = (Target)targets.get(finalTargetName);
    51             Hashtable targets = project.getTargets();
       
    52             Target finalTarget = (Target) targets.get(finalTargetName);
    47             if (finalTarget == null) {
    53             if (finalTarget == null) {
    48                 log.info("The final target : " + finalTargetName + " not available skipping");
    54                 log.info("The final target : " + finalTargetName
       
    55                         + " not available skipping");
    49                 return;
    56                 return;
    50             }
    57             }
    51             finalTarget.execute();
    58             // let's the project execute the target.
       
    59             project.executeTarget(finalTargetName);
    52         }
    60         }
    53     }
    61     }
    54 }
    62 }