Skip to content

Commit 268d2fb

Browse files
authored
Merge pull request #78 from rspieldenner/extra_lifecycle_hooks
Extra lifecycle hooks
2 parents 91f60be + 52696ea commit 268d2fb

File tree

5 files changed

+79
-14
lines changed

5 files changed

+79
-14
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
5.0.0 / 2017-04-19
2+
==================
3+
4+
* Add some tasks and rework task ordering
5+
* BREAKING: `snapshot`, `devSnapshot`, `candidate`, `final` are no longer finalized by release, they now depend on `release`
6+
* Added `snapshotSetup`, `devSnapshotSetup`, `candidateSetup`, `finalSetup` added if you need to run specific things early in the process
7+
* Added `postRelease` task for tasks you want to happen after release (which tags the repo), we have moved publishing to be called by this step
8+
19
4.2.0 / 2017-03-31
210
==================
311

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,39 @@ The plugin assumes Git root is in the same location as Gradle root. If this isn'
128128

129129
./gradlew -Pgit.root=<git root path> final
130130

131+
# Lifecycle Hooks
132+
133+
### For `devSnapshot`
134+
135+
* `devSnapshotSetup` - any kind of setup is good to live around here, e.g. setting status, various checks
136+
* `release` - probably have `release` dependOn any `assemble` and `check` tasks, dependsOn `devSnapshotSetup`
137+
* `postRelease` - any steps you want to happen after the repo tag, in our case this is where publishing happens since if the publish partially fails we don't want to fix the tags, dependsOn `release`
138+
* `devSnapshot` - command line task to kick off devSnapshot workflow, dependsOn `postRelease`
139+
140+
### For `snapshot`
141+
142+
* `snapshotSetup` - any kind of setup is good to live around here, e.g. setting status, various checks
143+
* `release` - probably have `release` dependOn any `assemble` and `check` tasks, dependsOn `snapshotSetup`
144+
* `postRelease` - any steps you want to happen after the repo tag, in our case this is where publishing happens since if the publish partially fails we don't want to fix the tags, dependsOn `release`
145+
* `snapshot` - command line task to kick off snapshot workflow, dependsOn `postRelease`
146+
147+
### For `candidate`
148+
149+
* `candidateSetup` - any kind of setup is good to live around here, e.g. setting status, various checks
150+
* `release` - this is where the tag is pushed to the repo, so probably have `release` dependOn any `assemble` and `check` tasks, dependsOn `candidateSetup`
151+
* `postRelease` - any steps you want to happen after the repo tag, in our case this is where publishing happens since if the publish partially fails we don't want to fix the tags, dependsOn `release`
152+
* `candidate` - command line task to kick off devSnapshot workflow, dependsOn `postRelease`
153+
154+
### For `final`
155+
156+
* `finalSetup` - any kind of setup is good to live around here, e.g. setting status, various checks
157+
* `release` - this is where the tag is pushed to the repo, so probably have `release` dependOn any `assemble` and `check` tasks, dependsOn `finalSetup`
158+
* `postRelease` - any steps you want to happen after the repo tag, in our case this is where publishing happens since if the publish partially fails we don't want to fix the tags, dependsOn `release`
159+
* `final` - command line task to kick off devSnapshot workflow, dependsOn `postRelease`
160+
161+
Gradle and Java Compatibility
162+
=============================
163+
131164
Built with Oracle JDK7
132165
Tested with Oracle JDK8
133166

@@ -136,6 +169,7 @@ Tested with Oracle JDK8
136169
| 2.13 | yes |
137170
| 3.3 | yes |
138171
| 3.4.1 | yes |
172+
| 3.5 | yes |
139173

140174
LICENSE
141175
=======

gradle/wrapper/gradle-wrapper.jar

571 Bytes
Binary file not shown.
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Mar 30 11:37:52 PDT 2017
1+
#Wed Apr 19 13:06:32 PDT 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip

src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy

