build.gradle.kts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // the build derives a version with the jgitver plugin out of a tag in the git history. when there is no
  2. // git repo, the jgitver default would be 0.0.0. one can override this version with a parameter. also, permit
  3. // to start the build setting the javac release parameter, no parameter means build for java-17:
  4. // gradle clean build -PjavacRelease=17
  5. // gradle clean build -PjavacRelease=21
  6. // gradle clean build -PcustomVersion=1.0.0-10-asdf
  7. val customVersion = (project.findProperty("customVersion") ?: "") as String
  8. val javacRelease = (project.findProperty("javacRelease") ?: "17") as String
  9. plugins {
  10. id("fr.brouillard.oss.gradle.jgitver") version "0.9.1"
  11. id("jacoco")
  12. id("java")
  13. id("maven-publish")
  14. }
  15. repositories {
  16. mavenLocal()
  17. mavenCentral()
  18. }
  19. dependencies {
  20. implementation("com.lmax:disruptor:3.4.4")
  21. implementation("org.java-websocket:Java-WebSocket:1.5.3")
  22. implementation("org.jsoup:jsoup:1.16.1")
  23. implementation("org.json:json:20211205")
  24. implementation("com.j2html:j2html:1.6.0")
  25. implementation("commons-configuration:commons-configuration:1.10")
  26. implementation("commons-cli:commons-cli:1.5.0")
  27. implementation("commons-io:commons-io:2.13.0")
  28. implementation("org.apache.httpcomponents:httpclient:4.5.14")
  29. implementation("org.apache.httpcomponents:httpmime:4.5.14")
  30. implementation("org.apache.logging.log4j:log4j-api:2.20.0")
  31. implementation("org.apache.logging.log4j:log4j-core:2.20.0")
  32. implementation("com.squareup.okhttp3:okhttp:4.12.0")
  33. implementation("org.graalvm.js:js:22.3.2")
  34. testImplementation(enforcedPlatform("org.junit:junit-bom:5.10.0"))
  35. testImplementation("org.junit.jupiter:junit-jupiter")
  36. testRuntimeOnly("org.junit.platform:junit-platform-launcher")
  37. }
  38. group = "com.rarchives.ripme"
  39. version = "1.7.94"
  40. description = "ripme"
  41. jacoco {
  42. toolVersion = "0.8.12"
  43. }
  44. jgitver {
  45. gitCommitIDLength = 8
  46. nonQualifierBranches = "main,master"
  47. useGitCommitID = true
  48. }
  49. afterEvaluate {
  50. if (customVersion != "") {
  51. project.version = customVersion
  52. }
  53. }
  54. tasks.compileJava {
  55. options.release.set(Integer.parseInt(javacRelease))
  56. }
  57. tasks.withType<Jar> {
  58. duplicatesStrategy = DuplicatesStrategy.INCLUDE
  59. manifest {
  60. attributes["Main-Class"] = "com.rarchives.ripme.App"
  61. attributes["Implementation-Version"] = archiveVersion
  62. attributes["Multi-Release"] = "true"
  63. }
  64. // To add all of the dependencies otherwise a "NoClassDefFoundError" error
  65. from(sourceSets.main.get().output)
  66. dependsOn(configurations.runtimeClasspath)
  67. from({
  68. configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
  69. })
  70. }
  71. publishing {
  72. publications {
  73. create<MavenPublication>("maven") {
  74. from(components["java"])
  75. }
  76. }
  77. }
  78. tasks.withType<JavaCompile> {
  79. options.encoding = "UTF-8"
  80. val compilerArgs = options.compilerArgs
  81. compilerArgs.addAll(listOf("-Xlint:deprecation"))
  82. }
  83. tasks.test {
  84. testLogging {
  85. showStackTraces = true
  86. }
  87. useJUnitPlatform {
  88. // gradle-6.5.1 not yet allows passing this as parameter, so exclude it
  89. excludeTags("flaky","slow")
  90. includeEngines("junit-jupiter")
  91. includeEngines("junit-vintage")
  92. }
  93. finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
  94. }
  95. tasks.register<Test>("testAll") {
  96. useJUnitPlatform {
  97. includeTags("any()", "none()")
  98. }
  99. }
  100. tasks.register<Test>("testFlaky") {
  101. useJUnitPlatform {
  102. includeTags("flaky")
  103. }
  104. }
  105. tasks.register<Test>("testSlow") {
  106. useJUnitPlatform {
  107. includeTags("slow")
  108. }
  109. }
  110. tasks.register<Test>("testTagged") {
  111. useJUnitPlatform {
  112. includeTags("any()")
  113. }
  114. }
  115. // make all archive tasks in the build reproducible
  116. tasks.withType<AbstractArchiveTask>().configureEach {
  117. isPreserveFileTimestamps = false
  118. isReproducibleFileOrder = true
  119. }
  120. println("Build directory: ${file(layout.buildDirectory)}")
  121. tasks.jacocoTestReport {
  122. dependsOn(tasks.test) // tests are required to run before generating the report
  123. reports {
  124. xml.required.set(false)
  125. csv.required.set(false)
  126. html.outputLocation.set(file("${file(layout.buildDirectory)}/jacocoHtml"))
  127. }
  128. }