Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [OSM-892] added support for gradle 8 #280

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ test_matrix_unix: &test_matrix_unix
parameters:
node_version: [ '16.18', '18.18', '20.9' ]
jdk_version: [ '8.0.292.j9-adpt' ]
gradle_version: [ '4.10', '5.5', '6.2.1' ]
gradle_version: [ '4.10', '5.5', '6.2.1']

test_matrix_unix_new_versions: &test_matrix_unix_new_versions
matrix:
parameters:
node_version: [ '16.18', '18.18', '20.9' ]
jdk_version: [ '17.0.9-jbr' ]
gradle_version: [ '7.3', '8.4' ]

test_matrix_win: &test_matrix_win
matrix:
Expand All @@ -38,6 +45,13 @@ test_matrix_win: &test_matrix_win
jdk_version: [ '8' ]
gradle_version: [ '4.10', '5.5', '6.2.1' ]

test_matrix_win_new_versions: &test_matrix_win_new_versions
matrix:
parameters:
node_version: [ '16', '18', '20' ]
jdk_version: [ '17' ]
gradle_version: [ '7.3', '8.4' ]

filters_branches_only_main: &filters_branches_only_main
filters:
branches:
Expand Down Expand Up @@ -264,6 +278,14 @@ workflows:
- Lint
<<: *filters_branches_ignore_main

- test-unix:
name: Test OS=Unix Node=<<matrix.node_version>> JDK=<<matrix.jdk_version>> Gradle=<<matrix.gradle_version>>
context: nodejs-install
<<: *test_matrix_unix_new_versions
requires:
- Lint
<<: *filters_branches_ignore_main

- test-windows:
name: Test OS=Windows Node=<<matrix.node_version>> JDK=<<matrix.jdk_version>> Gradle=<<matrix.gradle_version>>
context: nodejs-install
Expand All @@ -272,6 +294,14 @@ workflows:
- Lint
<<: *filters_branches_ignore_main

- test-windows:
name: Test OS=Windows Node=<<matrix.node_version>> JDK=<<matrix.jdk_version>> Gradle=<<matrix.gradle_version>>
context: nodejs-install
<<: *test_matrix_win_new_versions
requires:
- Lint
<<: *filters_branches_ignore_main

