Skip to content

Commit

Permalink
Merge pull request #78 from rspieldenner/extra_lifecycle_hooks
Browse files Browse the repository at this point in the history
Extra lifecycle hooks
  • Loading branch information
rspieldenner committed Apr 19, 2017
2 parents 91f60be + 52696ea commit 268d2fb
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,11 @@
5.0.0 / 2017-04-19
==================

* Add some tasks and rework task ordering
* BREAKING: `snapshot`, `devSnapshot`, `candidate`, `final` are no longer finalized by release, they now depend on `release`
* Added `snapshotSetup`, `devSnapshotSetup`, `candidateSetup`, `finalSetup` added if you need to run specific things early in the process
* 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

4.2.0 / 2017-03-31
==================

Expand Down
34 changes: 34 additions & 0 deletions README.md
Expand Up @@ -128,6 +128,39 @@ The plugin assumes Git root is in the same location as Gradle root. If this isn'

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

# Lifecycle Hooks

### For `devSnapshot`

* `devSnapshotSetup` - any kind of setup is good to live around here, e.g. setting status, various checks
* `release` - probably have `release` dependOn any `assemble` and `check` tasks, dependsOn `devSnapshotSetup`
* `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`
* `devSnapshot` - command line task to kick off devSnapshot workflow, dependsOn `postRelease`

### For `snapshot`

* `snapshotSetup` - any kind of setup is good to live around here, e.g. setting status, various checks
* `release` - probably have `release` dependOn any `assemble` and `check` tasks, dependsOn `snapshotSetup`
* `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`
* `snapshot` - command line task to kick off snapshot workflow, dependsOn `postRelease`

### For `candidate`

* `candidateSetup` - any kind of setup is good to live around here, e.g. setting status, various checks
* `release` - this is where the tag is pushed to the repo, so probably have `release` dependOn any `assemble` and `check` tasks, dependsOn `candidateSetup`
* `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`
* `candidate` - command line task to kick off devSnapshot workflow, dependsOn `postRelease`

### For `final`

* `finalSetup` - any kind of setup is good to live around here, e.g. setting status, various checks
* `release` - this is where the tag is pushed to the repo, so probably have `release` dependOn any `assemble` and `check` tasks, dependsOn `finalSetup`
* `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`
* `final` - command line task to kick off devSnapshot workflow, dependsOn `postRelease`

Gradle and Java Compatibility
=============================

Built with Oracle JDK7
Tested with Oracle JDK8

Expand All @@ -136,6 +169,7 @@ Tested with Oracle JDK8
| 2.13 | yes |
| 3.3 | yes |
| 3.4.1 | yes |
| 3.5 | yes |

