All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openscm.kundo.strategy.KundoModuleStrategy.groovy Maven / Gradle / Ivy

The newest version!
package org.openscm.kundo.strategy

/*
 * Copyright (C) 2008 The Ultimate People Company Ltd ("UPCO").
 *
 * 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.
 */

import org.openscm.kundo.plugins.Module

/**
 * Kundo Module Strategy
 * @author Ben Leedham
 * @version 1.0.0
 * 
 * Description: The Kundo Module Strategy loads a list of modules based from the current project's recipe.groovy file. 
 * 
 * 

The Kundo Module Strategy creates a list of modules based on the profile and modules section. * the recipe.groovy file generally exists in the project root although the location is configurable * via a custom build.xml file. * The targets specified on the command line will be propagated to each specified sub-module in the * active profile. * * The default profile is always loaded, additional profiles can be loaded using the reactor.profiles property.

*/ /* * @ant-target doReactor */ public class KundoModuleStrategy extends ModuleStrategy { /** * Constructor passes the ant instance in a call to super * @param ant AntBuilder instance */ KundoModuleStrategy( ant ) { super( ant ) } /** * Concrete implementation of the ModuleStrategy.loadModules() method * * Loads a list of modules based upon the projects recipe.groovy file. */ void loadModules( buildContext, childBuildFile, childTarget , inheritConfiguration, profiles ) { // if( childTarget.equals("install") && isDeployEnabled( defaultTarget ) ){ // log.info( message:'Ignoring reactor install target - this will be executed via deploy target dependency.') // return; // } // Get the recipe hierarchhy from the ant project, we are only interested in the current project and no parents. def recipe = buildContext.get( "recipe.hierarchy" ) def profileList = recipe.getProfileList() def moduleList profileList.each{ profile -> if( profile.getName() == "default" ){ moduleList = profile.getModuleLocationList() } } // Closure to build a module from the project module element def addModule = { m -> log.debug( "Creating module with params $m" ) def Module module = new Module() module.name = m module.buildFile = childBuildFile module.dir = m module.target = childTarget module.inheritConfiguration = inheritConfiguration modules.add(module) } // Check for any top level modules and process accordingly moduleList.each{ m -> addModule( m ) } // For each of the profiles in the passed list.. profiles.each { pf-> // Find the matching profile inside the project def pfile = profileList.find{ it.getName().equals( pf ) } log.debug( "Identified profiles $pfile to load modules from." ) // Check that something was found if(pfile != null) { // For each of the modules inside that profile pfile.getModuleLocationList().each{ m-> // Add to the profile list. addModule( m ) } } } } /** * Checks to see if deploy is enabled as to whether processing should occur later. * @parm defaultTarget Target to be executed * @return boolean true if deploy is enabled. */ def boolean isDeployEnabled( defaultTarget ){ return defaultTarget.equals( "deploy" ) } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy