build.gradle 4.0 KB

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