Skip to content

Commit 9518120

Browse files
committed
Migrate plugin to latest Gradle and dependencies
Makes it consistent with other authorization plugins using the same base template.
1 parent 16a6d83 commit 9518120

38 files changed

+517
-388
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
day: friday
8+
- package-ecosystem: gradle
9+
directory: "/"
10+
schedule:
11+
interval: weekly
12+
day: friday
13+
open-pull-requests-limit: 99

.github/workflows/pr_workflow.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Testing For PRs
5+
6+
on: [ pull_request ]
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Set up JDK
14+
uses: actions/setup-java@v3
15+
with:
16+
java-version: 17
17+
distribution: temurin
18+
- name: Build with Gradle
19+
run: ./gradlew assemble check

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
name: Create Stable Release
3+
4+
# Controls when the action will run. Workflow runs when manually triggered using the UI
5+
# or API.
6+
on:
7+
workflow_dispatch:
8+
# Inputs the workflow accepts.
9+
inputs:
10+
prerelease:
11+
description: 'The release should be an experimental release'
12+
default: 'NO'
13+
required: true
14+
15+
jobs:
16+
build_and_release:
17+
runs-on: ubuntu-latest
18+
env:
19+
GITHUB_USER: "gocd-contrib"
20+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
21+
PRERELEASE: "${{ github.event.inputs.prerelease }}"
22+
steps:
23+
- uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
- name: Set up JDK
27+
uses: actions/setup-java@v3
28+
with:
29+
java-version: 17
30+
distribution: temurin
31+
- name: Release
32+
run: ./gradlew githubRelease

.github/workflows/test_and_build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Test and Build
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up JDK
16+
uses: actions/setup-java@v3
17+
with:
18+
java-version: 17
19+
distribution: temurin
20+
- name: Test with Gradle
21+
run: ./gradlew assemble check
22+
previewGithubRelease:
23+
needs: test
24+
runs-on: ubuntu-latest
25+
env:
26+
GITHUB_USER: "gocd-contrib"
27+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0
32+
- name: Set up JDK
33+
uses: actions/setup-java@v3
34+
with:
35+
java-version: 17
36+
distribution: temurin
37+
- name: Test with Gradle
38+
run: ./gradlew githubRelease

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ out/
1313
!gradle-wrapper.jar
1414

1515
classes/
16+
src/main/resources-generated/
1617

