diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-07-17 16:36:09 +0200 |
---|---|---|
committer | Paweł Marks <pmarks@virtuslab.com> | 2020-07-17 16:36:09 +0200 |
commit | 6996b1135f61c7d2cb60b0652c6a2691dda31990 (patch) | |
tree | d568096c25e31c28d14d518a63458b5a7526b896 /runners/maven-plugin/build.gradle.kts | |
parent | de56cab76f556e5b4af0b8c8cb08d8b482b86d0a (diff) | |
parent | 1c3530dcbb50c347f80bef694829dbefe89eca77 (diff) | |
download | dokka-6996b1135f61c7d2cb60b0652c6a2691dda31990.tar.gz dokka-6996b1135f61c7d2cb60b0652c6a2691dda31990.tar.bz2 dokka-6996b1135f61c7d2cb60b0652c6a2691dda31990.zip |
Merge branch 'dev-0.11.0'
Diffstat (limited to 'runners/maven-plugin/build.gradle.kts')
-rw-r--r-- | runners/maven-plugin/build.gradle.kts | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/runners/maven-plugin/build.gradle.kts b/runners/maven-plugin/build.gradle.kts new file mode 100644 index 00000000..fbd2b48a --- /dev/null +++ b/runners/maven-plugin/build.gradle.kts @@ -0,0 +1,98 @@ +import org.jetbrains.CrossPlatformExec +import org.jetbrains.SetupMaven +import org.jetbrains.registerDokkaArtifactPublication + +val setupMaven by tasks.register<SetupMaven>("setupMaven") + +dependencies { + implementation(project(":core")) + implementation("org.apache.maven:maven-core:${setupMaven.mavenVersion}") + implementation("org.apache.maven:maven-plugin-api:${setupMaven.mavenVersion}") + implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:${setupMaven.mavenPluginToolsVersion}") + implementation("org.apache.maven:maven-archiver:2.5") + implementation(kotlin("stdlib-jdk8")) + implementation("org.eclipse.aether:aether-api:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-spi:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-impl:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-connector-basic:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-transport-file:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-transport-http:${setupMaven.aetherVersion}") + implementation("org.apache.maven:maven-aether-provider:3.3.3") +} + +tasks.named<Delete>("clean") { + delete(setupMaven.mavenBuildDir) + delete(setupMaven.mavenBinDir) +} + +/** + * Generate pom.xml for Maven Plugin Plugin + */ +val generatePom by tasks.registering(Copy::class) { + val dokka_version: String by project + inputs.property("dokka_version", dokka_version) + + from("$projectDir/pom.tpl.xml") { + rename("(.*).tpl.xml", "$1.xml") + } + into(setupMaven.mavenBuildDir) + + eachFile { + filter { line -> + line.replace("<maven.version></maven.version>", "<maven.version>${setupMaven.mavenVersion}</maven.version>") + } + filter { line -> + line.replace("<version>dokka_version</version>", "<version>$dokka_version</version>") + } + filter { line -> + line.replace( + "<version>maven-plugin-plugin</version>", + "<version>${setupMaven.mavenPluginToolsVersion}</version>" + ) + } + } +} + +/** + * Copy compiled classes to [mavenBuildDir] for Maven Plugin Plugin + */ +val syncClasses by tasks.registering(Sync::class) { + dependsOn(tasks.compileKotlin, tasks.compileJava) + from("$buildDir/classes/kotlin", "$buildDir/classes/java") + into("${setupMaven.mavenBuildDir}/classes/java") + + preserve { + include("**/*.class") + } +} + +val helpMojo by tasks.registering(CrossPlatformExec::class) { + dependsOn(setupMaven, generatePom, syncClasses) + workingDir(setupMaven.mavenBuildDir) + commandLine(setupMaven.mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:helpmojo") +} + +val pluginDescriptor by tasks.registering(CrossPlatformExec::class) { + dependsOn(setupMaven, generatePom, syncClasses) + workingDir(setupMaven.mavenBuildDir) + commandLine(setupMaven.mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:descriptor") +} + +val sourceJar by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) +} + +tasks.named<Jar>("jar") { + dependsOn(pluginDescriptor, helpMojo) + metaInf { + from("${setupMaven.mavenBuildDir}/classes/java/main/META-INF") + } + manifest { + attributes("Class-Path" to configurations.runtimeClasspath.get().files.joinToString(" ") { it.name }) + } +} + +registerDokkaArtifactPublication("dokkaMavenPlugin") { + artifactId = "dokka-maven-plugin" +} |