diff --git a/gradle/dependency-locks/compile.lockfile b/gradle/dependency-locks/compile.lockfile deleted file mode 100644 index 43e6b71..0000000 --- a/gradle/dependency-locks/compile.lockfile +++ /dev/null @@ -1,10 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cglib:cglib-nodep:3.2.2 -com.google.guava:guava:19.0 -commons-io:commons-io:2.5 -junit:junit:4.12 -org.hamcrest:hamcrest-core:1.3 -org.objenesis:objenesis:2.4 -org.spockframework:spock-core:1.3-groovy-2.4 diff --git a/gradle/dependency-locks/compileOnly.lockfile b/gradle/dependency-locks/compileOnly.lockfile deleted file mode 100644 index 656c5db..0000000 --- a/gradle/dependency-locks/compileOnly.lockfile +++ /dev/null @@ -1,3 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. diff --git a/gradle/dependency-locks/integTestCompile.lockfile b/gradle/dependency-locks/integTestCompile.lockfile deleted file mode 100644 index 43e6b71..0000000 --- a/gradle/dependency-locks/integTestCompile.lockfile +++ /dev/null @@ -1,10 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cglib:cglib-nodep:3.2.2 -com.google.guava:guava:19.0 -commons-io:commons-io:2.5 -junit:junit:4.12 -org.hamcrest:hamcrest-core:1.3 -org.objenesis:objenesis:2.4 -org.spockframework:spock-core:1.3-groovy-2.4 diff --git a/gradle/dependency-locks/integTestCompileOnly.lockfile b/gradle/dependency-locks/integTestCompileOnly.lockfile deleted file mode 100644 index 656c5db..0000000 --- a/gradle/dependency-locks/integTestCompileOnly.lockfile +++ /dev/null @@ -1,3 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. diff --git a/gradle/dependency-locks/integTestRuntime.lockfile b/gradle/dependency-locks/integTestRuntime.lockfile deleted file mode 100644 index 43e6b71..0000000 --- a/gradle/dependency-locks/integTestRuntime.lockfile +++ /dev/null @@ -1,10 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cglib:cglib-nodep:3.2.2 -com.google.guava:guava:19.0 -commons-io:commons-io:2.5 -junit:junit:4.12 -org.hamcrest:hamcrest-core:1.3 -org.objenesis:objenesis:2.4 -org.spockframework:spock-core:1.3-groovy-2.4 diff --git a/gradle/dependency-locks/runtime.lockfile b/gradle/dependency-locks/runtime.lockfile deleted file mode 100644 index 43e6b71..0000000 --- a/gradle/dependency-locks/runtime.lockfile +++ /dev/null @@ -1,10 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cglib:cglib-nodep:3.2.2 -com.google.guava:guava:19.0 -commons-io:commons-io:2.5 -junit:junit:4.12 -org.hamcrest:hamcrest-core:1.3 -org.objenesis:objenesis:2.4 -org.spockframework:spock-core:1.3-groovy-2.4 diff --git a/gradle/dependency-locks/testCompile.lockfile b/gradle/dependency-locks/testCompile.lockfile deleted file mode 100644 index 43e6b71..0000000 --- a/gradle/dependency-locks/testCompile.lockfile +++ /dev/null @@ -1,10 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cglib:cglib-nodep:3.2.2 -com.google.guava:guava:19.0 -commons-io:commons-io:2.5 -junit:junit:4.12 -org.hamcrest:hamcrest-core:1.3 -org.objenesis:objenesis:2.4 -org.spockframework:spock-core:1.3-groovy-2.4 diff --git a/gradle/dependency-locks/testCompileOnly.lockfile b/gradle/dependency-locks/testCompileOnly.lockfile deleted file mode 100644 index 656c5db..0000000 --- a/gradle/dependency-locks/testCompileOnly.lockfile +++ /dev/null @@ -1,3 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. diff --git a/gradle/dependency-locks/testRuntime.lockfile b/gradle/dependency-locks/testRuntime.lockfile deleted file mode 100644 index 43e6b71..0000000 --- a/gradle/dependency-locks/testRuntime.lockfile +++ /dev/null @@ -1,10 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cglib:cglib-nodep:3.2.2 -com.google.guava:guava:19.0 -commons-io:commons-io:2.5 -junit:junit:4.12 -org.hamcrest:hamcrest-core:1.3 -org.objenesis:objenesis:2.4 -org.spockframework:spock-core:1.3-groovy-2.4 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index cc4fdc2..f3d88b1 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ba94df8..1b16c34 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/groovy/nebula/test/BaseIntegrationSpec.groovy b/src/main/groovy/nebula/test/BaseIntegrationSpec.groovy index ad18b86..f2b2e9c 100644 --- a/src/main/groovy/nebula/test/BaseIntegrationSpec.groovy +++ b/src/main/groovy/nebula/test/BaseIntegrationSpec.groovy @@ -18,6 +18,7 @@ package nebula.test import groovy.transform.CompileStatic import groovy.transform.TypeCheckingMode import org.gradle.api.logging.LogLevel +import org.gradle.api.logging.configuration.WarningMode import org.junit.Rule import org.junit.rules.TestName import spock.lang.Specification @@ -81,39 +82,6 @@ abstract class BaseIntegrationSpec extends Specification { file } - protected static void checkForDeprecations(String output) { - def deprecations = output.readLines().findAll { - it.contains("has been deprecated and is scheduled to be removed in Gradle") || - it.contains("Deprecated Gradle features were used in this build") || - it.contains("has been deprecated. This is scheduled to be removed in Gradle") || - it.contains("This behaviour has been deprecated and is scheduled to be removed in Gradle") - } - // temporary for known issue with overwriting task - // overridden task expected to not be needed in future version - if (deprecations.size() == 1 && deprecations.first().contains("Creating a custom task named 'dependencyInsight' has been deprecated and is scheduled to be removed in Gradle 5.0.")) { - return - } - if (!System.getProperty("ignoreDeprecations") && !deprecations.isEmpty()) { - throw new IllegalArgumentException("Deprecation warnings were found (Set the ignoreDeprecations system property during the test to ignore):\n" + deprecations.collect { - " - $it" - }.join("\n")) - } - } - - protected static void checkForMutableProjectState(String output) { - def mutableProjectStateWarnings = output.readLines().findAll { - it.contains("was resolved without accessing the project in a safe manner") || - it.contains("This may happen when a configuration is resolved from a thread not managed by Gradle or from a different project") - - } - - if (!System.getProperty("ignoreMutableProjectStateWarnings") && !mutableProjectStateWarnings.isEmpty()) { - throw new IllegalArgumentException("Mutable Project State warnings were found (Set the ignoreMutableProjectStateWarnings system property during the test to ignore):\n" + mutableProjectStateWarnings.collect { - " - $it" - }.join("\n")) - } - } - protected void writeHelloWorld(File baseDir = getProjectDir()) { writeHelloWorld('nebula', baseDir) } @@ -211,15 +179,11 @@ abstract class BaseIntegrationSpec extends Specification { getProjectDir().getName().replaceAll(/_\d+/, '') } - protected List calculateArguments(String... args) { + protected List calculateArguments(WarningMode warningMode, String... args) { + // We have to avoid the command line switch for backwards compatibility and system properties in non-forked and forked modes are weird so we use gradle.properties + new File(projectDir, 'gradle.properties') << '\norg.gradle.warning.mode=' + warningMode.name().toLowerCase() + List arguments = [] - // Gradle will use these files name from the PWD, instead of the project directory. It's easier to just leave - // them out and let the default find them, since we're not changing their default names. - //arguments += '--build-file' - //arguments += (buildFile.canonicalPath - projectDir.canonicalPath).substring(1) - //arguments += '--settings-file' - //arguments += (settingsFile.canonicalPath - projectDir.canonicalPath).substring(1) - //arguments += '--no-daemon' switch (getLogLevel()) { case LogLevel.INFO: arguments += '--info' @@ -232,9 +196,8 @@ abstract class BaseIntegrationSpec extends Specification { arguments += '--parallel' } arguments += '--stacktrace' - arguments += '-Dorg.gradle.warning.mode=all' arguments.addAll(args) arguments.addAll(initScripts.collect { file -> '-I' + file.absolutePath }) arguments } -} \ No newline at end of file +} diff --git a/src/main/groovy/nebula/test/IntegrationSpec.groovy b/src/main/groovy/nebula/test/IntegrationSpec.groovy index a7e888c..d876d96 100644 --- a/src/main/groovy/nebula/test/IntegrationSpec.groovy +++ b/src/main/groovy/nebula/test/IntegrationSpec.groovy @@ -26,6 +26,7 @@ import nebula.test.functional.internal.GradleHandle import nebula.test.multiproject.MultiProjectIntegrationHelper import org.apache.commons.io.FileUtils import org.gradle.api.logging.LogLevel +import org.gradle.api.logging.configuration.WarningMode /** * @author Justin Ryan @@ -34,7 +35,7 @@ import org.gradle.api.logging.LogLevel @CompileStatic abstract class IntegrationSpec extends BaseIntegrationSpec { private static final String DEFAULT_REMOTE_DEBUG_JVM_ARGUMENTS = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" - private static final Integer DEFAULT_DAEMON_MAX_IDLE_TIME_IN_SECONDS_IN_MEMORY_SAFE_MODE = 15; + private static final Integer DEFAULT_DAEMON_MAX_IDLE_TIME_IN_SECONDS_IN_MEMORY_SAFE_MODE = 15 // Holds State of last run private ExecutionResult result @@ -72,8 +73,8 @@ abstract class IntegrationSpec extends BaseIntegrationSpec { helper = new MultiProjectIntegrationHelper(getProjectDir(), settingsFile) } - protected GradleHandle launcher(String... args) { - List arguments = calculateArguments(args) + protected GradleHandle launcher(WarningMode warningMode, String ... args) { + List arguments = calculateArguments(warningMode, args) List jvmArguments = calculateJvmArguments() Integer daemonMaxIdleTimeInSeconds = calculateMaxIdleDaemonTimeoutInSeconds() @@ -144,7 +145,11 @@ abstract class IntegrationSpec extends BaseIntegrationSpec { /* Execution */ protected ExecutionResult runTasksSuccessfully(String... tasks) { - ExecutionResult result = runTasks(tasks) + return runTasksSuccessfully(WarningMode.Fail, tasks) + } + + protected ExecutionResult runTasksSuccessfully(WarningMode warningMode, String... tasks) { + ExecutionResult result = runTasks(warningMode, tasks) if (result.failure) { result.rethrowFailure() } @@ -153,20 +158,23 @@ abstract class IntegrationSpec extends BaseIntegrationSpec { @CompileStatic(TypeCheckingMode.SKIP) protected ExecutionResult runTasksWithFailure(String... tasks) { - ExecutionResult result = runTasks(tasks) + return runTasksWithFailure(WarningMode.Fail, tasks) + } + + @CompileStatic(TypeCheckingMode.SKIP) + protected ExecutionResult runTasksWithFailure(WarningMode warningMode, String... tasks) { + ExecutionResult result = runTasks(warningMode, tasks) assert result.failure result } protected ExecutionResult runTasks(String... tasks) { - ExecutionResult result = launcher(tasks).run() - this.result = result - return checkForDeprecations(result) + return runTasks(WarningMode.Fail, tasks) } - protected ExecutionResult checkForDeprecations(ExecutionResult result) { - checkForMutableProjectState(result.standardOutput) - checkForDeprecations(result.standardOutput) + protected ExecutionResult runTasks(WarningMode warningMode, String... tasks) { + ExecutionResult result = launcher(warningMode, tasks).run() + this.result = result return result } diff --git a/src/main/groovy/nebula/test/IntegrationTestKitSpec.groovy b/src/main/groovy/nebula/test/IntegrationTestKitSpec.groovy index e2044c9..7c8eb13 100644 --- a/src/main/groovy/nebula/test/IntegrationTestKitSpec.groovy +++ b/src/main/groovy/nebula/test/IntegrationTestKitSpec.groovy @@ -15,7 +15,9 @@ */ package nebula.test + import nebula.test.functional.internal.classpath.ClasspathAddingInitScriptBuilder +import org.gradle.api.logging.configuration.WarningMode import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner import org.gradle.util.GFileUtils @@ -41,7 +43,7 @@ abstract class IntegrationTestKitSpec extends BaseIntegrationSpec { boolean definePluginOutsideOfPluginBlock = false def setup() { - if (! settingsFile) { + if (!settingsFile) { settingsFile = new File(projectDir, "settings.gradle") settingsFile.text = "rootProject.name='${moduleName}'\n" } @@ -68,15 +70,19 @@ abstract class IntegrationTestKitSpec extends BaseIntegrationSpec { } BuildResult runTasks(String... tasks) { - BuildResult result = createRunner(tasks) - .build() - return checkForDeprecations(result) + return runTasks(WarningMode.Fail, tasks) + } + + BuildResult runTasks(WarningMode warningMode, String... tasks) { + return createRunner(warningMode, tasks).build() } BuildResult runTasksAndFail(String... tasks) { - BuildResult result = createRunner(tasks) - .buildAndFail() - return checkForDeprecations(result) + return runTasksAndFail(WarningMode.Fail, tasks) + } + + BuildResult runTasksAndFail(WarningMode warningMode, String... tasks) { + return createRunner(warningMode, tasks).buildAndFail() } def tasksWereSuccessful(BuildResult result, String... tasks) { @@ -90,14 +96,19 @@ abstract class IntegrationTestKitSpec extends BaseIntegrationSpec { } GradleRunner createRunner(String... tasks) { - def pluginArgs = definePluginOutsideOfPluginBlock ? createGradleTestKitInitArgs() : new ArrayList<>() + return createRunner(WarningMode.Fail, tasks) + } + + GradleRunner createRunner(WarningMode warningMode, String... tasks) { + def arguments = calculateArguments(warningMode, tasks) + def pluginArgs = definePluginOutsideOfPluginBlock ? createGradleTestKitInitArgs() : new ArrayList() def gradleRunnerBuilder = GradleRunner.create() .withProjectDir(projectDir) - .withArguments(calculateArguments(tasks) + pluginArgs) + .withArguments(arguments + pluginArgs) .withDebug(debug) .withPluginClasspath() - if(forwardOutput) { + if (forwardOutput) { gradleRunnerBuilder.forwardOutput() } if (gradleVersion != null) { @@ -122,9 +133,4 @@ abstract class IntegrationTestKitSpec extends BaseIntegrationSpec { return Arrays.asList("--init-script", initScript.getAbsolutePath()) } - - protected BuildResult checkForDeprecations(BuildResult result) { - checkForDeprecations(result.output) - return result - } } diff --git a/src/test/groovy/nebula/test/MutableProjectStateWarningCheckIntegrationSpec.groovy b/src/test/groovy/nebula/test/MutableProjectStateWarningCheckIntegrationSpec.groovy index c2943ed..815e3d6 100644 --- a/src/test/groovy/nebula/test/MutableProjectStateWarningCheckIntegrationSpec.groovy +++ b/src/test/groovy/nebula/test/MutableProjectStateWarningCheckIntegrationSpec.groovy @@ -3,7 +3,7 @@ package nebula.test class MutableProjectStateWarningCheckIntegrationSpec extends IntegrationSpec { def setup() { - gradleVersion = "5.1" + gradleVersion = "5.6.4" } def 'mutable project state warning when configuration in another project is resolved unsafely'() { @@ -38,11 +38,10 @@ class MutableProjectStateWarningCheckIntegrationSpec extends IntegrationSpec { when: - runTasks("resolve", "--parallel", "--warning-mode", "all") + def failure = runTasksWithFailure("resolve", "--parallel").failure then: - def e = thrown(IllegalArgumentException) - e.message.contains('Mutable Project State warnings were found (Set the ignoreMutableProjectStateWarnings system property during the test to ignore)') + failure.message.contains('Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0') } def 'mutable project state warning when configuration is resolved from a non-gradle thread'() { @@ -81,11 +80,10 @@ class MutableProjectStateWarningCheckIntegrationSpec extends IntegrationSpec { when: - runTasks("resolve", "--warning-mode", "all") + def failure = runTasksWithFailure("resolve").failure then: - def e = thrown(IllegalArgumentException) - e.message.contains('Mutable Project State warnings were found (Set the ignoreMutableProjectStateWarnings system property during the test to ignore)') + failure.message.contains('Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0') } def 'mutable project state warning when configuration is resolved while evaluating a different project'() { @@ -117,11 +115,10 @@ class MutableProjectStateWarningCheckIntegrationSpec extends IntegrationSpec { when: - runTasks(":bar:help", "--parallel", "--warning-mode", "all") + def failure = runTasksWithFailure(":bar:help", "--parallel").failure then: - def e = thrown(IllegalArgumentException) - e.message.contains('Mutable Project State warnings were found (Set the ignoreMutableProjectStateWarnings system property during the test to ignore)') + failure.message.contains('Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0') } }