blob: 921dbf81ecae698eb270ea91173f33d73366e3c6 [file] [log] [blame]
Pierre De Rop3a00a212015-03-01 09:27:46 +00001/*
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 */
23import aQute.bnd.build.Workspace
24
25// Our release number, which has to be monotonically incremented each time we make a new release.
Pierre De Rop5b849c82015-06-05 20:26:18 +000026ext.dmRelease = "r5"
Pierre De Rop3a00a212015-03-01 09:27:46 +000027
28// Our Apache svn Staging repo
29ext.svnStagingPath = "https://dist.apache.org/repos/dist/dev/felix"
30
31// Our Apache svn Release repo
32ext.svnReleasePath = "https://dist.apache.org/repos/dist/release/felix"
33
34apply plugin: 'java'
35apply from: file("rat.gradle")
36
37// Add bnd as a build dependency
38buildscript {
39 dependencies {
40 classpath files('cnf/gradle/biz.aQute.bnd.gradle.jar')
41 }
42}
43
44// Configure RAT plugin to ignore some files
45rat {
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
74Workspace workspace
75workspace = Workspace.getWorkspace(".")
76
77task 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')
102 ant.zipfileset(dir: '../gradle', prefix: topdir+"-src/gradle", includes: '*')
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.
109 logger.lifecycle(" Packaging binary distribution.")
110 ant.zip(destfile: "staging/"+topdir+"-bin.zip") {
111 ant.mappedresources() {
Pierre De Rop6501bac2015-06-11 22:41:04 +0000112 // simply include all released bundle.
113 ant.fileset(dir: '..', includes: 'cnf/releaserepo/*/*.jar')
Pierre De Rop3a00a212015-03-01 09:27:46 +0000114 ant.chainedmapper() {
115 ant.flattenmapper()
116 ant.globmapper(from: '*', to: topdir+'-bin/*')
117 }
118 }
119 ant.mappedresources() {
120 ant.fileset(dir: 'resources/bin', includes: '*')
121 ant.chainedmapper() {
122 ant.flattenmapper()
123 ant.globmapper(from: '*', to: topdir+'-bin/*')
124 }
125 }
126 }
127}
128
129// Sign staging directory
130task signStaging << {
131 description = 'Signs the local staging distribution.'
132 fileTree("staging").visit { FileVisitDetails details ->
133 logger.lifecycle(" Signing " + details.file.path)
134 ant.exec(executable: 'gpg', dir: 'staging') {
135 ant.arg(line: '--armor')
136 ant.arg(line: '--output')
137 ant.arg(line: details.file.name + ".asc")
138 ant.arg(line: "--detach-sig")
139 ant.arg(line: details.file.name)
140 }
141
142 ant.exec(executable: 'gpg', dir: 'staging', output: "staging/" + details.file.name + ".md5") {
143 ant.arg(line: '--print-md')
144 ant.arg(line: 'MD5')
145 ant.arg(line: details.file.name)
146 }
147
148 ant.exec(executable: 'gpg', dir: 'staging', output: "staging/" + details.file.name + ".sha") {
149 ant.arg(line: '--print-md')
150 ant.arg(line: 'SHA512')
151 ant.arg(line: details.file.name)
152 }
153 }
154}
155
156
157// Moves the source and binary distributions to staging.
158task commitToStaging << {
159 description = 'Commits the local staging to the Apache svn staging repository.'
160 getProject().exec {
161 commandLine 'svn',
162 'import', 'staging', svnStagingPath + "/org.apache.felix.dependencymanager-" + dmRelease + "/",
163 '-m', "Staging Apache Felix Dependency Manager release " + dmRelease + "."
164 }
165}
166
167// Promotes the staged distributions to release
168task promoteToRelease << {
169 description = 'Moves the staging repository to the Apache release repository.'
Pierre De Rope91fae52015-03-19 06:19:16 +0000170
Pierre De Ropfdffc272015-03-19 20:57:37 +0000171 // Move all artifacts from the staging repo to the release repo
172 new ByteArrayOutputStream().withStream { os ->
173 def result = exec {
174 executable = 'svn'
175 args = ['list', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease]
176 standardOutput = os
177 }
178 def outputAsString = os.toString()
179
180 outputAsString.split("\n").each { artifact ->
181 logger.lifecycle(" Moving " + artifact + " to release repository ...")
182 getProject().exec {
183 commandLine 'svn',
184 'move', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease + "/" + artifact ,
185 svnReleasePath, '-m', "Releasing Apache Felix Dependency Manager release " + dmRelease + "."
186 }
187 }
Pierre De Rop3a00a212015-03-01 09:27:46 +0000188 }
Pierre De Rope91fae52015-03-19 06:19:16 +0000189
Pierre De Ropfdffc272015-03-19 20:57:37 +0000190 // And remove the toplevel release path from the staging repo
191 logger.lifecycle(" Removing org.apache.felix.dependencymanager-" + dmRelease + " from staging ...")
192 getProject().exec {
Pierre De Rope91fae52015-03-19 06:19:16 +0000193 commandLine 'svn',
194 'rm', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease, "-m",
195 "Releasing Apache Felix Dependency Manager release " + dmRelease + "."
196 }
Pierre De Rop3a00a212015-03-01 09:27:46 +0000197}
198
199// Removes the staged distributions from staging
200task deleteFromStaging << {
201 description = 'Cancels the staged distribution from the Apache staging repository.'
202 getProject().exec {
203 commandLine 'svn',
204 'delete', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease + "/",
205 "-m", "Removing Apache Felix Dependency Manager release " + dmRelease + " from staging."
206 }
207}
208
209// Clean staging directory
210task clean(overwrite: true) << {
211 new File("release/staging").deleteDir()
212 new File("rat-report.xml").delete()
213}
214
215// Only clean the staging directory
216task cleanStaging << {
217 description = 'Clean the local staging directory.'
218 new File("release/staging").deleteDir()
Pierre De Rope91fae52015-03-19 06:19:16 +0000219 new File("release/staging-copy").deleteDir()
Pierre De Rop3a00a212015-03-01 09:27:46 +0000220}