build.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. plugins {
  2. id "checkstyle"
  3. id 'com.github.node-gradle.node' version '3.0.1'
  4. id "eclipse"
  5. id "io.spring.nohttp" version "0.0.7"
  6. id "io.spring.javaformat"
  7. id "java"
  8. id "maven-publish"
  9. }
  10. group = 'io.spring.asciidoctor.backends'
  11. description = 'Spring Asciidoctor Backends'
  12. apply from: "$rootDir/gradle/publish-maven.gradle"
  13. def generatedGem = "$buildDir/generated-resources/gem"
  14. def generatedAssets = "$buildDir/generated-resources/assets"
  15. def mavenProjectRepository = "$buildDir/maven-repository"
  16. sourceCompatibility = "1.8"
  17. targetCompatibility = "1.8"
  18. java {
  19. withJavadocJar()
  20. withSourcesJar()
  21. }
  22. sourceSets {
  23. main {
  24. output.dir(generatedAssets, builtBy: "gulp")
  25. output.dir(generatedGem, builtBy: "gem")
  26. }
  27. test {
  28. output.dir(mavenProjectRepository, builtBy: ["publishMavenPublicationToProjectRepository", "unzipMavenBinary"])
  29. }
  30. }
  31. configurations {
  32. mavenBinary
  33. }
  34. repositories {
  35. mavenCentral()
  36. }
  37. dependencies {
  38. checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:$springJavaFormatVersion")
  39. compileOnly("org.asciidoctor:asciidoctorj:$asciidoctorjVersion")
  40. compileOnly("org.asciidoctor:asciidoctorj-pdf:$asciidoctorjPdfVersion")
  41. testImplementation("com.google.guava:guava:30.1-jre")
  42. testImplementation("org.apache.pdfbox:pdfbox:2.0.23")
  43. testImplementation("org.asciidoctor:asciidoctorj:$asciidoctorjVersion")
  44. testImplementation("org.asciidoctor:asciidoctorj-pdf:$asciidoctorjPdfVersion")
  45. testImplementation("org.assertj:assertj-core:3.11.1")
  46. testImplementation("org.jsoup:jsoup:1.13.1")
  47. testImplementation("org.junit.jupiter:junit-jupiter:5.6.0")
  48. testImplementation("org.seleniumhq.selenium:selenium-chrome-driver:3.141.59")
  49. testImplementation("org.seleniumhq.selenium:selenium-remote-driver:3.141.59")
  50. testImplementation("org.slf4j:slf4j-simple:1.7.30")
  51. testImplementation("org.testcontainers:junit-jupiter:1.15.2")
  52. testImplementation("org.testcontainers:selenium:1.15.2")
  53. testImplementation("org.apache.maven:maven-embedder:3.6.2");
  54. testImplementation("org.apache.maven.shared:maven-invoker:3.1.0")
  55. testImplementation("org.testcontainers:junit-jupiter:1.15.2")
  56. testImplementation gradleTestKit()
  57. testRuntimeOnly("org.junit.platform:junit-platform-launcher")
  58. mavenBinary("org.apache.maven:apache-maven:3.6.2:bin@zip")
  59. }
  60. node {
  61. version = '20.9.0'
  62. download = true
  63. }
  64. tasks.withType(JavaCompile) {
  65. options.compilerArgs << '-parameters'
  66. }
  67. nohttp {
  68. source.exclude "node_modules/**"
  69. source.exclude "src/test/maven/target/**"
  70. source.exclude "src/test/gradle/build/**"
  71. }
  72. test {
  73. useJUnitPlatform()
  74. }
  75. task convertTestAsciidoc(type: JavaExec) {
  76. classpath = sourceSets.test.runtimeClasspath
  77. main = 'io.spring.asciidoctor.backend.testsupport.TestSpringHtmlConverter'
  78. }
  79. task gulp(type: NpmTask) {
  80. dependsOn("npm_install")
  81. inputs.dir("src/main/css")
  82. inputs.dir("src/main/img")
  83. inputs.dir("src/main/js")
  84. inputs.file("postcss.config.js")
  85. outputs.dir(generatedAssets)
  86. args = ["run", "build", "--output=${generatedAssets}"]
  87. }
  88. task dev(type: NpmTask) {
  89. dependsOn("convertTestAsciidoc")
  90. args = ["run", "dev"]
  91. }
  92. task gem(type: Sync) {
  93. dependsOn("gulp")
  94. inputs.dir("src/main/ruby")
  95. inputs.dir("src/main/gemspec")
  96. outputs.dir(generatedGem)
  97. destinationDir = file(generatedGem)
  98. from("src/main/ruby/") {
  99. into("gems/spring-asciidoctor-backends-0.0.0/")
  100. }
  101. from("src/main/gemspec/") {
  102. into("specifications/")
  103. }
  104. from(generatedAssets) {
  105. into("gems/spring-asciidoctor-backends-0.0.0/data/assets")
  106. }
  107. }
  108. task prettierFormat(type: NpmTask) {
  109. inputs.dir("src")
  110. outputs.dir("src")
  111. args = ["run", "format"]
  112. }
  113. task prettierCheckFormat(type: NpmTask) {
  114. inputs.dir("src")
  115. args = ["run", "checkFormat"]
  116. }
  117. task unzipMavenBinary(type: Copy) {
  118. configurations.mavenBinary.asFileTree.each { mavenZip ->
  119. from(zipTree(mavenZip))
  120. }
  121. into "$buildDir/maven-binary"
  122. }
  123. tasks.withType(GenerateModuleMetadata) {
  124. enabled = false
  125. }
  126. checkFormat.dependsOn prettierCheckFormat
  127. format.dependsOn prettierFormat
  128. publishing {
  129. publications {
  130. maven(MavenPublication) {
  131. from components.java
  132. }
  133. }
  134. repositories {
  135. maven {
  136. name "project"
  137. url file(mavenProjectRepository).toURI()
  138. }
  139. }
  140. }