Skip to content

Commit 91ae67b

Browse files
committed
Fail build when run with unsupported Gradle version
- Test more gradle versions, including minimum supported - Fail build when run with Gradle < 5.2 - Fail build when run with Gradle 7.0 - Update README.md for Gradle compatibility
1 parent d08faa6 commit 91ae67b

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

.github/workflows/gradle.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
# Test latest version 5.x, 6.x and 7.x, as well as all patched minor versions of 8.x
34-
# Latest 8.x is tested in 'quick-check' job
35-
gradle-version: [ "5.6.4", "6.9.4", "7.6.3", "8.0.2", "8.1.1", "8.2.1", "8.3"]
33+
# Test earliest and latest supported version of 5.x, 6.x and 7.x, as well as all patched minor versions of 8.x
34+
# Latest 8.x is tested in 'quick-check' job using the wrapper
35+
gradle-version: [ "5.2.1", "5.6.4", "6.0.1", "6.9.4", "7.1.1", "7.6.3", "8.0.2", "8.1.1", "8.2.1", "8.3", "8.4", "8.5"]
3636
runs-on: ubuntu-latest
3737
env:
3838
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,23 @@ You can provide this value via the `DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS` env
5353

5454
### Gradle compatibility
5555

56-
The plugin should be compatible with all versions of Gradle >= 5.0, and has been tested against
57-
Gradle versions "5.6.4", "6.9.4", "7.0.2", "7.6.2", "8.0.2" and the current Gradle release.
58-
59-
The plugin is compatible with running Gradle with the configuration-cache enabled. However, this support is
60-
limited to Gradle "8.1.0" and later:
61-
- With Gradle "8.0", the build should run successfully, but an empty dependency graph will be generated.
62-
- With Gradle <= "7.6.4", the plugin will cause the build to fail with configuration-cache enabled.
63-
64-
To use this plugin with versions of Gradle older than "8.1.0", you'll need to invoke Gradle with the
65-
configuration-cache disabled.
56+
The plugin should be compatible with most versions of Gradle >= 5.2, and has been tested against
57+
Gradle versions "5.2.1", "5.6.4", "6.0.1", "6.9.4", "7.1.1" and "7.6.3", as well as all patched versions of Gradle 8.x.
58+
59+
The plugin is compatible with running Gradle with the configuration-cache enabled: this support is
60+
limited to Gradle "8.1.0" and later. Earlier Gradle versions will not work with `--configuration-cache`.
61+
Note that no dependency graph will be generated when configuration state is loaded from the configuration-cache.
62+
63+
| Gradle version | Compatible | Compatible with configuration-cache |
64+
| -------------- | ------- | ------------------------ |
65+
| 1.x - 4.x | :x: | :x: |
66+
| 5.0 - 5.1.1 | :x: | :x: |
67+
| 5.2 - 5.6.4 || :x: |
68+
| 6.0 - 6.9.4 || :x: |
69+
| 7.0 - 7.0.2 | :x: | :x: |
70+
| 7.1 - 7.6.3 || :x: |
71+
| 8.0 - 8.0.2 || :x: |
72+
| 8.1+ |||
6673

6774
## Building/Testing
6875

plugin-test/src/test/groovy/org/gradle/github/dependencygraph/SampleProjectDependencyExtractorTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import org.apache.commons.io.FileUtils
44
import org.gradle.util.GradleVersion
55
import spock.lang.IgnoreIf
66

7-
// Samples aren't designed to run on Gradle 5.x
8-
@IgnoreIf({ GradleVersion.version(testGradleVersion) < GradleVersion.version("6.0") })
7+
// Samples aren't designed to run on Gradle < 6.4
8+
@IgnoreIf({ GradleVersion.version(testGradleVersion) < GradleVersion.version("6.4") })
99
class SampleProjectDependencyExtractorTest extends BaseExtractorTest {
1010
def setup() {
1111
applyDependencyGraphPlugin()

plugin/src/main/kotlin/org/gradle/github/GitHubDependencyGraphPlugin.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package org.gradle.github
22

3+
import org.gradle.api.GradleException
34
import org.gradle.api.Plugin
45
import org.gradle.api.invocation.Gradle
56
import org.gradle.forceresolve.ForceDependencyResolutionPlugin
7+
import org.gradle.util.GradleVersion
68

79
/**
810
* A plugin that collects all resolved dependencies in a Gradle build for submission to the
@@ -11,6 +13,12 @@ import org.gradle.forceresolve.ForceDependencyResolutionPlugin
1113
@Suppress("unused")
1214
class GitHubDependencyGraphPlugin : Plugin<Gradle> {
1315
override fun apply(gradle: Gradle) {
16+
val gradleVersion = GradleVersion.current().baseVersion
17+
if (gradleVersion < GradleVersion.version("5.2") ||
18+
(gradleVersion >= GradleVersion.version("7.0") && gradleVersion < GradleVersion.version("7.1"))) {
19+
throw GradleException("${this.javaClass.simpleName} is not supported for $gradleVersion.")
20+
}
21+
1422
// Only apply the dependency extractor to the root build
1523
if (gradle.parent == null) {
1624
gradle.pluginManager.apply(GitHubDependencyExtractorPlugin::class.java)

0 commit comments

Comments
 (0)