lots of exercises in java... from https://github.com/exercism/java

build.gradle 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // This root Gradle project is used for:
  2. //
  3. // - Checking that every test suite compiles against its corresponding reference implementation;
  4. // - Checking that every reference implementation passes its corresponding test suite;
  5. // - Checking that every provided starter implementation compiles.
  6. //
  7. // This file is never delivered to Exercism users.
  8. def generatedTestSourceDir = "build/gen/test/java"
  9. subprojects {
  10. // Add a task that copies test source files into a build directory. All @Ignore annotations
  11. // are removed during this copying, so that when we run the copied tests, none are skipped and
  12. // all should execute.
  13. //
  14. // Note that journey-test.sh also strips @Ignore annotations using sed. The
  15. // stripping implementations here and in journey-test.sh should be kept
  16. // consistent.
  17. task copyTestsFilteringIgnores(type: Copy) {
  18. from "src/test/java"
  19. into generatedTestSourceDir
  20. filter { line ->
  21. line.contains("@Ignore") ? null : line
  22. }
  23. }
  24. afterEvaluate { project ->
  25. sourceSets {
  26. // Set the directory containing the reference solution as the default source set. Default
  27. // compile tasks will now run against this source set.
  28. main {
  29. java.srcDirs = [".meta/src/reference/java"]
  30. }
  31. // Define a custom source set named "starterSource" that points to the starter implementations
  32. // delivered to users. We can then use the generated "compileStarterSourceJava" task to verify
  33. // that the starter source compiles as-is.
  34. starterSource {
  35. java.srcDirs = ["src/main/java"]
  36. }
  37. // Set the directory containing the @Ignore-stripped tests as the default test source set.
  38. // Default test tasks will now run against this source set.
  39. test {
  40. java.srcDirs = [generatedTestSourceDir]
  41. }
  42. // Log the source paths associated with each source set to verify they are what we expect.
  43. logCompileTaskSourcePath(project, "compileJava") // Corresponds to the "main" source set.
  44. logCompileTaskSourcePath(project, "compileStarterSourceJava")
  45. logCompileTaskSourcePath(project, "compileTestJava")
  46. }
  47. // When running the standard test task, make sure we prepopulate the test source set with the
  48. // @Ignore-stripped tests.
  49. test.dependsOn(copyTestsFilteringIgnores)
  50. }
  51. }
  52. def logCompileTaskSourcePath(Project project, String taskName) {
  53. project[taskName].doFirst { compileTask ->
  54. println " (source = ${compileTask.source.asPath})"
  55. }
  56. }