Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | /** |
| 21 | * Gradle script used to perform DM releases (really similar to Apache ACE build.xml) |
| 22 | */ |
| 23 | import aQute.bnd.build.Workspace |
| 24 | |
| 25 | // Our release number, which has to be monotonically incremented each time we make a new release. |
Pierre De Rop | bd5c018 | 2015-11-20 20:35:03 +0000 | [diff] [blame] | 26 | ext.dmRelease = "r6" |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 27 | |
| 28 | // Our Apache svn Staging repo |
| 29 | ext.svnStagingPath = "https://dist.apache.org/repos/dist/dev/felix" |
| 30 | |
| 31 | // Our Apache svn Release repo |
| 32 | ext.svnReleasePath = "https://dist.apache.org/repos/dist/release/felix" |
| 33 | |
| 34 | apply plugin: 'java' |
| 35 | apply from: file("rat.gradle") |
| 36 | |
| 37 | // Add bnd as a build dependency |
| 38 | buildscript { |
| 39 | dependencies { |
| 40 | classpath files('cnf/gradle/biz.aQute.bnd.gradle.jar') |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // Configure RAT plugin to ignore some files |
| 45 | rat { |
| 46 | excludes = [ |
| 47 | 'rat-report.xml', |
| 48 | '**/.git/**', |
| 49 | '**/.gradle/**', |
| 50 | '**/.project', |
| 51 | '**/.settings/**', |
| 52 | '**/*.iml', |
| 53 | '**/*.iws', |
| 54 | '**/*.ipr', |
| 55 | '**/.classpath', |
| 56 | 'cnf/**', |
| 57 | 'gradle/wrapper/**', |
| 58 | 'release/**', |
| 59 | 'gradlew', |
| 60 | 'README', |
| 61 | '**/DEPENDENCIES', |
| 62 | '**/README', |
| 63 | '**/.gitignore', |
| 64 | '**/generated/**', |
| 65 | 'doc/**', |
| 66 | '**/packageinfo', |
| 67 | '**/*.txt', |
| 68 | 'docs/**', |
| 69 | '.metadata/**' |
| 70 | ] |
| 71 | } |
| 72 | |
| 73 | // Setup the workspace |
| 74 | Workspace workspace |
| 75 | workspace = Workspace.getWorkspace(".") |
| 76 | |
| 77 | task makeStaging << { |
| 78 | description = 'Packages the source and binary distributions.' |
| 79 | |
| 80 | // Package source and source bin dependencies distributions. |
| 81 | logger.lifecycle(" Packaging source distributions.") |
| 82 | def topdir="org.apache.felix.dependencymanager-" + dmRelease |
| 83 | ant.zip(destfile: "staging/"+topdir+'-src.zip') { |
| 84 | zipfileset(dir: '../cnf', prefix: topdir+"-src/cnf", includes: ".project,.classpath,src/**,*.bnd,ext/**") |
| 85 | zipfileset(dir: '..', prefix: topdir+"-src", includes: '*.gradle,*.properties') |
| 86 | zipfileset(dir: 'resources/src', prefix: topdir+"-src", includes: '*') |
| 87 | new File('.').eachFile { |
| 88 | if(new File(it, 'bnd.bnd').exists()) { |
| 89 | def bndProject = workspace.getProject(it.name) |
| 90 | if (! bndProject.isNoBundles() && ! bndProject.getName().endsWith(".benchmark")) { |
| 91 | zipfileset(dir: "../${bndProject.name}", prefix: topdir+"-src/${bndProject.name}", |
| 92 | includes: "*.gradle,.project,.classpath,.settings/**,src/**,test/**,*.bnd,*.bndrun,run-*/conf/**,resources/**,README*") |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Package binary dependencies, needed to build the source distributions. |
| 99 | logger.lifecycle(" Packaging binary dependencies.") |
| 100 | ant.zip(destfile: "staging/"+topdir+"-deps.zip") { |
| 101 | ant.zipfileset(dir: '..', prefix: topdir+"-src", includes: 'gradlew') |
Pierre De Rop | af33161 | 2015-09-18 22:17:09 +0000 | [diff] [blame] | 102 | ant.zipfileset(dir: '../gradle', prefix: topdir+"-src/gradle", includes: '**') |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 103 | ant.zipfileset(dir: 'resources/deps', prefix: topdir+"-src", includes: '*') |
| 104 | ant.zipfileset(dir: '../cnf', prefix: topdir+"-src/cnf", |
| 105 | includes: 'buildrepo/**,localrepo/**,releaserepo/**,plugins/**,gradle/**') |
| 106 | } |
| 107 | |
| 108 | // Package binaries as a simple collection of bundles. We use same license files as for src distrib. |
Pierre De Rop | e822723 | 2015-12-01 20:46:10 +0000 | [diff] [blame] | 109 | logger.lifecycle(" Packaging binary distribution.") |
| 110 | |
| 111 | // First, get list of latest released bundles available from our Release repository |
| 112 | def released = [] |
| 113 | def releaseRepo = workspace.getRepository("Release") |
| 114 | logger.lifecycle("releaserepo=" + releaseRepo) |
| 115 | def bundles=releaseRepo.list(null) |
| 116 | bundles.each { |
| 117 | def sortedVersions = releaseRepo.versions(it) |
| 118 | def latestVersion = sortedVersions.last() |
| 119 | def latestBundle = releaseRepo.get(it, latestVersion, null) |
| 120 | released << latestBundle |
| 121 | } |
| 122 | |
| 123 | // Now, add all the latest released bundles in the binary distribution |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 124 | ant.zip(destfile: "staging/"+topdir+"-bin.zip") { |
Pierre De Rop | e822723 | 2015-12-01 20:46:10 +0000 | [diff] [blame] | 125 | // simply include all released bundle. |
| 126 | released.each { |
| 127 | file=it |
| 128 | ant.mappedresources() { |
| 129 | ant.filelist(files: file) |
| 130 | ant.chainedmapper() { |
| 131 | ant.flattenmapper() |
| 132 | ant.globmapper(from: '*', to: topdir+'-bin/*') |
| 133 | } |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | ant.mappedresources() { |
Pierre De Rop | e822723 | 2015-12-01 20:46:10 +0000 | [diff] [blame] | 137 | ant.fileset(dir: 'resources/bin', includes: '*') |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 138 | ant.chainedmapper() { |
| 139 | ant.flattenmapper() |
| 140 | ant.globmapper(from: '*', to: topdir+'-bin/*') |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | // Sign staging directory |
| 147 | task signStaging << { |
| 148 | description = 'Signs the local staging distribution.' |
| 149 | fileTree("staging").visit { FileVisitDetails details -> |
| 150 | logger.lifecycle(" Signing " + details.file.path) |
| 151 | ant.exec(executable: 'gpg', dir: 'staging') { |
| 152 | ant.arg(line: '--armor') |
| 153 | ant.arg(line: '--output') |
| 154 | ant.arg(line: details.file.name + ".asc") |
| 155 | ant.arg(line: "--detach-sig") |
| 156 | ant.arg(line: details.file.name) |
| 157 | } |
| 158 | |
| 159 | ant.exec(executable: 'gpg', dir: 'staging', output: "staging/" + details.file.name + ".md5") { |
| 160 | ant.arg(line: '--print-md') |
| 161 | ant.arg(line: 'MD5') |
| 162 | ant.arg(line: details.file.name) |
| 163 | } |
| 164 | |
| 165 | ant.exec(executable: 'gpg', dir: 'staging', output: "staging/" + details.file.name + ".sha") { |
| 166 | ant.arg(line: '--print-md') |
| 167 | ant.arg(line: 'SHA512') |
| 168 | ant.arg(line: details.file.name) |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | |
| 174 | // Moves the source and binary distributions to staging. |
| 175 | task commitToStaging << { |
| 176 | description = 'Commits the local staging to the Apache svn staging repository.' |
| 177 | getProject().exec { |
| 178 | commandLine 'svn', |
| 179 | 'import', 'staging', svnStagingPath + "/org.apache.felix.dependencymanager-" + dmRelease + "/", |
| 180 | '-m', "Staging Apache Felix Dependency Manager release " + dmRelease + "." |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | // Promotes the staged distributions to release |
| 185 | task promoteToRelease << { |
| 186 | description = 'Moves the staging repository to the Apache release repository.' |
Pierre De Rop | e91fae5 | 2015-03-19 06:19:16 +0000 | [diff] [blame] | 187 | |
Pierre De Rop | fdffc27 | 2015-03-19 20:57:37 +0000 | [diff] [blame] | 188 | // Move all artifacts from the staging repo to the release repo |
| 189 | new ByteArrayOutputStream().withStream { os -> |
| 190 | def result = exec { |
| 191 | executable = 'svn' |
| 192 | args = ['list', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease] |
| 193 | standardOutput = os |
| 194 | } |
| 195 | def outputAsString = os.toString() |
| 196 | |
| 197 | outputAsString.split("\n").each { artifact -> |
| 198 | logger.lifecycle(" Moving " + artifact + " to release repository ...") |
| 199 | getProject().exec { |
| 200 | commandLine 'svn', |
| 201 | 'move', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease + "/" + artifact , |
| 202 | svnReleasePath, '-m', "Releasing Apache Felix Dependency Manager release " + dmRelease + "." |
| 203 | } |
| 204 | } |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 205 | } |
Pierre De Rop | e91fae5 | 2015-03-19 06:19:16 +0000 | [diff] [blame] | 206 | |
Pierre De Rop | fdffc27 | 2015-03-19 20:57:37 +0000 | [diff] [blame] | 207 | // And remove the toplevel release path from the staging repo |
| 208 | logger.lifecycle(" Removing org.apache.felix.dependencymanager-" + dmRelease + " from staging ...") |
| 209 | getProject().exec { |
Pierre De Rop | e91fae5 | 2015-03-19 06:19:16 +0000 | [diff] [blame] | 210 | commandLine 'svn', |
| 211 | 'rm', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease, "-m", |
| 212 | "Releasing Apache Felix Dependency Manager release " + dmRelease + "." |
| 213 | } |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | // Removes the staged distributions from staging |
| 217 | task deleteFromStaging << { |
| 218 | description = 'Cancels the staged distribution from the Apache staging repository.' |
| 219 | getProject().exec { |
| 220 | commandLine 'svn', |
| 221 | 'delete', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease + "/", |
| 222 | "-m", "Removing Apache Felix Dependency Manager release " + dmRelease + " from staging." |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | // Clean staging directory |
| 227 | task clean(overwrite: true) << { |
| 228 | new File("release/staging").deleteDir() |
| 229 | new File("rat-report.xml").delete() |
| 230 | } |
| 231 | |
| 232 | // Only clean the staging directory |
| 233 | task cleanStaging << { |
| 234 | description = 'Clean the local staging directory.' |
| 235 | new File("release/staging").deleteDir() |
Pierre De Rop | e91fae5 | 2015-03-19 06:19:16 +0000 | [diff] [blame] | 236 | new File("release/staging-copy").deleteDir() |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 237 | } |