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