blob: 609ce5f8587ce6c7b72473b63ddefe78fde8270a [file] [log] [blame]
plugins {
id "com.github.dkorotych.gradle-maven-exec"
}
configurations {
archive
update
}
// The maven tycho build is disabled unless the 'maven' property is defined because
// maven might not be installed and we have to update the version strings in many files.
if(project.hasProperty('maven')) {
// Update version strings in manifest, feature and pom files for tycho.
task updateVersionStrings {
onlyIf { tycho.enabled }
doLast {
def manifestVersion = "${scmVersion.undecoratedVersion}.qualifier"
// Replace plugin versions
ant.replaceregexp(
match: "Bundle-Version:\\s*[\\w.-]*",
replace: "Bundle-Version: $manifestVersion") {
fileset(dir: rootDir, includes: '**/MANIFEST.MF')
}
// Replace feature versions
ant.replaceregexp(
match: "(?s)<feature(.*?)version\\s*=\\s*\"[\\w.-]*\"(.*)>",
replace: "<feature\\1version=\"$manifestVersion\"\\2>") {
fileset(dir: rootDir, includes: '**/feature.xml')
}
// Replace first occurence of version tag in poms
ant.replaceregexp(
match: "(?s)(.*?)<version>[\\w.-]*</version>(.*)",
replace: "\\1<version>$version</version>\\2") {
fileset(dir: rootDir, includes: '**/pom.xml')
}
}
}
// The 'maven' property optionally provides the path to the maven installation.
// The 'sign' property enables artifact signing.
task tycho(type: MavenExec, dependsOn: updateVersionStrings) {
def mavenPath = project.property('maven')
if(!mavenPath.empty) {
mavenDir = rootProject.file(mavenPath)
}
workingDir rootDir
goals 'clean', 'verify'
options {
define = ['build.type' : version.endsWith('SNAPSHOT') ? 'N' : 'R']
if(project.hasProperty('sign')) {
activateProfiles = ['sign']
}
}
}
task zipSite(type: Zip, dependsOn: tycho) {
archiveBaseName = project.name
archiveVersion = project.version
destinationDirectory = layout.buildDirectory
from layout.projectDirectory.dir('target/repository')
}
assemble.dependsOn zipSite
artifacts {
archive zipSite
update(layout.projectDirectory.dir('target/repository')) {
builtBy tycho
}
}
}