1import groovy.io.FileType 2import org.jetbrains.CorrectShadowPublishing 3import org.jetbrains.CrossPlatformExec 4 5import java.nio.file.Files 6import java.nio.file.StandardCopyOption 7 8apply plugin: 'kotlin' 9apply plugin: 'com.github.johnrengelman.shadow' 10 11sourceCompatibility = 1.8 12 13tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 14 kotlinOptions { 15 freeCompilerArgs += "-Xjsr305=strict" 16 languageVersion = "1.2" 17 apiVersion = languageVersion 18 jvmTarget = "1.8" 19 } 20} 21 22dependencies { 23 shadow project(":runners:fatjar") 24 shadow "org.apache.maven:maven-core:$maven_version" 25 shadow "org.apache.maven:maven-model:$maven_version" 26 shadow "org.apache.maven:maven-plugin-api:$maven_version" 27 shadow "org.apache.maven:maven-archiver:$maven_archiver_version" 28 shadow "org.codehaus.plexus:plexus-utils:$plexus_utils_version" 29 shadow "org.codehaus.plexus:plexus-archiver:$plexus_archiver_version" 30 shadow "org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version" 31 shadow "com.github.olivergondza:maven-jdk-tools-wrapper:0.1" 32} 33 34task generatePom() { 35 inputs.file(new File(projectDir, "pom.tpl.xml")) 36 inputs.property("dokka_version", dokka_version) 37 inputs.property("maven_version", maven_version) 38 inputs.property("maven_plugin_tools_version", maven_plugin_tools_version) 39 outputs.file(new File(buildDir, "pom.xml")) 40 doLast { 41 final pomTemplate = new File(projectDir, "pom.tpl.xml") 42 final pom = new File(buildDir, "pom.xml") 43 pom.text = pomTemplate.text.replace("<version>dokka_version</version>", "<version>$dokka_version</version>") 44 .replace("<maven.version></maven.version>", "<maven.version>$maven_version</maven.version>") 45 .replace("<version>maven-plugin-plugin</version>", "<version>$maven_plugin_tools_version</version>") 46 } 47} 48 49task mergeClassOutputs doLast { 50 def sourceDir = new File(buildDir, "classes/kotlin") 51 def targetDir = new File(buildDir, "classes/java") 52 53 sourceDir.eachFileRecurse FileType.ANY, { 54 def filePath = it.toPath() 55 def targetFilePath = targetDir.toPath().resolve(sourceDir.toPath().relativize(filePath)) 56 if (it.isFile()) { 57 Files.move(filePath, targetFilePath, StandardCopyOption.REPLACE_EXISTING) 58 } else if (it.isDirectory()) { 59 targetFilePath.toFile().mkdirs() 60 } 61 } 62} 63 64task pluginDescriptor(type: CrossPlatformExec) { 65 workingDir buildDir 66 commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:descriptor' 67 68 dependsOn mergeClassOutputs 69} 70 71task helpMojo(type: CrossPlatformExec) { 72 workingDir buildDir 73 commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:helpmojo' 74 75 dependsOn mergeClassOutputs 76} 77 78helpMojo.dependsOn generatePom 79sourceSets.main.java.srcDir("$buildDir/generated-sources/plugin") 80compileJava.dependsOn helpMojo 81 82pluginDescriptor.dependsOn generatePom 83 84shadowJar { 85 baseName = 'dokka-maven-plugin' 86 classifier = '' 87} 88 89shadowJar.dependsOn pluginDescriptor 90 91 92task sourceJar(type: Jar) { 93 from sourceSets.main.allSource 94} 95 96apply plugin: 'maven-publish' 97 98publishing { 99 publications { 100 dokkaMavenPlugin(MavenPublication) { MavenPublication publication -> 101 artifactId = 'dokka-maven-plugin' 102 103 artifact sourceJar { 104 classifier "sources" 105 } 106 107 CorrectShadowPublishing.configure(publication, project) 108 } 109 } 110} 111 112bintrayPublication(project, ['dokkaMavenPlugin']) 113