build.gradle 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. plugins {
  2. id 'java'
  3. id 'java-library'
  4. id 'org.asciidoctor.jvm.convert' version '3.3.0'
  5. id 'org.asciidoctor.jvm.pdf' version '3.3.0'
  6. id 'org.asciidoctor.jvm.epub' version '3.3.0'
  7. }
  8. group 'org.test'
  9. version '1.0.0'
  10. java {
  11. toolchain {
  12. languageVersion = JavaLanguageVersion.of(8)
  13. }
  14. }
  15. ext {
  16. indexFileName = 'index.adoc'
  17. springAsciidoctorVersion = '0.0.1-M1'
  18. }
  19. repositories {
  20. maven { url 'https://maven.aliyun.com/repository/central' }
  21. mavenCentral()
  22. maven {
  23. url "https://repo.spring.io/milestone"
  24. }
  25. maven {
  26. url "https://repo.spring.io/release"
  27. }
  28. }
  29. configurations {
  30. asciidoctorExtensions
  31. }
  32. dependencies {
  33. asciidoctorExtensions "io.spring.asciidoctor.backends:spring-asciidoctor-backends:${springAsciidoctorVersion}"
  34. }
  35. test {
  36. }
  37. asciidoctor {
  38. baseDirFollowsSourceDir()
  39. sources {
  40. include project.ext.indexFileName
  41. }
  42. resources {
  43. from(sourceDir) {
  44. include 'images/**'
  45. }
  46. }
  47. outputDir file("$buildDir/asciidoc")
  48. configurations "asciidoctorExtensions"
  49. outputOptions {
  50. backends "spring-html"
  51. }
  52. }
  53. asciidoctor.doLast {
  54. delete file("$buildDir/asciidoc/img/banner-logo.svg")
  55. copy {
  56. from file("$buildDir/asciidoc/images/banner-logo.svg")
  57. into file("$buildDir/asciidoc/img")
  58. }
  59. }
  60. asciidoctorj {
  61. options header_footer: true
  62. attributes 'icons@': 'font'
  63. }
  64. asciidoctorPdf {
  65. baseDirFollowsSourceDir()
  66. sources {
  67. include project.ext.indexFileName
  68. }
  69. resources {
  70. from(sourceDir) {
  71. include 'images/**'
  72. }
  73. }
  74. outputDir file("$buildDir/asciidoc")
  75. }
  76. asciidoctorEpub {
  77. ebookFormats(EPUB3)
  78. baseDirFollowsSourceDir()
  79. sources {
  80. include project.ext.indexFileName
  81. }
  82. resources {
  83. from(sourceDir) {
  84. include 'images/**'
  85. }
  86. }
  87. outputDir file("$buildDir/asciidoc")
  88. }
  89. task tarIndexPage(type: Tar) {
  90. description '打包 html 及 pdf'
  91. dependsOn asciidoctor, asciidoctorPdf
  92. archiveFileName = "index.tar.gz"
  93. destinationDirectory = file("$buildDir/dist")
  94. compression = Compression.GZIP
  95. from "$buildDir/asciidoc"
  96. }