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

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. subprojects { project ->
  2. apply plugin: "java"
  3. sourceSets {
  4. // Verify that the tests are working by running them against the example code.
  5. // By replacing the "main" sourceSet with the example code we avoid any collisions
  6. // with solution code that may have been included as a "starter" (e.g. etl).
  7. main {
  8. java.srcDirs = ["src/example/java"]
  9. }
  10. project["compileJava"].doFirst { compileTask ->
  11. println " (source = " + compileTask.source.asPath + ")"
  12. }
  13. starterSource {
  14. java.srcDirs = ["src/main/java"]
  15. }
  16. project["compileStarterSourceJava"].doFirst { compileTask ->
  17. println " (source = " + compileTask.source.asPath + ")"
  18. }
  19. // In lieu of being able to disable @Ignore in JUnit tests, we filter
  20. // those annotations, placing the edited tests in the path named here.
  21. test {
  22. java.srcDirs = ["build/gen/test/java"]
  23. }
  24. project["compileTestJava"].doFirst { compileTask ->
  25. println " (source = " + compileTask.source.asPath + ")"
  26. }
  27. }
  28. task copyTestsFilteringIgnores(type: Copy) {
  29. from "src/test/java"
  30. into "build/gen/test/java"
  31. filter { line ->
  32. line.contains("@Ignore") ? "" : line
  33. }
  34. }
  35. test.dependsOn(copyTestsFilteringIgnores)
  36. }