
org.openscm.kundo.plugins.TestCompileDelegate.groovy Maven / Gradle / Ivy
The newest version!
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
/**
* Test Compile Delegate
* @author Ben Leedham
* @version 1.0.0
*
* Description: Delegate to compile java test files using paths from the
* kundo-dependency-management-plugin and the javac ant task
*
* The test compile delegate consumes source paths set by the kundo-project-plugin and
* dependency paths set up by the kundo-dependency-management-plugin, it also uses the
* compile.classpath set by the CompileDelegate to compile Java test classes using the
* javac ant task.
*
*/
/*
* @ant-target doTestCompile
*/
class TestCompileDelegate extends AbstractCompileDelegate {
private def log
private def ps
/**
* Constructor
* @param ant AntBuilder instance
* @param buildContext BuildContext instance
*/
TestCompileDelegate( AntBuilder ant, BuildContext buildContext ){
super( ant, buildContext)
this.log = SimpleLogger.getInstance( ant )
this.ps = File.pathSeparator
}
/**
* Implementation of abstract method from AbstractPluginTargetDelegate
* to hold assertions that all global and local properties are available to the plugin.
* This method is automatically called prior to execution.
*/
void doCheck(){
assert buildContext.get( "project.properties" ) != null
assert buildContext.get( "artifactid" ) != null
//assert ant.project.getReference( "compile.classpath" ) != null
}
/**
* Concrete implementation of the AbstractPluginTargetDelegate.execute() method
*/
void doExecute(){
def srcPaths = buildContext.get( "project.properties" )
def artifactId = buildContext.get( "artifactid" )
def outputPath = ""
srcPaths.each{ mapKey, list ->
if( mapKey.equals( "src" ) ){
list.each{ aggregatedPropertiesObject ->
outputPath += aggregatedPropertiesObject.output + ps
}
}
}
def compileClasspath = ant.project.getReference( "compile.classpath" )
ant.path( id: "test.compile.classpath" ){
if( compileClasspath != null ){
ant.path( refid: "compile.classpath" )
}else if( buildContext.isSet( "${artifactId}.extra.classpath" ) ){
ant.path( refid: "global.${artifactId}.extra.classpath" )
}
if( buildContext.isSet( "${artifactId}.test.classpath" ) ){
ant.path( refid: "global.${artifactId}.test.classpath" )
}
ant.pathelement( path: outputPath )
}
srcPaths.each{ mapKey, list ->
if( mapKey.equals( "test" ) ){
list.each{ aggregatedPropertiesObject ->
doCompile( aggregatedPropertiesObject.include,
aggregatedPropertiesObject.exclude,
aggregatedPropertiesObject.dir,
aggregatedPropertiesObject.output,
"test.compile.classpath" )
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy