Skip to content

Commit

Permalink
Merge branch 'master' into feature/spring5
Browse files Browse the repository at this point in the history
  • Loading branch information
iles-2e committed May 9, 2018
2 parents 1b21b17 + a32a47c commit 3d664a3
Show file tree
Hide file tree
Showing 225 changed files with 27,051 additions and 18,771 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.1-SNAPSHOT
2.9.1-SNAPSHOT
14 changes: 1 addition & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ buildscript {
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.6.2"
classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.5.3"
classpath "org.ajoberstar:gradle-git:1.7.2"
}
Expand Down Expand Up @@ -79,19 +80,6 @@ subprojects {
group = 'io.springfox'
version = project.rootProject.version

jar {
manifest {
attributes(
'Implementation-Title': "${project.name}",
'Implementation-Version': version.toString(),
'Created-By': System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')',
'Built-With': "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}",
'Build-Time': "${new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")}",
'Built-By': System.getProperty('user.name'),
'Built-On': "${InetAddress.localHost.hostName}/${InetAddress.localHost.hostAddress}"
)
}
}
task allDeps(type: DependencyReportTask) {}

jacoco {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ class BintrayCredentials {
}

String getUsername() {
return project.hasProperty('bintrayUsername') ? project.property('bintrayUsername') : 'admin'
project.hasProperty('bintrayUsername') ?
project.property('bintrayUsername') :
System.getenv('BINTRAY_USER_NAME')
}

String getPassword() {
return project.hasProperty('bintrayPassword') ? project.property('bintrayPassword') : 'password'
project.hasProperty('bintrayApiKey') ?
project.property('bintrayApiKey') :
System.getenv('BINTRAY_PASSWORD')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BuildInfoFactory {
def isReleaseBuild = project.gradle.startParameter.taskNames.contains("release")

SemanticVersion buildVersion = versioningStrategy.buildVersion(releaseType, isReleaseBuild)
project.logger.info("current verison: ${versioningStrategy.current()}, " +
project.logger.lifecycle("[RELEASE] current verison: ${versioningStrategy.current()}, " +
"build version: $buildVersion, dryRun: $dryRun, releaseBuild: $isReleaseBuild")
new BuildInfo(
versioningStrategy.current(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ package springfox.gradlebuild.plugins
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import springfox.gradlebuild.BintrayCredentials
import springfox.gradlebuild.BuildInfo
import springfox.gradlebuild.BuildInfoFactory
import springfox.gradlebuild.tasks.*
import springfox.gradlebuild.tasks.BumpAndTagTask
import springfox.gradlebuild.tasks.CheckCleanWorkspaceTask
import springfox.gradlebuild.tasks.CheckGitBranchTask
import springfox.gradlebuild.tasks.IntermediaryTask
import springfox.gradlebuild.tasks.CheckRequiredSecretsTask
import springfox.gradlebuild.tasks.ReleaseTask
import springfox.gradlebuild.version.FileVersionStrategy
import springfox.gradlebuild.version.ReleaseType
import springfox.gradlebuild.version.VersioningStrategy
Expand All @@ -34,16 +38,16 @@ import springfox.gradlebuild.version.VersioningStrategy
* https://www.youtube.com/watch?v=Y6SVoXFsw7I ( GradleSummit2014 - Releasing With Gradle - René Groeschke)
*
*/
public class MultiProjectReleasePlugin implements Plugin<Project> {
class MultiProjectReleasePlugin implements Plugin<Project> {

ReleaseTask releaseTask
BumpAndTagTask bumpAndTagTask
CheckCleanWorkspaceTask checkCleanWorkspaceTask
SnapshotTask snapshotTask
BintrayCredentialsCheckTask credentialCheck
CheckRequiredSecretsTask credentialCheck
CheckGitBranchTask checkGitBranchTask
Task showPublishInfo
VersioningStrategy versioningStrategy
IntermediaryTask checkWorkspaceTask

@Override
void apply(Project project) {
Expand All @@ -53,107 +57,64 @@ public class MultiProjectReleasePlugin implements Plugin<Project> {
BuildInfo versioningInfo = createBuildInfo(project, versioningStrategy)
releaseTask = project.task(ReleaseTask.TASK_NAME, type: ReleaseTask)
bumpAndTagTask = project.task(BumpAndTagTask.TASK_NAME, type: BumpAndTagTask)
snapshotTask = project.task(SnapshotTask.TASK_NAME, type: SnapshotTask)
credentialCheck = project.task(BintrayCredentialsCheckTask.TASK_NAME, type: BintrayCredentialsCheckTask)
credentialCheck = project.task(CheckRequiredSecretsTask.TASK_NAME, type: CheckRequiredSecretsTask)
checkCleanWorkspaceTask = project.task(CheckCleanWorkspaceTask.TASK_NAME, type: CheckCleanWorkspaceTask)
checkGitBranchTask = project.task(CheckGitBranchTask.TASK_NAME, type: CheckGitBranchTask)
checkWorkspaceTask = project.task('checkWorkspace', type: IntermediaryTask)

showPublishInfo = project.task('showPublishInfo') {
group = 'Help'
description = 'Show project publishing information'
}

configureVersionAndPublications(project, versioningInfo)
configureVersion(project, versioningInfo)
configureGlobalTasks()
configureSnapshotTaskGraph(project)
configureReleaseTaskGraph(project)
project.tasks.showPublishInfo << {
project.logger.info "======= Project version: $project.version, $versioningInfo"
project.logger.lifecycle "[RELEASE] Project version: $project.version, $versioningInfo"
}
}

def configureGlobalTasks() {
checkWorkspaceTask.dependsOn showPublishInfo
checkWorkspaceTask.dependsOn checkCleanWorkspaceTask
checkWorkspaceTask.dependsOn credentialCheck
}

def configureSnapshotTaskGraph(Project project) {
def iSnapshotCheckTask = project.task('iSnapshotCheck', type: IntermediaryTask)
iSnapshotCheckTask.dependsOn showPublishInfo
def publishSnapshot = project.task('publishSnapshot', type: IntermediaryTask, group: "release")

publishSnapshot.dependsOn checkWorkspaceTask

project.afterEvaluate { evaluatedProject ->
def javaCheckTasks = evaluatedProject.getTasksByName('check', true)
iSnapshotCheckTask.dependsOn javaCheckTasks

evaluatedProject.subprojects.each { p ->
p.tasks.findByPath('publish').each { t ->
snapshotTask.dependsOn(t)
}
}
def artifactoryPublishTasks = evaluatedProject.getTasksByName('artifactoryPublish', true)
publishSnapshot.dependsOn javaCheckTasks
publishSnapshot.dependsOn artifactoryPublishTasks
}

snapshotTask.dependsOn iSnapshotCheckTask
snapshotTask.dependsOn checkCleanWorkspaceTask
snapshotTask.dependsOn credentialCheck
iSnapshotCheckTask.mustRunAfter checkCleanWorkspaceTask
iSnapshotCheckTask.mustRunAfter credentialCheck

}

def configureReleaseTaskGraph(Project project) {
def iPublishTask = project.task('iPublishTask', type: IntermediaryTask)
def iCheckTask = project.task('iCheckTask', type: IntermediaryTask)
def iWorkspaceTask = project.task('iWorkspaceTask', type: IntermediaryTask)
def publishTask = project.task('publishRelease', type: IntermediaryTask)

publishTask.dependsOn checkWorkspaceTask
publishTask.dependsOn checkGitBranchTask

project.afterEvaluate { evaluatedProject ->
def javaCheckTasks = evaluatedProject.getTasksByName('check', true)
iCheckTask.dependsOn javaCheckTasks

evaluatedProject.subprojects.each { p ->
p.tasks.findByPath('bintrayUpload').each { t ->
iPublishTask.dependsOn(t)
}
}
def bintrayUploadTasks = evaluatedProject.getTasksByName('bintrayUpload', true)
publishTask.dependsOn javaCheckTasks
publishTask.dependsOn bintrayUploadTasks
}

iWorkspaceTask.dependsOn checkGitBranchTask
iWorkspaceTask.dependsOn checkCleanWorkspaceTask

iCheckTask.dependsOn iWorkspaceTask
iCheckTask.dependsOn showPublishInfo

iPublishTask.dependsOn iCheckTask

bumpAndTagTask.dependsOn iPublishTask
bumpAndTagTask.dependsOn publishTask
releaseTask.dependsOn bumpAndTagTask
}

def configureVersionAndPublications(Project project, BuildInfo buildInfo) {
def configureVersion(Project project, BuildInfo buildInfo) {
project.version = "${buildInfo.buildVersion.asText()}"
project.ext.buildInfo = buildInfo

configurePublications(project, buildInfo)
}

def configurePublications(Project project, BuildInfo buildInfo) {
def isSnapshotBuild = isSnapshotBuild(project)
def type = isSnapshotBuild ? 'snapshot' : 'release'
def login = new BintrayCredentials(project)
def artifactRepoBase = 'http://oss.jfrog.org/artifactory'
def repoPrefix = 'oss'
project.ext {
bintrayCredentials = login
releaseRepos = {
//Only snapshots - bintray plugin takes care of non-snapshot releases
if (isSnapshotBuild) {
project.logger.info("Setting up maven repo for snapshot build: $buildInfo")
maven {
name 'jfrogOss'
url "${artifactRepoBase}/${repoPrefix}-${type}-local"
credentials {
username = "${login.username}"
password = "${login.password}"
}
}
}
}
}
}

static boolean isSnapshotBuild(Project project) {
project.gradle.startParameter.taskNames.contains("snapshot")
}

static def createBuildInfo(Project project, VersioningStrategy versioningStrategy) {
Expand All @@ -169,7 +130,7 @@ public class MultiProjectReleasePlugin implements Plugin<Project> {
project.hasProperty('buildNumberFormat') ? project.property('buildNumberFormat') : '-SNAPSHOT'
}

public static boolean dryRun(Project project) {
static boolean dryRun(Project project) {
project.hasProperty('dryRun') ? Boolean.valueOf(project.property('dryRun')) : false
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@
package springfox.gradlebuild.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.tasks.TaskAction
import springfox.gradlebuild.BuildInfo

class BumpAndTagTask extends DefaultTask {
private static Logger LOG = Logging.getLogger(BumpAndTagTask.class);
public static final String TASK_NAME = 'bumpAndTag'
String description = 'Bumps the version file and tags the release'
String group = 'release'

@TaskAction
void exec() {
BuildInfo buildInfo = project.rootProject.buildInfo
LOG.info("Bumping the version and tagging after release using (${buildInfo.versioningStrategy.class.simpleName})")
project.logger.lifecycle("[RELEASE] Bumping the version and tagging after release using " +
"(${buildInfo.versioningStrategy.class.simpleName})")
buildInfo.versioningStrategy.persist(project, buildInfo)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package springfox.gradlebuild.tasks
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

import static springfox.gradlebuild.plugins.MultiProjectReleasePlugin.dryRun
import static springfox.gradlebuild.plugins.MultiProjectReleasePlugin.*

class CheckCleanWorkspaceTask extends DefaultTask {
public static final String TASK_NAME = "checkCleanWorkspace"
Expand All @@ -32,7 +32,7 @@ class CheckCleanWorkspaceTask extends DefaultTask {
@TaskAction
void check() {
if (dryRun(project)) {
project.logger.warn("Would have checked the workspace is clean!")
project.logger.warn("[RELEASE] [DRYRUN] Would have checked the workspace is clean!")
return
}
def sout = new ByteArrayOutputStream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CheckGitBranchTask extends DefaultTask {
void check() {
String requiredBranch = "master"
if (dryRun(project)) {
project.logger.warn("Would have checked the branch is master!")
project.logger.warn("[RELEASE] [DRYRUN] Would have checked the branch is master!")
return
}
project.exec {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/

package springfox.gradlebuild.tasks

import com.google.common.base.Strings
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.tasks.TaskAction

class CheckRequiredSecretsTask extends DefaultTask {
public static final TASK_NAME = "checkRequiredSecrets"
String description = 'verifies credentials for bintray/github/oss-sonatype'
String group = 'release'

@TaskAction
def action() {
requiredProperty('bintrayUsername', 'BINTRAY_USER_NAME')
requiredProperty('bintrayPassword', 'BINTRAY_PASSWORD')
requiredProperty('githubToken', 'GITHUB_TOKEN')
requiredProperty('sonatypeUsername', 'SONATYPE_USER_NAME')
requiredProperty('sonatypePassword', 'SONATYPE_PASSWORD')
}

String requiredProperty(String propName, String environmentVariable) {
def value = project.hasProperty(propName) ?
project.property(propName) :
System.getenv(environmentVariable)
if (!Strings.isNullOrEmpty(value)) {
return value
}
throw new GradleException("Either gradle property: $propName or environment variable: $environmentVariable" +
" must not present!")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ReleaseTask extends DefaultTask {
def buildInfo = project.rootProject.buildInfo
LOG.info("Pushing annotated tag ${buildInfo.releaseTag}")
if (buildInfo.dryRun) {
project.logger.warn("Would have executed -> git push origin ${buildInfo.releaseTag}")
project.logger.warn("[RELEASE] [DRYRUN] Would have executed -> git push origin ${buildInfo.releaseTag}")
} else {
project.exec {
commandLine 'git', 'push', "origin", "${buildInfo.releaseTag}"
Expand Down

0 comments on commit 3d664a3

Please sign in to comment.