Skip to content

Commit 918345c

Browse files
authored
Gradle 6 (#356)
* 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
1 parent 1982629 commit 918345c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1722
-865
lines changed

.github/workflows/tests.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
17+
- name: Set up JDK 11
18+
uses: actions/setup-java@v3
19+
with:
20+
java-version: 11
21+
distribution: adopt
22+
architecture: x64
23+
24+
- name: Validate Gradle wrapper
25+
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
26+
27+
- name: Build with Gradle
28+
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
29+
with:
30+
arguments: check

.travis.yml

-11
This file was deleted.

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 3.0.0
4+
##### Released: 13. May 2022
5+
* Upgraded to gradle 6
6+
* Added gradle test kit and refactored tests to use GradleRunner
7+
* ReleaseExtension fields are gradle properties now
8+
* gradle adapter config defaults to main instead of master branch
9+
* Switched default branch to main
10+
311
## 2.5.0
412
##### Released: xx. July 2016
513

@@ -67,7 +75,7 @@
6775
### New Features
6876

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

7381
### Changes

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Contributing
22

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

README.md

+35-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gradle-release plugin
22

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

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

2727
## Installation
2828

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

31-
### Gradle 1.x and 2.0
31+
### Legacy plugin application
3232

3333
```groovy
3434
buildscript {
@@ -38,18 +38,18 @@ buildscript {
3838
}
3939
}
4040
dependencies {
41-
classpath 'net.researchgate:gradle-release:2.8.1'
41+
classpath 'net.researchgate:gradle-release:3.0.0'
4242
}
4343
}
4444
4545
apply plugin: 'net.researchgate.release'
4646
```
4747

48-
### Gradle 2.1 and higher
48+
### Plugin DSL
4949

5050
```groovy
5151
plugins {
52-
id 'net.researchgate.release' version '2.8.1'
52+
id 'net.researchgate.release' version '3.0.0'
5353
}
5454
```
5555

@@ -160,8 +160,8 @@ Below are some properties of the Release Plugin Convention that are specific to
160160
<tr>
161161
<td>Git</td>
162162
<td>requireBranch</td>
163-
<td>master</td>
164-
<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>
163+
<td>main</td>
164+
<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>
165165
</tr>
166166
<tr>
167167
<td>Git</td>
@@ -195,7 +195,7 @@ release {
195195

196196
This are all possible configuration options and its default values:
197197

198-
```
198+
``` build.gradle
199199
release {
200200
failOnCommitNeeded = true
201201
failOnPublishNeeded = true
@@ -216,7 +216,7 @@ release {
216216
versionPatterns = [
217217
/(\d+)([^\d]*$)/: { Matcher m, Project p -> m.replaceAll("${(m[0][1] as int) + 1}${m[0][2]}") }
218218
]
219-
pushReleaseVersionBranch = false
219+
pushReleaseVersionBranch = null
220220
scmAdapters = [
221221
net.researchgate.release.GitAdapter,
222222
net.researchgate.release.SvnAdapter,
@@ -225,7 +225,7 @@ release {
225225
]
226226
227227
git {
228-
requireBranch = 'master'
228+
requireBranch = 'main'
229229
pushToRemote = 'origin'
230230
pushToBranchPrefix = ''
231231
commitVersionFileOnly = false
@@ -240,6 +240,30 @@ release {
240240
}
241241
```
242242

243+
### Kotlin DSL Example
244+
245+
``` build.gradle.kts
246+
import net.researchgate.release.ReleaseExtension
247+
repositories {
248+
maven {
249+
url 'https://plugins.gradle.org/m2/'
250+
}
251+
}
252+
dependencies {
253+
classpath 'net.researchgate:gradle-release:3.0.0'
254+
}
255+
256+
apply(plugin = "base")
257+
apply(plugin = "net.researchgate.release")
258+
259+
configure<ReleaseExtension> {
260+
ignoredSnapshotDependencies.set(listOf("net.researchgate:gradle-release"))
261+
with(git) {
262+
requireBranch = "master"
263+
}
264+
}
265+
```
266+
243267
### Custom release steps
244268

245269
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.

build.gradle

+34-64
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,62 @@
11
buildscript {
22
repositories {
3-
jcenter {
4-
url "https://jcenter.bintray.com"
3+
maven {
4+
url "https://plugins.gradle.org/m2/"
55
}
66
}
77
dependencies {
8-
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.3.0'
9-
classpath 'nu.studer:gradle-plugindev-plugin:1.0.4'
8+
classpath 'nu.studer:gradle-plugindev-plugin:4.1'
109
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.4.6'
11-
classpath 'net.researchgate:gradle-release:2.6.0'
10+
classpath 'net.researchgate:gradle-release:2.7.0'
1211
}
1312
}
1413

15-
apply plugin: 'groovy'
14+
plugins {
15+
id 'org.gradle.java-gradle-plugin'
16+
id 'org.gradle.groovy'
17+
id 'maven-publish'
18+
id 'net.researchgate.release' version '2.7.0'
19+
id "com.jfrog.bintray" version "1.8.4"
20+
}
21+
1622
apply plugin: 'idea'
17-
apply plugin: 'nu.studer.plugindev'
18-
apply plugin: 'com.jfrog.artifactory'
19-
apply plugin: 'net.researchgate.release'
2023

2124
group='net.researchgate'
2225

23-
dependencies {
24-
testCompile("org.spockframework:spock-core:$spockVersion") { exclude group: 'org.codehaus.groovy' }
25-
testCompile "junit:junit:$junitVersion"
26-
testCompile "org.eclipse.jgit:org.eclipse.jgit:$jgitVersion"
27-
testCompile "cglib:cglib-nodep:$cglibVersion"
26+
repositories {
27+
mavenCentral()
2828
}
2929

30-
plugindev {
31-
pluginImplementationClass 'net.researchgate.release.ReleasePlugin'
32-
pluginDescription 'gradle-release is a plugin for providing a Maven-like release process to project using Gradle.'
33-
pluginLicenses 'MIT'
34-
pluginTags 'gradle', 'plugin', 'release'
35-
authorId 'hillkorn'
36-
authorName 'Dennis Schumann'
37-
authorEmail 'dennis.schumann@researchgate.net'
38-
projectUrl 'https://github.com/researchgate/gradle-release'
39-
projectInceptionYear '2011'
40-
done() // do not omit this
30+
dependencies {
31+
testCompile("org.spockframework:spock-core:2.1-groovy-2.5") { exclude group: 'org.codehaus.groovy' }
32+
testCompile "org.eclipse.jgit:org.eclipse.jgit:5.0.3.201809091024-r"
33+
testCompile "cglib:cglib-nodep:3.2.8"
34+
testImplementation gradleTestKit()
35+
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
4136
}
4237

43-
release {
44-
git {
45-
requireBranch = '(master|\\d+\\.\\d+)'
38+
gradlePlugin {
39+
plugins {
40+
releasePlugin {
41+
id = 'net.researchgate.release'
42+
implementationClass = 'net.researchgate.release.ReleasePlugin'
43+
}
4644
}
4745
}
4846

49-
bintray {
50-
user = project.hasProperty('bintrayUser') ? bintrayUser : ''
51-
key = project.hasProperty('bintrayApiKey') ? bintrayApiKey : ''
52-
pkg {
53-
repo = 'gradle-plugins'
54-
userOrg = 'researchgate'
55-
version {
56-
gpg {
57-
sign = false
58-
}
59-
mavenCentralSync {
60-
sync = false
61-
user = project.hasProperty('sonatypeUser') ? sonatypeUser : ''
62-
password = project.hasProperty('sonatypePassword') ? sonatypePassword : ''
63-
}
64-
}
65-
}
66-
publish = false
47+
tasks.withType(Test).configureEach {
48+
dependsOn tasks.jar
49+
useJUnitPlatform()
50+
systemProperties.put('currentVersion', project.version)
6751
}
6852

69-
artifactory {
70-
contextUrl = 'https://oss.jfrog.org'
71-
publish {
72-
repository {
73-
repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
74-
username = project.hasProperty('bintrayUser') ? bintrayUser : ''
75-
password = project.hasProperty('bintrayApiKey') ? bintrayApiKey : ''
76-
}
77-
defaults {
78-
publications 'plugin' // That is how it is named in plugindev plugin
79-
properties = ['bintray.repo': 'gradle-plugins', 'bintray.package': 'gradle-release', 'bintray.version': version.toString()]
80-
}
81-
}
82-
resolve {
83-
repoKey = 'jcenter'
53+
release {
54+
git {
55+
requireBranch = '(master|\\d+\\.\\d+)'
8456
}
8557
}
8658

87-
afterReleaseBuild.dependsOn bintrayUpload
88-
89-
wrapper.gradleVersion = '1.12'
59+
wrapper.gradleVersion = '6.9.2'
9060

9161
updateVersion.doFirst {
9262
def file = file('README.md')

gradle.properties

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
version=2.8.2-SNAPSHOT
2-
# Dependency versions
3-
spockVersion=0.7-groovy-1.8
4-
jgitVersion=3.7.1.201504261725-r
5-
junitVersion=4.12
6-
cglibVersion=3.2.0
1+
version=3.0.0-SNAPSHOT

gradle/wrapper/gradle-wrapper.jar

7.99 KB
Binary file not shown.
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Feb 04 07:48:37 CET 2015
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip
6+
distributionSha256Sum=8bde5c859a3ddf5d127ac77465fc24fa8a831d3d8d49e8248548f2cb87485ef1

0 commit comments

Comments
 (0)