dharrigan

Untitled

Jan 17th, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 3.00 KB | None | 0 0
  1. import org.asciidoctor.gradle.AsciidoctorExtension
  2. import org.asciidoctor.gradle.AsciidoctorTask
  3. import org.gradle.kotlin.dsl.kotlin
  4. import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
  5. import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  6. import org.springframework.boot.gradle.tasks.bundling.BootJar
  7.  
  8. plugins {
  9.     val asciiDoctorVersion = "1.5.7"
  10.     val kotlinVersion = "1.3.10"
  11.     val nebulaKotlinVersion = "1.3.10"
  12.     val nebulaProjectVersion = "5.1.2"
  13.     val springBootVersion = "2.1.0.RELEASE"
  14.     val springDependencyManagementVersion = "1.0.6.RELEASE"
  15.  
  16.     idea
  17.     java
  18.     jacoco
  19.     kotlin("jvm") version kotlinVersion
  20.     kotlin("plugin.spring") version kotlinVersion
  21.     id("io.spring.dependency-management") version springDependencyManagementVersion
  22.     id("nebula.integtest") version nebulaProjectVersion
  23.     id("nebula.kotlin") version nebulaKotlinVersion
  24.     id("nebula.project") version nebulaProjectVersion
  25.     id("org.asciidoctor.convert") version asciiDoctorVersion
  26.     id("org.springframework.boot") version springBootVersion
  27. }
  28.  
  29. val snippetsDir = file("build/generated-snippets")
  30.  
  31. group = "com.dharrigan"
  32. version = System.getenv("PROJECT_VERSION") ?: "0.0.0-SNAPSHOT"
  33. description = "FooBar"
  34.  
  35. java.sourceCompatibility = JavaVersion.VERSION_1_8
  36.  
  37. repositories {
  38.     mavenLocal()
  39. }
  40.  
  41. with(configurations) {
  42.     all { resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) }
  43.     testImplementation.exclude(module = "junit", group = "junit")
  44. }
  45.  
  46. dependencies {
  47.     implementation(kotlin("reflect"))
  48.     asciidoctor("org.springframework.restdocs:spring-restdocs-asciidoctor")
  49. }
  50.  
  51. idea {
  52.     module.isDownloadJavadoc = true
  53.     project {
  54.         vcs = "Git"
  55.         languageLevel = IdeaLanguageLevel(java.sourceCompatibility)
  56.     }
  57. }
  58.  
  59. with(tasks) {
  60.     withType<JavaCompile> {
  61.         with(options) {
  62.             encoding = "UTF-8"
  63.             compilerArgs = mutableListOf("-Xlint", "-parameters")
  64.             setIncremental(true)
  65.         }
  66.     }
  67.     withType<KotlinCompile> {
  68.         kotlinOptions {
  69.             freeCompilerArgs = listOf("-Xjsr305=strict")
  70.             javaParameters = true
  71.             jvmTarget = java.sourceCompatibility.name
  72.         }
  73.     }
  74.     val testTask = withType<Test> {
  75.         outputs.dir(snippetsDir)
  76.         jacocoTestReport.reports.html.isEnabled = true
  77.         jacocoTestReport.executionData(this)
  78.         useJUnitPlatform()
  79.         failFast = true
  80.     }
  81.     val asciiDocTask = withType<AsciidoctorTask> {
  82.         dependsOn(testTask)
  83.         inputs.dir(snippetsDir)
  84.         attributes.putAll(mapOf("snippets" to snippetsDir))
  85.         sourceDir = file("$projectDir/src/main/docs/asciidoc")
  86.         outputDir("$buildDir/asciidoc")
  87.     }
  88.     withType<BootJar> {
  89.         dependsOn(asciiDocTask)
  90.         mainClassName = "com.dharrigan.Foobar"
  91.         from("$buildDir/asciidoc/html5") {
  92.             include("*.html")
  93.             into("BOOT-INF/classes/static")
  94.         }
  95.         rootSpec.exclude("logback.xml")
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment