Files
spring-integration/gradle/bundlor.gradle
Chris Beams a600e5279b Polish @author tags
Names should be spelled out ('Chris Beams') instead of abbreviated
('cbeams')
2010-10-27 15:54:05 -04:00

92 lines
3.5 KiB
Groovy

/*
* Copyright 2002-2010 the original author or authors.
*
* 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.
*/
// -----------------------------------------------------------------------------
// Task definitions and configuration relating to the SpringSource 'bundlor'
// OSGi manifest generation utility.
//
// @author Chris Beams
// see: http://www.springsource.org/bundlor
// -----------------------------------------------------------------------------
/**
* Generate an OSGi manifest using the ant bundlor task.
*
* @author Luke Taylor
* @author Chris Beams
* @see http://static.springsource.org/s2-bundlor/1.0.x/user-guide/html/ch04s02.html
*/
task bundlor(dependsOn: compileJava) {
description = 'Generates an OSGi-compatibile MANIFEST.MF file.'
def template = new File(projectDir, 'template.mf')
def bundlorDir = new File("${project.buildDir}/bundlor")
def manifest = file("${bundlorDir}/META-INF/MANIFEST.MF")
// inform gradle what directory this task writes so that
// it can be removed when issuing `gradle cleanBundlor`
outputs.dir bundlorDir
// incremental build configuration
// if the $manifest output file already exists, the bundlor
// task will be skipped *unless* any of the following are true
// * template.mf has been changed
// * main classpath dependencies have been changed
// * main java sources for this project have been modified
outputs.files manifest
inputs.files template, project.sourceSets.main.runtimeClasspath
// tell the jar task to use bundlor manifest instead of the default
jar.manifest.from manifest
// the bundlor manifest should be evaluated as part of the jar task's
// incremental build
jar.inputs.files manifest
// configuration that will be used when creating the ant taskdef classpath
configurations { bundlorconf }
dependencies {
bundlorconf 'com.springsource.bundlor:com.springsource.bundlor.ant:1.0.0.RELEASE',
'com.springsource.bundlor:com.springsource.bundlor:1.0.0.RELEASE',
'com.springsource.bundlor:com.springsource.bundlor.blint:1.0.0.RELEASE'
}
doFirst {
ant.taskdef(resource: 'com/springsource/bundlor/ant/antlib.xml',
classpath: configurations.bundlorconf.asPath)
// the bundlor ant task writes directly to standard out
// redirect it to INFO level logging, which gradle will
// deal with gracefully
logging.captureStandardOutput(LogLevel.INFO)
// the ant task will throw unless this dir exists
if (!bundlorDir.isDirectory())
bundlorDir.mkdir()
// execute the ant task, and write out the $manifest file
ant.bundlor(inputPath: sourceSets.main.classesDir,
outputPath: bundlorDir, manifestTemplatePath: template) {
property(name: 'version', value: project.version)
property(name: 'spring.version', value: project.springVersion)
}
}
}
// ensure that the bundlor task runs prior to the jar task
jar.dependsOn bundlor