LICENSE
=======
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Thu Mar 30 11:37:52 PDT 2017
#Wed Apr 19 13:06:32 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
47 changes: 35 additions & 12 deletions src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy
Expand Up @@ -42,11 +42,16 @@ class ReleasePlugin implements Plugin<Project> {
static Logger logger = Logging.getLogger(ReleasePlugin)

static final String SNAPSHOT_TASK_NAME = 'snapshot'
static final String SNAPSHOT_SETUP_TASK_NAME = 'snapshotSetup'
static final String DEV_SNAPSHOT_TASK_NAME = 'devSnapshot'
static final String DEV_SNAPSHOT_SETUP_TASK_NAME = 'devSnapshotSetup'
static final String CANDIDATE_TASK_NAME = 'candidate'
static final String CANDIDATE_SETUP_TASK_NAME = 'candidateSetup'
static final String FINAL_TASK_NAME = 'final'
static final String FINAL_SETUP_TASK_NAME = 'finalSetup'
static final String RELEASE_CHECK_TASK_NAME = 'releaseCheck'
static final String NEBULA_RELEASE_EXTENSION_NAME = 'nebulaRelease'
static final String POST_RELEASE_TASK_NAME = 'postRelease'
static final String GROUP = 'Nebula Release'

@Override
Expand Down Expand Up @@ -113,23 +118,40 @@ class ReleasePlugin implements Plugin<Project> {
releaseCheck.grgit = releaseExtension.grgit
releaseCheck.patterns = nebulaReleaseExtension

def snapshotTask = project.task(SNAPSHOT_TASK_NAME)
def devSnapshotTask = project.task(DEV_SNAPSHOT_TASK_NAME)
def candidateTask = project.task(CANDIDATE_TASK_NAME)
candidateTask.doLast {
def postReleaseTask = project.task(POST_RELEASE_TASK_NAME)
postReleaseTask.group = GROUP
postReleaseTask.dependsOn project.tasks.release

def snapshotSetupTask = project.task(SNAPSHOT_SETUP_TASK_NAME)
def devSnapshotSetupTask = project.task(DEV_SNAPSHOT_SETUP_TASK_NAME)
def candidateSetupTask = project.task(CANDIDATE_SETUP_TASK_NAME)
candidateSetupTask.doLast {
project.allprojects.each { it.status = 'candidate' }
}
def finalTask = project.task(FINAL_TASK_NAME)
finalTask.doLast {
def finalSetupTask = project.task(FINAL_SETUP_TASK_NAME)
finalSetupTask.doLast {
project.allprojects.each { it.status = 'release' }
}

[snapshotTask, devSnapshotTask, candidateTask, finalTask].each {
[snapshotSetupTask, devSnapshotSetupTask, candidateSetupTask, finalSetupTask].each {
it.group = GROUP
it.finalizedBy project.tasks.release
it.dependsOn releaseCheck
}

def snapshotTask = project.task(SNAPSHOT_TASK_NAME)
snapshotTask.dependsOn snapshotSetupTask
def devSnapshotTask = project.task(DEV_SNAPSHOT_TASK_NAME)
devSnapshotTask.dependsOn devSnapshotSetupTask
def candidateTask = project.task(CANDIDATE_TASK_NAME)
candidateTask.dependsOn candidateSetupTask
def finalTask = project.task(FINAL_TASK_NAME)
finalTask.dependsOn finalSetupTask

[snapshotTask, devSnapshotTask, candidateTask, finalTask].each {
it.group = GROUP
it.dependsOn postReleaseTask
}

def cliTasks = project.gradle.startParameter.taskNames
determineStage(cliTasks, releaseCheck)
checkStateForStage()
Expand All @@ -148,6 +170,7 @@ class ReleasePlugin implements Plugin<Project> {
}
}

configurePublishingIfPresent()
configureBintrayTasksIfPresent()
}

Expand Down Expand Up @@ -208,13 +231,13 @@ class ReleasePlugin implements Plugin<Project> {
void configurePublishingIfPresent() {
project.plugins.withType(MavenPublishPlugin) {
project.tasks.withType(GenerateMavenPom) { task ->
project.rootProject.tasks.release.dependsOn(task)
project.rootProject.tasks.postRelease.dependsOn(task)
}
}

project.plugins.withType(IvyPublishPlugin) {
project.tasks.withType(GenerateIvyDescriptor) { task ->
project.rootProject.tasks.release.dependsOn(task)
project.rootProject.tasks.postRelease.dependsOn(task)
}
}
}
Expand All @@ -225,7 +248,7 @@ class ReleasePlugin implements Plugin<Project> {
project.plugins.withType(JavaPlugin) {
task.dependsOn(project.tasks.build)
}
project.rootProject.tasks.release.dependsOn(task)
project.rootProject.tasks.postRelease.dependsOn(task)
}
} else {
logger.info('Skipping configuration of bintray task since it is not present')
Expand All @@ -236,7 +259,7 @@ class ReleasePlugin implements Plugin<Project> {
project.plugins.withType(JavaPlugin) {
task.dependsOn(project.tasks.build)
}
project.rootProject.tasks.release.dependsOn(task)
project.rootProject.tasks.postRelease.dependsOn(task)
}
} else {
logger.info('Skipping configuration of artifactoryPublish task since it is not present')
Expand Down

0 comments on commit 268d2fb

Please sign in to comment.