From caf48e76f3bff5e9907cd094cf0719f623e528d5 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 8 Jul 2020 10:47:05 +0200 Subject: Implement simple MavenIntegrationTest.kt --- integration-tests/maven/build.gradle.kts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 integration-tests/maven/build.gradle.kts (limited to 'integration-tests/maven/build.gradle.kts') diff --git a/integration-tests/maven/build.gradle.kts b/integration-tests/maven/build.gradle.kts new file mode 100644 index 00000000..b0187b13 --- /dev/null +++ b/integration-tests/maven/build.gradle.kts @@ -0,0 +1,17 @@ +import org.jetbrains.dependsOnMavenLocalPublication + +evaluationDependsOn(":runners:maven-plugin") + +dependencies { + implementation(kotlin("stdlib")) + implementation(kotlin("test-junit")) +} + +tasks.integrationTest { + dependsOnMavenLocalPublication() + dependsOn(":runners:maven-plugin:setupMaven") + + val dokka_version: String by project + environment("DOKKA_VERSION", dokka_version) + environment("MVN_BINARY_PATH", project(":runners:maven-plugin").extra["MVN_BINARY_PATH"].toString()) +} -- cgit From 4f9e180a1f9e9e0432bf1aed379c024736623d12 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 8 Jul 2020 12:15:30 +0200 Subject: Implement SetupMaven task --- .../src/main/kotlin/org/jetbrains/SetupMaven.kt | 49 +++++++++++++++++ integration-tests/maven/build.gradle.kts | 7 ++- runners/maven-plugin/build.gradle.kts | 63 ++++++++-------------- 3 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt (limited to 'integration-tests/maven/build.gradle.kts') 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().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") 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("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("", "$mavenVersion") + line.replace("", "${setupMaven.mavenVersion}") } filter { line -> line.replace("dokka_version", "$dokka_version") } filter { line -> - line.replace("maven-plugin-plugin", "$mavenPluginToolsVersion") + line.replace("maven-plugin-plugin", "${setupMaven.mavenPluginToolsVersion}") } } } @@ -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") { 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 }) -- cgit