+35-12
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ class ReleasePlugin implements Plugin<Project> {
4242
static Logger logger = Logging.getLogger(ReleasePlugin)
4343

4444
static final String SNAPSHOT_TASK_NAME = 'snapshot'
45+
static final String SNAPSHOT_SETUP_TASK_NAME = 'snapshotSetup'
4546
static final String DEV_SNAPSHOT_TASK_NAME = 'devSnapshot'
47+
static final String DEV_SNAPSHOT_SETUP_TASK_NAME = 'devSnapshotSetup'
4648
static final String CANDIDATE_TASK_NAME = 'candidate'
49+
static final String CANDIDATE_SETUP_TASK_NAME = 'candidateSetup'
4750
static final String FINAL_TASK_NAME = 'final'
51+
static final String FINAL_SETUP_TASK_NAME = 'finalSetup'
4852
static final String RELEASE_CHECK_TASK_NAME = 'releaseCheck'
4953
static final String NEBULA_RELEASE_EXTENSION_NAME = 'nebulaRelease'
54+
static final String POST_RELEASE_TASK_NAME = 'postRelease'
5055
static final String GROUP = 'Nebula Release'
5156

5257
@Override
@@ -113,23 +118,40 @@ class ReleasePlugin implements Plugin<Project> {
113118
releaseCheck.grgit = releaseExtension.grgit
114119
releaseCheck.patterns = nebulaReleaseExtension
115120

116-
def snapshotTask = project.task(SNAPSHOT_TASK_NAME)
117-
def devSnapshotTask = project.task(DEV_SNAPSHOT_TASK_NAME)
118-
def candidateTask = project.task(CANDIDATE_TASK_NAME)
119-
candidateTask.doLast {
121+
def postReleaseTask = project.task(POST_RELEASE_TASK_NAME)
122+
postReleaseTask.group = GROUP
123+
postReleaseTask.dependsOn project.tasks.release
124+
125+
def snapshotSetupTask = project.task(SNAPSHOT_SETUP_TASK_NAME)
126+
def devSnapshotSetupTask = project.task(DEV_SNAPSHOT_SETUP_TASK_NAME)
127+
def candidateSetupTask = project.task(CANDIDATE_SETUP_TASK_NAME)
128+
candidateSetupTask.doLast {
120129
project.allprojects.each { it.status = 'candidate' }
121130
}
122-
def finalTask = project.task(FINAL_TASK_NAME)
123-
finalTask.doLast {
131+
def finalSetupTask = project.task(FINAL_SETUP_TASK_NAME)
132+
finalSetupTask.doLast {
124133
project.allprojects.each { it.status = 'release' }
125134
}
126135

127-
[snapshotTask, devSnapshotTask, candidateTask, finalTask].each {
136+
[snapshotSetupTask, devSnapshotSetupTask, candidateSetupTask, finalSetupTask].each {
128137
it.group = GROUP
129-
it.finalizedBy project.tasks.release
130138
it.dependsOn releaseCheck
131139
}
132140

141+
def snapshotTask = project.task(SNAPSHOT_TASK_NAME)
142+
snapshotTask.dependsOn snapshotSetupTask
143+
def devSnapshotTask = project.task(DEV_SNAPSHOT_TASK_NAME)
144+
devSnapshotTask.dependsOn devSnapshotSetupTask
145+
def candidateTask = project.task(CANDIDATE_TASK_NAME)
146+
candidateTask.dependsOn candidateSetupTask
147+
def finalTask = project.task(FINAL_TASK_NAME)
148+
finalTask.dependsOn finalSetupTask
149+
150+
[snapshotTask, devSnapshotTask, candidateTask, finalTask].each {
151+
it.group = GROUP
152+
it.dependsOn postReleaseTask
153+
}
154+
133155
def cliTasks = project.gradle.startParameter.taskNames
134156
determineStage(cliTasks, releaseCheck)
135157
checkStateForStage()
@@ -148,6 +170,7 @@ class ReleasePlugin implements Plugin<Project> {
148170
}
149171
}
150172

173+
configurePublishingIfPresent()
151174
configureBintrayTasksIfPresent()
152175
}
153176

@@ -208,13 +231,13 @@ class ReleasePlugin implements Plugin<Project> {
208231
void configurePublishingIfPresent() {
209232
project.plugins.withType(MavenPublishPlugin) {
210233
project.tasks.withType(GenerateMavenPom) { task ->
211-
project.rootProject.tasks.release.dependsOn(task)
234+
project.rootProject.tasks.postRelease.dependsOn(task)
212235
}
213236
}
214237

215238
project.plugins.withType(IvyPublishPlugin) {
216239
project.tasks.withType(GenerateIvyDescriptor) { task ->
217-
project.rootProject.tasks.release.dependsOn(task)
240+
project.rootProject.tasks.postRelease.dependsOn(task)
218241
}
219242
}
220243
}
@@ -225,7 +248,7 @@ class ReleasePlugin implements Plugin<Project> {
225248
project.plugins.withType(JavaPlugin) {
226249
task.dependsOn(project.tasks.build)
227250
}
228-
project.rootProject.tasks.release.dependsOn(task)
251+
project.rootProject.tasks.postRelease.dependsOn(task)
229252
}
230253
} else {
231254
logger.info('Skipping configuration of bintray task since it is not present')
@@ -236,7 +259,7 @@ class ReleasePlugin implements Plugin<Project> {
236259
project.plugins.withType(JavaPlugin) {
237260
task.dependsOn(project.tasks.build)
238261
}
239-
project.rootProject.tasks.release.dependsOn(task)
262+
project.rootProject.tasks.postRelease.dependsOn(task)
240263
}
241264
} else {
242265
logger.info('Skipping configuration of artifactoryPublish task since it is not present')

0 commit comments

Comments
 (0)