aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-08 12:15:30 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-08 18:59:57 +0200
commit4f9e180a1f9e9e0432bf1aed379c024736623d12 (patch)
treed6f3bba272a38a4c52ae60f90a8c9a74bb1ace5f
parentcaf48e76f3bff5e9907cd094cf0719f623e528d5 (diff)
downloaddokka-4f9e180a1f9e9e0432bf1aed379c024736623d12.tar.gz
dokka-4f9e180a1f9e9e0432bf1aed379c024736623d12.tar.bz2
dokka-4f9e180a1f9e9e0432bf1aed379c024736623d12.zip
Implement SetupMaven task
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt49
-rw-r--r--integration-tests/maven/build.gradle.kts7
-rw-r--r--runners/maven-plugin/build.gradle.kts63
3 files changed, 76 insertions, 43 deletions
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt b/buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt
new file mode 100644
index 00000000..519eea13
--- /dev/null
+++ b/buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt
@@ -0,0 +1,49 @@
+package org.jetbrains
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.artifacts.Configuration
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.Internal
+import org.gradle.api.tasks.Sync
+import org.gradle.kotlin.dsl.creating
+import org.gradle.kotlin.dsl.dependencies
+import org.gradle.kotlin.dsl.getValue
+import java.io.File
+
+@Suppress("LeakingThis")
+open class SetupMaven : Sync() {
+ @get:Input
+ var mavenVersion = "3.5.0"
+
+ @get:Input
+ var mavenPluginToolsVersion = "3.5.2"
+
+ @get:Input
+ var aetherVersion = "1.1.0"
+
+ @get:Internal
+ val mavenBuildDir = "${project.buildDir}/maven"
+
+ @get:Internal
+ val mavenBinDir = "${project.buildDir}/maven-bin"
+
+ @get:Internal
+ val mvn = File(mavenBinDir, "apache-maven-$mavenVersion/bin/mvn")
+
+ private val mavenBinaryConfiguration: Configuration by project.configurations.creating {
+ project.dependencies {
+ this@creating.invoke(
+ group = "org.apache.maven",
+ name = "apache-maven",
+ version = mavenVersion,
+ classifier = "bin", ext = "zip"
+ )
+ }
+ }
+
+ init {
+ from(mavenBinaryConfiguration.map { file -> project.zipTree(file) })
+ into(mavenBinDir)
+ }
+
+}
diff --git a/integration-tests/maven/build.gradle.kts b/integration-tests/maven/build.gradle.kts
index b0187b13..1c747bbc 100644
--- a/integration-tests/maven/build.gradle.kts
+++ b/integration-tests/maven/build.gradle.kts
@@ -1,3 +1,4 @@
+import org.jetbrains.SetupMaven
import org.jetbrains.dependsOnMavenLocalPublication
evaluationDependsOn(":runners:maven-plugin")
@@ -9,9 +10,11 @@ dependencies {
tasks.integrationTest {
dependsOnMavenLocalPublication()
- dependsOn(":runners:maven-plugin:setupMaven")
+
+ val setupMavenTask = project(":runners:maven-plugin").tasks.withType<SetupMaven>().single()
+ dependsOn(setupMavenTask)
val dokka_version: String by project
environment("DOKKA_VERSION", dokka_version)
- environment("MVN_BINARY_PATH", project(":runners:maven-plugin").extra["MVN_BINARY_PATH"].toString())
+ environment("MVN_BINARY_PATH", setupMavenTask.mvn.absolutePath)
}
diff --git a/runners/maven-plugin/build.gradle.kts b/runners/maven-plugin/build.gradle.kts
index 8e412b43..6214da6d 100644
--- a/runners/maven-plugin/build.gradle.kts
+++ b/runners/maven-plugin/build.gradle.kts
@@ -1,48 +1,29 @@
import org.jetbrains.configureBintrayPublication
import org.jetbrains.CrossPlatformExec
+import org.jetbrains.SetupMaven
-/**
- * [mavenBin] configuration is used to download Maven Plugin Plugin
- * for generating plugin-help.xml and plugin.xml files
- */
-val mavenBin: Configuration by configurations.creating
-val mavenVersion = "3.5.0"
-val mavenPluginToolsVersion = "3.5.2"
-val aetherVersion = "1.1.0"
+val setupMaven by tasks.register<SetupMaven>("setupMaven")
dependencies {
implementation(project(":core"))
- implementation("org.apache.maven:maven-core:$mavenVersion")
- implementation("org.apache.maven:maven-plugin-api:$mavenVersion")
- implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:$mavenPluginToolsVersion")
+ 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:${aetherVersion}")
- implementation("org.eclipse.aether:aether-spi:${aetherVersion}")
- implementation("org.eclipse.aether:aether-impl:${aetherVersion}")
- implementation("org.eclipse.aether:aether-connector-basic:${aetherVersion}")
- implementation("org.eclipse.aether:aether-transport-file:${aetherVersion}")
- implementation("org.eclipse.aether:aether-transport-http:${aetherVersion}")
+ 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")
- mavenBin(group = "org.apache.maven", name = "apache-maven", version = mavenVersion, classifier = "bin", ext = "zip")
}
-val mavenBinDir = "$buildDir/maven-bin"
-val mavenBuildDir = "$buildDir/maven"
-val mvn = File(mavenBinDir, "apache-maven-$mavenVersion/bin/mvn")
-extra.set("MVN_BINARY_PATH", mvn.absolutePath)
-
tasks.named<Delete>("clean") {
- delete(mavenBinDir)
-}
-
-/**
- * Copy Maven Plugin Plugin to [mavenBinDir] directory
- */
-val setupMaven by tasks.registering(Sync::class) {
- from(mavenBin.map { zipTree(it) })
- into(mavenBinDir)
+ delete(setupMaven.mavenBuildDir)
+ delete(setupMaven.mavenBinDir)
}
/**
@@ -55,17 +36,17 @@ val generatePom by tasks.registering(Copy::class) {
from("$projectDir/pom.tpl.xml") {
rename("(.*).tpl.xml", "$1.xml")
}
- into(mavenBuildDir)
+ into(setupMaven.mavenBuildDir)
eachFile {
filter { line ->
- line.replace("<maven.version></maven.version>", "<maven.version>$mavenVersion</maven.version>")
+ 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>$mavenPluginToolsVersion</version>")
+ line.replace("<version>maven-plugin-plugin</version>", "<version>${setupMaven.mavenPluginToolsVersion}</version>")
}
}
}
@@ -76,7 +57,7 @@ val generatePom by tasks.registering(Copy::class) {
val syncClasses by tasks.registering(Sync::class) {
dependsOn(tasks.compileKotlin, tasks.compileJava)
from("$buildDir/classes/kotlin", "$buildDir/classes/java")
- into("$mavenBuildDir/classes/java")
+ into("${setupMaven.mavenBuildDir}/classes/java")
preserve {
include("**/*.class")
@@ -85,14 +66,14 @@ val syncClasses by tasks.registering(Sync::class) {
val helpMojo by tasks.registering(CrossPlatformExec::class) {
dependsOn(setupMaven, generatePom, syncClasses)
- workingDir(mavenBuildDir)
- commandLine(mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:helpmojo")
+ 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(mavenBuildDir)
- commandLine(mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:descriptor")
+ workingDir(setupMaven.mavenBuildDir)
+ commandLine(setupMaven.mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:descriptor")
}
val sourceJar by tasks.registering(Jar::class) {
@@ -103,7 +84,7 @@ val sourceJar by tasks.registering(Jar::class) {
tasks.named<Jar>("jar") {
dependsOn(pluginDescriptor, helpMojo)
metaInf {
- from("$mavenBuildDir/classes/java/main/META-INF")
+ from("${setupMaven.mavenBuildDir}/classes/java/main/META-INF")
}
manifest {
attributes("Class-Path" to configurations.runtimeClasspath.get().files.joinToString(" ") { it.name })