- release:
name: Release
context: nodejs-app-release
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Please refer to the [Snyk for Java](https://docs.snyk.io/products/snyk-open-sour
| ------- | --------- |
| Windows | ✅ |
| Linux | ✅ |
| OSX | ️✅ |
| OSX | ️✅ |

## Supported Node versions

| Node | Supported |
| ---- | --------- |
| 12 | ✅ |
| 14 | ✅ |
| 16 | ✅ |
| 18 | ✅ |
| 20 | ✅ |

## Supported Gradle versions

Expand All @@ -45,6 +45,7 @@ Please refer to the [Snyk for Java](https://docs.snyk.io/products/snyk-open-sour
| 5 | ✅ |
| 6 | ✅ |
| 7 | ✅ |
| 8 | ✅ |

# Supported Snyk command line arguments:

Expand Down
3 changes: 2 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,8 @@ function buildArgs(

// Gradle 7 introduced configuration caching which we don't support yet
// If it is enabled in a gradle.properties file, it can be disabled on the command line with --no-configuration-cache
if (gradleVersion.match(/Gradle 7/)) args.push('--no-configuration-cache');
if (gradleVersion.match(/Gradle 7/) || gradleVersion.match(/Gradle 8/))
args.push('--no-configuration-cache');

// There might be a legacy --configuration option in 'args'.
// It has been superseded by --configuration-matching option for Snyk CLI (see buildArgs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ repositories {
}

dependencies {
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testCompile("org.jetbrains.kotlin:kotlin-reflect") {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.jetbrains.kotlin:kotlin-reflect") {
exclude(module = "junit")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ repositories {
}

dependencies {
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testCompile("org.jetbrains.kotlin:kotlin-reflect") {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.jetbrains.kotlin:kotlin-reflect") {
exclude(module = "junit")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ repositories {
}

dependencies {
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testCompile("org.jetbrains.kotlin:kotlin-reflect") {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.jetbrains.kotlin:kotlin-reflect") {
exclude(module = "junit")
}
}
Expand Down
50 changes: 21 additions & 29 deletions test/fixtures/custom-resolution-strategy-via-all/build.gradle
Original file line number Diff line number Diff line change
@@ -1,55 +1,47 @@
apply plugin: 'java'
apply plugin: 'maven'

group = 'com.github.jitpack'
version = '1.0.0'

sourceCompatibility = 1.8 // java 8
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
compile 'commons-discovery:commons-discovery:0.2'
compile 'axis:axis:1.3'
implementation 'commons-discovery:commons-discovery:0.2'
implementation 'axis:axis:1.3'
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
if (project.gradle.gradleVersion >= '6.3') {
archiveClassifier.set('sources')
} else {
classifier = 'sources'
}
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
if (project.gradle.gradleVersion >= '6.3') {
archiveClassifier.set('javadoc')
} else {
classifier = 'javadoc'
}
from javadoc.destinationDir
}

artifacts {
archives sourcesJar
archives javadocJar
archives tasks.sourcesJar
archives tasks.javadocJar
}

// To specify a license in the pom:
install {
repositories.mavenInstaller {
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
}

// See https://docs.gradle.org/current/userguide/customizing_dependency_resolution_behavior.html#sec:dependency_resolve_rules
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'commons-logging' && details.requested.name == 'commons-logging') {
details.useVersion '1.0.3'
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'commons-logging' && details.requested.name == 'commons-logging') {
details.useVersion '1.0.3'
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
apply plugin: 'java'
apply plugin: 'maven'

group = 'com.github.jitpack'
version = '1.0.0'

sourceCompatibility = 1.8 // java 8
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
compile 'commons-discovery:commons-discovery:0.2'
compile 'axis:axis:1.3'
implementation 'commons-discovery:commons-discovery:0.2'
implementation 'axis:axis:1.3'
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
if (project.gradle.gradleVersion >= '6.3') {
archiveClassifier.set('sources')
} else {
classifier = 'sources'
}
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
if (project.gradle.gradleVersion >= '6.3') {
archiveClassifier.set('javadoc')
} else {
classifier = 'javadoc'
}
dependsOn 'javadoc'
from javadoc.destinationDir
}

Expand All @@ -30,33 +39,10 @@ artifacts {
archives javadocJar
}

// To specify a license in the pom:
install {
repositories.mavenInstaller {
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'commons-logging' && details.requested.name == 'commons-logging') {
details.useVersion '1.0.3'
}
}
}
}
}

Closure versionStrategy = {
eachDependency { details ->
if (details.requested.group == 'commons-logging' && details.requested.name == 'commons-logging') {
details.useVersion '1.0.3'
}
}
}

// See https://github.com/snyk/snyk/issues/729
// We currently do NOT support this. Securely transplanting resolution strategy from constituent
// configurations using Gradle APIs is pretty hard.
// Known workarounds:
// - use `configurations.all` syntax, as recommended by Gradle documentation
// - scan a particular configuration using, e.g. `snyk test --configuration-matching=^compile$`
configurations*.resolutionStrategy versionStrategy
35 changes: 20 additions & 15 deletions test/fixtures/gradle-kts/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import org.gradle.api.JavaVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
val kotlinVersion = "1.3.21"
id("org.jetbrains.kotlin.jvm") version kotlinVersion
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
val kotlinVersion = if (JavaVersion.current().toString() >= "17") "1.8.10" else "1.3.21"
kotlin("jvm") version kotlinVersion
kotlin("plugin.spring") version kotlinVersion
kotlin("plugin.jpa") version kotlinVersion
}

version = "1.0.0-SNAPSHOT"

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xjsr305=strict")
}
doFirst {
if (JavaVersion.current().isJava8Compatible()) {
kotlinOptions.jvmTarget = "1.8"
} else {
kotlinOptions.jvmTarget = "17"
}
kotlinOptions.freeCompilerArgs = listOf("-Xjsr305=strict")
}
}


tasks.withType<Test> {
useJUnitPlatform()
useJUnitPlatform()
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
// Removed Spring because too heavy
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testCompile("org.jetbrains.kotlin:kotlin-reflect") {
exclude(module = "junit")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.jetbrains.kotlin:kotlin-reflect") {
exclude(module = "junit")
}
}
1 change: 0 additions & 1 deletion test/fixtures/malformed-build-gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'java'
apply plugin: 'maven'

group = 'com.github.jitpack'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'java'
apply plugin: 'maven'

group = 'com.github.jitpack'

Expand Down Expand Up @@ -65,10 +64,10 @@ dependencies.attributesSchema {


dependencies {
compile 'com.google.guava:guava:18.0'
implementation 'com.google.guava:guava:18.0'
apiConf 'commons-httpclient:commons-httpclient:3.1'
runtimeConf 'org.apache.commons:commons-lang3:3.8.1'
compile project(':subproj')
implementation project(':subproj')
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/multi-config-attributes/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'java'
apply plugin: 'maven'

group = 'com.github.jitpack'

Expand Down Expand Up @@ -45,7 +44,7 @@ if (project.hasProperty('objects')) {
}

dependencies {
compile 'com.google.guava:guava:18.0'
implementation 'com.google.guava:guava:18.0'
apiConf 'commons-httpclient:commons-httpclient:3.1'
runtimeConf 'org.apache.commons:commons-lang3:3.8.1'
}
Expand Down
Loading