Skip to content

Commit

Permalink
Gradle 6 (#356)
Browse files Browse the repository at this point in the history
* feat: upgrade wrapper to 6.9.2

* Upgraded to gradle 6 and refactored tests to use the gradleTestKit. ReleaseExtension uses Properties now.

* feat: replaced travis ci with github workflow to run tests

* feat: Replaced dynamic property handling in grovvy with fields #353 #288 #281

* feat: GitAdapter and SvnAdapter configs are now of type gradle property and have input annotations
  • Loading branch information
Hillkorn authored Jun 1, 2022
1 parent 1982629 commit 918345c
Show file tree
Hide file tree
Showing 49 changed files with 1,722 additions and 865 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
tests:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: adopt
architecture: x64

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b

- name: Build with Gradle
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
with:
arguments: check
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 3.0.0
##### Released: 13. May 2022
* Upgraded to gradle 6
* Added gradle test kit and refactored tests to use GradleRunner
* ReleaseExtension fields are gradle properties now
* gradle adapter config defaults to main instead of master branch
* Switched default branch to main

## 2.5.0
##### Released: xx. July 2016

Expand Down Expand Up @@ -67,7 +75,7 @@
### New Features

* COMMON: Possibility to use the release plugin in multiprojects where each project has its own version (#116, thanks christierney)
* see [the example](https://github.com/researchgate/gradle-release-examples/tree/master/multi-project-multiple-versions)
* see [the example](https://github.com/researchgate/gradle-release-examples/tree/main/multi-project-multiple-versions)
* GIT: Option ```pushToBranchPrefix``` can now be set to specify a remote branch prefix when committing next version (#140, #113, thanks muryoh)

### Changes
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing

## Pull Requests
1. Fork the repo and create your branch from `master`.
1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests (currently we only have tests for git or some shared functionality)
3. Ensure the test suite passes.

Expand Down
46 changes: 35 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gradle-release plugin

[![Build Status](https://travis-ci.org/researchgate/gradle-release.svg?branch=master)](https://travis-ci.org/researchgate/gradle-release)
[![Build Status](https://travis-ci.org/researchgate/gradle-release.svg?branch=main)](https://travis-ci.org/researchgate/gradle-release)
[![Download](https://api.bintray.com/packages/researchgate/gradle-plugins/gradle-release/images/download.svg)](https://bintray.com/researchgate/gradle-plugins/gradle-release/_latestVersion)
[![Gitter](https://img.shields.io/badge/chat-online-brightgreen.svg?style=flat)](https://gitter.im/researchgate/gradle-release)

Expand All @@ -26,9 +26,9 @@ Current SCM support: [Bazaar](http://bazaar.canonical.com/en/), [Git](http://git

## Installation

The gradle-release plugin will work with Gradle 1.0M3 and beyond
The gradle-release plugin will work with Gradle 6.0 and beyond

### Gradle 1.x and 2.0
### Legacy plugin application

```groovy
buildscript {
Expand All @@ -38,18 +38,18 @@ buildscript {
}
}
dependencies {
classpath 'net.researchgate:gradle-release:2.8.1'
classpath 'net.researchgate:gradle-release:3.0.0'
}
}
apply plugin: 'net.researchgate.release'
```

### Gradle 2.1 and higher
### Plugin DSL

```groovy
plugins {
id 'net.researchgate.release' version '2.8.1'
id 'net.researchgate.release' version '3.0.0'
}
```

Expand Down Expand Up @@ -160,8 +160,8 @@ Below are some properties of the Release Plugin Convention that are specific to
<tr>
<td>Git</td>
<td>requireBranch</td>
<td>master</td>
<td>Defines the branch which releases must be done off of. Eg. set to `release` to require releases are done on the `release` branch (or use a regular expression to allow releases from multiple branches, e.g. `/release|master/`). Set to '' to ignore.</td>
<td>main</td>
<td>Defines the branch which releases must be done off of. Eg. set to `release` to require releases are done on the `release` branch (or use a regular expression to allow releases from multiple branches, e.g. `/release|main/`). Set to '' to ignore.</td>
</tr>
<tr>
<td>Git</td>
Expand Down Expand Up @@ -195,7 +195,7 @@ release {

This are all possible configuration options and its default values:

```
``` build.gradle
release {
failOnCommitNeeded = true
failOnPublishNeeded = true
Expand All @@ -216,7 +216,7 @@ release {
versionPatterns = [
/(\d+)([^\d]*$)/: { Matcher m, Project p -> m.replaceAll("${(m[0][1] as int) + 1}${m[0][2]}") }
]
pushReleaseVersionBranch = false
pushReleaseVersionBranch = null
scmAdapters = [
net.researchgate.release.GitAdapter,
net.researchgate.release.SvnAdapter,
Expand All @@ -225,7 +225,7 @@ release {
]
git {
requireBranch = 'master'
requireBranch = 'main'
pushToRemote = 'origin'
pushToBranchPrefix = ''
commitVersionFileOnly = false
Expand All @@ -240,6 +240,30 @@ release {
}
```

### Kotlin DSL Example

``` build.gradle.kts
import net.researchgate.release.ReleaseExtension
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'net.researchgate:gradle-release:3.0.0'
}

apply(plugin = "base")
apply(plugin = "net.researchgate.release")

configure<ReleaseExtension> {
ignoredSnapshotDependencies.set(listOf("net.researchgate:gradle-release"))
with(git) {
requireBranch = "master"
}
}
```

### Custom release steps

To add a step to the release process is very easy. Gradle provides a very nice mechanism for [manipulating existing tasks](http://gradle.org/docs/current/userguide/tutorial_using_tasks.html#N102B2). There are two available hooks provided: `beforeReleaseBuild` which runs before build and `afterReleaseBuild` which runs afterwards.
Expand Down
98 changes: 34 additions & 64 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,92 +1,62 @@
buildscript {
repositories {
jcenter {
url "https://jcenter.bintray.com"
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.3.0'
classpath 'nu.studer:gradle-plugindev-plugin:1.0.4'
classpath 'nu.studer:gradle-plugindev-plugin:4.1'
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.4.6'
classpath 'net.researchgate:gradle-release:2.6.0'
classpath 'net.researchgate:gradle-release:2.7.0'
}
}

apply plugin: 'groovy'
plugins {
id 'org.gradle.java-gradle-plugin'
id 'org.gradle.groovy'
id 'maven-publish'
id 'net.researchgate.release' version '2.7.0'
id "com.jfrog.bintray" version "1.8.4"
}

apply plugin: 'idea'
apply plugin: 'nu.studer.plugindev'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'net.researchgate.release'

group='net.researchgate'

dependencies {
testCompile("org.spockframework:spock-core:$spockVersion") { exclude group: 'org.codehaus.groovy' }
testCompile "junit:junit:$junitVersion"
testCompile "org.eclipse.jgit:org.eclipse.jgit:$jgitVersion"
testCompile "cglib:cglib-nodep:$cglibVersion"
repositories {
mavenCentral()
}

plugindev {
pluginImplementationClass 'net.researchgate.release.ReleasePlugin'
pluginDescription 'gradle-release is a plugin for providing a Maven-like release process to project using Gradle.'
pluginLicenses 'MIT'
pluginTags 'gradle', 'plugin', 'release'
authorId 'hillkorn'
authorName 'Dennis Schumann'
authorEmail '[email protected]'
projectUrl 'https://github.com/researchgate/gradle-release'
projectInceptionYear '2011'
done() // do not omit this
dependencies {
testCompile("org.spockframework:spock-core:2.1-groovy-2.5") { exclude group: 'org.codehaus.groovy' }
testCompile "org.eclipse.jgit:org.eclipse.jgit:5.0.3.201809091024-r"
testCompile "cglib:cglib-nodep:3.2.8"
testImplementation gradleTestKit()
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
}

release {
git {
requireBranch = '(master|\\d+\\.\\d+)'
gradlePlugin {
plugins {
releasePlugin {
id = 'net.researchgate.release'
implementationClass = 'net.researchgate.release.ReleasePlugin'
}
}
}

bintray {
user = project.hasProperty('bintrayUser') ? bintrayUser : ''
key = project.hasProperty('bintrayApiKey') ? bintrayApiKey : ''
pkg {
repo = 'gradle-plugins'
userOrg = 'researchgate'
version {
gpg {
sign = false
}
mavenCentralSync {
sync = false
user = project.hasProperty('sonatypeUser') ? sonatypeUser : ''
password = project.hasProperty('sonatypePassword') ? sonatypePassword : ''
}
}
}
publish = false
tasks.withType(Test).configureEach {
dependsOn tasks.jar
useJUnitPlatform()
systemProperties.put('currentVersion', project.version)
}

artifactory {
contextUrl = 'https://oss.jfrog.org'
publish {
repository {
repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
username = project.hasProperty('bintrayUser') ? bintrayUser : ''
password = project.hasProperty('bintrayApiKey') ? bintrayApiKey : ''
}
defaults {
publications 'plugin' // That is how it is named in plugindev plugin
properties = ['bintray.repo': 'gradle-plugins', 'bintray.package': 'gradle-release', 'bintray.version': version.toString()]
}
}
resolve {
repoKey = 'jcenter'
release {
git {
requireBranch = '(master|\\d+\\.\\d+)'
}
}

afterReleaseBuild.dependsOn bintrayUpload

wrapper.gradleVersion = '1.12'
wrapper.gradleVersion = '6.9.2'

updateVersion.doFirst {
def file = file('README.md')
Expand Down
7 changes: 1 addition & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
version=2.8.2-SNAPSHOT
# Dependency versions
spockVersion=0.7-groovy-1.8
jgitVersion=3.7.1.201504261725-r
junitVersion=4.12
cglibVersion=3.2.0
version=3.0.0-SNAPSHOT
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Feb 04 07:48:37 CET 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip
distributionSha256Sum=8bde5c859a3ddf5d127ac77465fc24fa8a831d3d8d49e8248548f2cb87485ef1
Loading

0 comments on commit 918345c

Please sign in to comment.