1718
# osx junk
1819
.DS_Store

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
See the [GitHub releases page](https://github.com/gocd-contrib/gocd-okta-oauth-authorization-plugin/releases) for changes after version 2.0.0.
2+
13
## 2.0.0 - 2023-08-09
24

35
* Switch to the Authorization extension API version 2.0

build.gradle

Lines changed: 60 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -15,95 +15,87 @@
1515
*/
1616

1717
apply plugin: 'java'
18+
apply from: "https://raw.githubusercontent.com/gocd/gocd-plugin-gradle-task-helpers/master/helper.gradle?_=${(int) (new Date().toInstant().epochSecond / 60)}"
19+
20+
gocdPlugin {
21+
id = 'cd.go.authorization.okta'
22+
pluginVersion = '2.0.1'
23+
goCdVersion = '19.2.0'
24+
name = 'Okta oauth authorization plugin'
25+
description = 'Okta oauth authorization plugin for GoCD'
26+
vendorName = 'Svetlin Zamfirov'
27+
vendorUrl = 'https://github.com/gocd-contrib/gocd-okta-oauth-authorization-plugin'
28+
29+
githubRepo {
30+
owner = System.getenv('GITHUB_USER') ?: 'bob'
31+
repo = 'gocd-okta-oauth-authorization-plugin'
32+
token = System.getenv('GITHUB_TOKEN') ?: 'bad-token'
33+
}
1834

19-
apply from: 'plugin-common.gradle'
35+
pluginProject = project
2036

21-
project.ext.pluginVersion = '2.0.0'
22-
project.ext.fullVersion = project.distVersion ? "${project.pluginVersion}-${project.distVersion}" : project.pluginVersion
37+
prerelease = !"No".equalsIgnoreCase(System.getenv('PRERELEASE'))
38+
assetsToRelease = [project.tasks.jar]
2339

24-
version = project.fullVersion
25-
group = 'cd.go'
40+
licenseReport {
41+
excludes = [
42+
'com.squareup.okio:okio' // Seems to not be able to resolve license, not sure if POM issue or jk1-license-report issue. Maybe due to no jar?
43+
]
44+
}
45+
}
2646

27-
project.ext.pluginDesc = [
28-
id : 'cd.go.authorization.okta',
29-
version : project.fullVersion,
30-
goCdVersion: '19.2.0',
31-
name : 'Okta oauth authorization plugin',
32-
description: 'Okta oauth authorization plugin for GoCD',
33-
vendorName : 'szamfirov',
34-
vendorUrl : 'https://github.com/szamfirov/okta-oauth-authorization-plugin'
35-
]
47+
group = 'cd.go'
48+
version = gocdPlugin.fullVersion(project)
3649

3750
repositories {
38-
jcenter()
51+
mavenCentral()
3952
mavenLocal()
4053
}
4154

42-
dependencies {
43-
compileOnly group: 'cd.go.plugin', name: 'go-plugin-api', version: '23.3.0'
44-
compile group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
45-
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.8.1'
46-
47-
testCompile group: 'cd.go.plugin', name: 'go-plugin-api', version: '23.3.0'
48-
testCompile group: 'junit', name: 'junit', version: '4.12'
49-
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.2.28'
50-
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
51-
testCompile group: 'org.skyscreamer', name: 'jsonassert', version: '1.4.0'
52-
testCompile group: 'org.jsoup', name: 'jsoup', version: '1.10.2'
53-
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
55+
java {
56+
sourceCompatibility = JavaVersion.VERSION_11
57+
targetCompatibility = JavaVersion.VERSION_11
5458
}
5559

56-
processResources {
57-
from("src/main/resource-templates") {
58-
filesMatching('plugin.xml') {
59-
expand project.pluginDesc
60-
}
61-
62-
filesMatching('plugin.properties') {
63-
expand project.pluginDesc
64-
}
60+
configurations.all {
61+
resolutionStrategy.dependencySubstitution {
62+
substitute module("junit:junit") using module("io.quarkus:quarkus-junit4-mock:3.0.0.Final") because "We don't want JUnit 4; but is an unneeded transitive of mockwebserver."
6563
}
6664
}
6765

68-
tasks.withType(Jar) { jarTask ->
69-
preserveFileTimestamps = false
70-
reproducibleFileOrder = true
66+
ext {
67+
deps = [
68+
gocdPluginApi: 'cd.go.plugin:go-plugin-api:23.3.0',
69+
]
7170

72-
['MD5', 'SHA1', 'SHA-256'].each { algo ->
73-
jarTask.outputs.files("${jarTask.archivePath}.${algo}")
74-
jarTask.doLast {
75-
ant.checksum file: jarTask.archivePath, format: 'MD5SUM', algorithm: algo
76-
}
77-
}
71+
versions = project.ext.deps.collectEntries { lib, libGav -> [lib, libGav.split(':').last()] }
72+
}
7873

79-
manifest {
80-
attributes(
81-
'Go-Version': project.pluginDesc.goCdVersion,
82-
'Plugin-Revision': project.pluginDesc.version,
83-
'Implementation-Title': project.name,
84-
'Implementation-Version': project.version,
85-
'Source-Compatibility': project.sourceCompatibility,
86-
'Target-Compatibility': project.targetCompatibility
87-
)
88-
}
74+
dependencies {
75+
compileOnly project.deps.gocdPluginApi
76+
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
77+
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.11.0'
78+
79+
testImplementation project.deps.gocdPluginApi
80+
testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.4.0'
81+
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.2'
82+
testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.1'
83+
testImplementation group: 'org.jsoup', name: 'jsoup', version: '1.16.1'
84+
testImplementation group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '4.11.0'
85+
86+
testImplementation platform('org.junit:junit-bom:5.10.0')
87+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api'
88+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params'
89+
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine'
90+
testRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-launcher'
8991
}
9092

91-
sourceSets {
92-
test {
93-
java {
94-
compileClasspath += configurations.compileOnly
95-
runtimeClasspath += configurations.compileOnly
96-
}
97-
}
93+
test {
94+
useJUnitPlatform()
9895
}
9996

10097
jar {
101-
from(configurations.compile) {
98+
from(configurations.runtimeClasspath) {
10299
into "lib/"
103100
}
104-
105-
// This is useful for debugging
106-
// from(sourceSets.main.java) {
107-
// into "/"
108-
// }
109101
}

gradle/wrapper/gradle-wrapper.jar

10.3 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#Wed Jul 05 19:39:24 IST 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionSha256Sum=03ec176d388f2aa99defcadc3ac6adf8dd2bce5145a129659537c0874dea5ad1
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
5+
networkTimeout=10000
6+
validateDistributionUrl=true
47
zipStoreBase=GRADLE_USER_HOME
58
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

0 commit comments

Comments
 (0)