diff options
Diffstat (limited to 'runners/maven-plugin/build.gradle')
-rw-r--r-- | runners/maven-plugin/build.gradle | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle index bac05b2b..f3b9e79c 100644 --- a/runners/maven-plugin/build.gradle +++ b/runners/maven-plugin/build.gradle @@ -1,12 +1,22 @@ -import groovy.xml.QName +import groovy.io.FileType +import org.jetbrains.CorrectShadowPublishing import org.jetbrains.CrossPlatformExec +import java.nio.file.Files +import java.nio.file.StandardCopyOption + apply plugin: 'kotlin' apply plugin: 'com.github.johnrengelman.shadow' +sourceCompatibility = 1.8 -tasks.withType(AbstractCompile) { - classpath += configurations.shadow +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + freeCompilerArgs += "-Xjsr305=strict" + languageVersion = "1.2" + apiVersion = languageVersion + jvmTarget = "1.8" + } } dependencies { @@ -20,22 +30,45 @@ dependencies { shadow "org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version" } -task ("generatePom") doLast { - final pomTemplate = new File(projectDir, "pom.tpl.xml") - final pom = new File(buildDir, "pom.xml") - pom.text = pomTemplate.text.replace("<version>dokka_version</version>", "<version>$dokka_version</version>") - .replace("<maven.version></maven.version>", "<maven.version>$maven_version</maven.version>") - .replace("<version>maven-plugin-plugin</version>", "<version>$maven_plugin_tools_version</version>") +task generatePom() { + inputs.file(new File(projectDir, "pom.tpl.xml")) + outputs.file(new File(buildDir, "pom.xml")) + doLast { + final pomTemplate = new File(projectDir, "pom.tpl.xml") + final pom = new File(buildDir, "pom.xml") + pom.text = pomTemplate.text.replace("<version>dokka_version</version>", "<version>$dokka_version</version>") + .replace("<maven.version></maven.version>", "<maven.version>$maven_version</maven.version>") + .replace("<version>maven-plugin-plugin</version>", "<version>$maven_plugin_tools_version</version>") + } +} + +task mergeClassOutputs doLast { + def sourceDir = new File(buildDir, "classes/kotlin") + def targetDir = new File(buildDir, "classes/java") + + sourceDir.eachFileRecurse FileType.ANY, { + def filePath = it.toPath() + def targetFilePath = targetDir.toPath().resolve(sourceDir.toPath().relativize(filePath)) + if (it.isFile()) { + Files.move(filePath, targetFilePath, StandardCopyOption.REPLACE_EXISTING) + } else if (it.isDirectory()) { + targetFilePath.toFile().mkdirs() + } + } } task pluginDescriptor(type: CrossPlatformExec) { workingDir buildDir commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:descriptor' + + dependsOn mergeClassOutputs } task helpMojo(type: CrossPlatformExec) { workingDir buildDir commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:helpmojo' + + dependsOn mergeClassOutputs } helpMojo.dependsOn generatePom @@ -60,13 +93,15 @@ apply plugin: 'maven-publish' publishing { publications { - dokkaMavenPlugin(MavenPublication) { publication -> + dokkaMavenPlugin(MavenPublication) { MavenPublication publication -> artifactId = 'dokka-maven-plugin' artifact sourceJar { classifier "sources" } + CorrectShadowPublishing.configure(publication, project) + pom.withXml { Node root = asNode() @@ -81,7 +116,7 @@ publishing { ''') root.children().find { - return ((QName) it.name()).qualifiedName == "dependencies" + return it.name() == "dependencies" }.append(dependency) def profiles = new XmlParser().parseText(''' @@ -115,15 +150,9 @@ publishing { root.append(profiles) } - project.shadow.component(publication) - } - } -} - -tasks.withType(GenerateMavenPom) { Task generatePom -> - generatePom.doLast { + } } } -bintrayPublication(project, ['dokkaMavenPlugin'])
\ No newline at end of file +bintrayPublication(project, ['dokkaMavenPlugin']) |