org.openscm.kundo.plugins.LoadDependenciesDelegate.groovy Maven / Gradle / Ivy
package org.openscm.kundo.plugins
/*
* 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.context.BuildContext
import org.openscm.kundo.common.logging.SimpleLogger
/**
* Load Dependencies Delegate
* @author Ben Leedham
* @version 1.0.0
*
* Description: Delegate to create scoped paths from the dependencies of a project
* specified in a maven pom file.
*
* The load dependencies delegate reads dependency information from a maven pom file at a location set by
* the kundo-project-plugin. Using that information it generates a separate path for each scope support by the
* Maven Ant Tasks (currently: compile,runtime,test,provided ). It the sets that path reference in the ant
* project with the name of the artifact being built suffixed with the scope and .classpath. This can then be
* retrieved at any time using the Build Context.
*
*/
/*
* @ant-target doLoadDependencies
*/
class LoadDependenciesDelegate extends AbstractDependenciesDelegate {
/**
* Constructor
* @param ant AntBuilder instance
* @param buildContext BuildContext instance
*/
LoadDependenciesDelegate( AntBuilder ant, BuildContext buildContext ){
super( ant, buildContext)
}
/**
* delegate implementation method to be called by doExecute
*
*/
void doLoadDependencies(){
def classPath
if( log.isDebugEnabled() ){
log.debug( "Entering -LoadDependenciesDelegate.doLoadDependencies( )" )
}
this.pomLocation = buildContext.get( "pom.location" )
File pomFile = new File( pomLocation )
if( pomFile.exists() ){
def artifactId = buildContext.get( "artifactid" )
SUPPORTED_SCOPES.each{ scope ->
mvn.dependencies( filesetId:"global.${artifactId}.${scope}.fileset", pathId:"global.${artifactId}.${scope}.classpath", useScope:"${scope}" ){
mvn.pom( file:pomLocation, id:"global.maven.project" )
}
if( (log.isDebugEnabled()) && ( buildContext.isSet( "${artifactId}.${scope}.classpath" ))){
classPath = buildContext.get( "${artifactId}.${scope}.classpath" )
log.debug( "-LoadDependenciesDelegate.doLoadDependencies( ) ${scope} classpath set to: ${classPath}" )
}
}
}
if( log.isDebugEnabled() ){
log.debug( "Exiting -LoadDependenciesDelegate.doLoadDependencies( )" )
}
}
/**
* Concrete implementation of the AbstractPluginTargetDelegate.execute() method
*/
void doExecute(){
doLoadDependencies()
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy