
org.openscm.kundo.plugins.CompileDelegate.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
/**
* Compile Delegate
* @author Ben Leedham
* @version 1.0.0
*
* Description: Delegate to compile java files using paths from the
* kundo-dependency-management-plugin and the javac ant task
*
* The compile delegate consumes source paths set by the kundo-project-plugin and
* dependency paths set up by the kundo-dependency-management-plugin and uses them
* to compile Java classes using the javac ant task.
*
*/
/*
* @ant-target doCompile
*/
class CompileDelegate extends AbstractCompileDelegate {
private def log
private def ps
/**
* Constructor
* @param ant AntBuilder instance
* @param buildContext BuildContext instance
*/
CompileDelegate( 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
}
/**
* Concrete implementation of the AbstractPluginTargetDelegate.execute() method
*/
void doExecute(){
def srcPaths = buildContext.get( "project.properties" )
def artifactId = buildContext.get( "artifactid" )
def resourcePath = ""
srcPaths.each{ mapKey, list ->
if( mapKey.equals( "resource" ) ){
list.each{ aggregatedPropertiesObject ->
resourcePath += aggregatedPropertiesObject.dir + ps
}
}
}
ant.path( id: "compile.classpath" ){
ant.path( refid: "global.${artifactId}.compile.classpath" )
ant.path( refid: "global.${artifactId}.extra.classpath" )
ant.pathelement( path: resourcePath )
}
srcPaths.each{ mapKey, list ->
if( mapKey.equals( "src" ) ){
list.each{ aggregatedPropertiesObject ->
doCompile( aggregatedPropertiesObject.include,
aggregatedPropertiesObject.exclude,
aggregatedPropertiesObject.dir,
aggregatedPropertiesObject.output,
"compile.classpath" )
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy