Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/nebula.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Nebula Build
on:
push:
branches:
- '*'
- 'main'
tags:
- v*.*.*
- v*.*.*-rc.*
Expand Down
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ dependencies {
plugin 'org.eclipse.jdt:core:3.3.0-v_771'

// These are because the AbstractRuleSpec test harness is included in src/main
compileOnly "com.netflix.nebula:nebula-test:11.+"
compileOnly("com.netflix.nebula:nebula-test:10.6.2") {
because("last version compiled on java 8")
}
compileOnly("org.spockframework:spock-core:2.3-groovy-4.0")
compileOnly("junit:junit:4.13.2")
compileOnly(gradleTestKit())
Expand Down Expand Up @@ -158,7 +160,7 @@ jar.dependsOn shadowJar

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(8))
}
}

Expand All @@ -176,6 +178,9 @@ tasks.withType(Test).configureEach {
}
}
}
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}

// Kotlin compiles first, stubbing Java dependencies, however it can't stub Groovy and we need to call Groovy code from Kotlin. For details see:
Expand All @@ -188,7 +193,11 @@ tasks.named('compileKotlin') {
// which automatically makes it depend of compileGroovy
libraries.from(files(sourceSets.main.groovy.classesDirectory))
}

tasks.named("compileTestGroovy") {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
['compileClasspath', 'runtimeClasspath', 'testCompileClasspath', 'testRuntimeClasspath'].each { confName ->
tasks.register("dependencyReport${confName.capitalize()}", DependencyReportTask) {
configurations = [project.configurations.getByName(confName)] as Set
Expand Down
25 changes: 13 additions & 12 deletions gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ com.netflix.nebula:gradle-contacts-plugin:7.0.1=integTestRuntimeClasspath,testRu
com.netflix.nebula:gradle-info-plugin:14.0.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-gradle-interop:2.3.0=integTestRuntimeClasspath
com.netflix.nebula:nebula-gradle-interop:3.0.0=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-test:11.0.0=integTestCompileClasspath,integTestRuntimeClasspath
com.netflix.nebula:nebula-test:11.1.5=compileClasspath,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-test:10.6.2=compileClasspath
com.netflix.nebula:nebula-test:11.3.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.perforce:p4java:2015.2.1365273=integTestRuntimeClasspath,testRuntimeClasspath
commons-lang:commons-lang:2.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
javax.inject:javax.inject:1=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
joda-time:joda-time:2.14.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
junit:junit:4.13.2=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=compileClasspath,testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
net.java.dev.jna:jna-platform:5.16.0=integTestRuntimeClasspath,testRuntimeClasspath
net.java.dev.jna:jna:5.16.0=integTestRuntimeClasspath,testRuntimeClasspath
org.apache.commons:commons-lang3:3.8.1=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
Expand All @@ -29,7 +29,7 @@ org.apache.maven:maven-builder-support:3.8.3=compileClasspath,runtimeClasspath,s
org.apache.maven:maven-model-builder:3.8.3=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
org.apache.maven:maven-model:3.8.3=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.assertj:assertj-core:3.27.3=compileClasspath,testCompileClasspath,testRuntimeClasspath
org.assertj:assertj-core:3.27.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.gpars:gpars:1.2.1=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
org.codehaus.jsr166-mirror:jsr166y:1.7.0=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
org.codehaus.plexus:plexus-interpolation:1.26=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
Expand All @@ -55,21 +55,22 @@ org.hamcrest:hamcrest-core:1.3=compileClasspath,integTestCompileClasspath,integT
org.hamcrest:hamcrest:2.2=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.2.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
org.jetbrains:annotations:13.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
org.jspecify:jspecify:1.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.13.1=integTestCompileClasspath,integTestRuntimeClasspath
org.junit.platform:junit-platform-commons:1.13.4=compileClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.13.1=integTestCompileClasspath,integTestRuntimeClasspath
org.junit.platform:junit-platform-engine:1.13.4=compileClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-launcher:1.13.1=integTestCompileClasspath,integTestRuntimeClasspath
org.junit.platform:junit-platform-launcher:1.13.4=compileClasspath,testCompileClasspath,testRuntimeClasspath
org.jspecify:jspecify:1.0.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.13.4=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.9.0=compileClasspath
org.junit.platform:junit-platform-engine:1.13.4=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.9.0=compileClasspath
org.junit.platform:junit-platform-launcher:1.13.4=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.multiverse:multiverse-core:0.7.0=compileClasspath,runtimeClasspath,shadow,testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:2.4=integTestRuntimeClasspath,testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.opentest4j:opentest4j:1.2.0=compileClasspath
org.opentest4j:opentest4j:1.3.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm-analysis:9.8=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm-commons:9.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm-tree:9.8=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm-util:9.8=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm:9.8=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.spockframework:spock-core:2.3-groovy-4.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.spockframework:spock-junit4:2.3-groovy-3.0=compileClasspath
org.spockframework:spock-junit4:2.3-groovy-4.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
empty=annotationProcessor,compile,integTestAnnotationProcessor,integTestCompile,integTestCompileOnly,integTestRuntime,runtime,testAnnotationProcessor,testCompile,testCompileOnly,testRuntime
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
package com.netflix.nebula.lint.plugin

import com.netflix.nebula.lint.BaseIntegrationTestKitSpec
import com.netflix.nebula.lint.GradleVersions
import com.netflix.nebula.lint.rule.dependency.DependencyParenthesesRule
import com.netflix.nebula.lint.rule.dependency.UnusedDependencyRule
import spock.lang.Issue
import spock.lang.Subject
import spock.lang.Unroll

@Subject([UnusedDependencyRule, DependencyParenthesesRule])
class FixGradleLintTaskSpec extends BaseIntegrationTestKitSpec {
Expand Down Expand Up @@ -49,8 +51,9 @@ class FixGradleLintTaskSpec extends BaseIntegrationTestKitSpec {
results.output.count('unfixed dependency-parentheses') == 1
}

@Unroll
def 'lint fixes violation in all applied files'() {
when:
setup:
buildFile << """
plugins {
id 'nebula.lint'
Expand Down Expand Up @@ -78,11 +81,17 @@ class FixGradleLintTaskSpec extends BaseIntegrationTestKitSpec {

writeHelloWorld()

then:
when:
gradleVersion = testGradleVersion
def results = runTasks('fixGradleLint')

then:
results.output.count('fixed dependency-parentheses') == 2
dependenciesFile.text.contains('implementation \'com.google.guava:guava:18.0\'')
buildFile.text.contains('implementation \'commons-lang:commons-lang:2.6\'')

where:
testGradleVersion << GradleVersions.ALL
}

@Issue('#37')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
package com.netflix.nebula.lint.plugin

import com.netflix.nebula.lint.BaseIntegrationTestKitSpec
import com.netflix.nebula.lint.GradleVersions
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Issue
import spock.lang.Unroll

class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {

@Unroll
def 'run multiple rules on a single module project'() {
when:
setup:
buildFile << """
plugins {
id 'nebula.lint'
Expand All @@ -33,26 +35,27 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
repositories {
mavenCentral()
}
gradleLint.rules = ['dependency-parentheses', 'dependency-tuple']
gradleLint.rules = ['dependency-parentheses', 'dependency-tuple', 'unused-dependency']

dependencies {
implementation('com.google.guava:guava:18.0')
testImplementation group: 'junit',
name: 'junit',
version: '4.11'
testImplementation "junit:junit:4.11"
}
"""

then:
def results = runTasks('assemble')

when:
def console = results.output.readLines()
gradleVersion = testGradleVersion
forwardOutput = true
def results = runTasks('assemble')

then:
console.findAll { it.startsWith('warning') }.size() == 2
def console = results.output.readLines()
console.findAll { it.startsWith('warning') }.size() == 3
console.any { it.contains('dependency-parentheses') }
console.any { it.contains('dependency-tuple') }
console.any { it.contains('unused-dependency') }

where:
testGradleVersion << GradleVersions.ALL
}

def 'run multiple rules on a single module project with applied file'() {
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/netflix/nebula/lint/GradleVersions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.netflix.nebula.lint;

public class GradleVersions {
public static String[] ALL = new String[]{"9.0.0", "9.1.0"};
}