aboutsummaryrefslogtreecommitdiff
path: root/runners/maven-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'runners/maven-plugin')
-rw-r--r--runners/maven-plugin/build.gradle161
-rw-r--r--runners/maven-plugin/build.gradle.kts115
-rw-r--r--runners/maven-plugin/src/main/kotlin/DokkaMojo.kt3
-rw-r--r--runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt6
4 files changed, 122 insertions, 163 deletions
diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle
deleted file mode 100644
index 76fab68d..00000000
--- a/runners/maven-plugin/build.gradle
+++ /dev/null
@@ -1,161 +0,0 @@
-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(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
- kotlinOptions {
- freeCompilerArgs += "-Xjsr305=strict"
- languageVersion = "1.2"
- apiVersion = languageVersion
- jvmTarget = "1.8"
- }
-}
-
-configurations {
- maven
-}
-
-dependencies {
- maven group: "org.apache.maven", name: 'apache-maven', version: maven_version, classifier: 'bin', ext: 'zip'
-
- shadow project(":runners:fatjar")
- shadow "org.apache.maven:maven-core:$maven_version"
- shadow "org.apache.maven:maven-model:$maven_version"
- shadow "org.apache.maven:maven-plugin-api:$maven_version"
- shadow "org.apache.maven:maven-archiver:$maven_archiver_version"
- shadow "org.codehaus.plexus:plexus-utils:$plexus_utils_version"
- shadow "org.codehaus.plexus:plexus-archiver:$plexus_archiver_version"
- shadow "org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version"
- shadow "com.github.olivergondza:maven-jdk-tools-wrapper:0.1"
-}
-
-final File mavenHome = new File(buildDir, "maven-bin")
-final File mvn = new File(mavenHome, "apache-maven-$maven_version/bin/mvn")
-
-tasks.clean.doLast {
- delete mavenHome
-}
-
-task setupMaven(type: Sync) {
- from configurations.maven.collect{ zipTree(it) }
- into "$buildDir/maven-bin"
-}
-
-def mavenBuildDir = "$buildDir/maven"
-
-
-sourceSets.main.resources {
- srcDirs += "$mavenBuildDir/classes/java/main"
- exclude "**/*.class"
-}
-
-task generatePom() {
- inputs.file(new File(projectDir, "pom.tpl.xml"))
- outputs.file(new File(mavenBuildDir, "pom.xml"))
- doLast {
- final pomTemplate = new File(projectDir, "pom.tpl.xml")
- final pom = new File(mavenBuildDir, "pom.xml")
- pom.parentFile.mkdirs()
- 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 syncKotlinClasses(type: Sync, dependsOn: compileKotlin) {
- from "$buildDir/classes/kotlin"
- into "$mavenBuildDir/classes/java"
-
- preserve {
- include '**/*.class'
- }
-}
-
-task syncJavaClasses(type: Sync, dependsOn: compileJava) {
- from "$buildDir/classes/java"
- into "$mavenBuildDir/classes/java"
-
- preserve {
- include '**/*.class'
- }
-}
-
-task helpMojo(type: CrossPlatformExec, dependsOn: setupMaven) {
- workingDir mavenBuildDir
- commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:helpmojo'
-
- dependsOn syncKotlinClasses
-}
-
-
-task pluginDescriptor(type: CrossPlatformExec, dependsOn: setupMaven) {
- workingDir mavenBuildDir
- commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:descriptor'
-
- dependsOn syncJavaClasses
-}
-
-
-//mergeClassOutputs.dependsOn compileKotlin
-//helpMojo.dependsOn mergeClassOutputs
-helpMojo.dependsOn generatePom
-sourceSets.main.java.srcDir("$buildDir/maven/generated-sources/plugin")
-compileJava.dependsOn helpMojo
-processResources.dependsOn pluginDescriptor
-
-pluginDescriptor.dependsOn generatePom
-
-shadowJar {
- baseName = 'dokka-maven-plugin'
- classifier = ''
-}
-
-shadowJar.dependsOn pluginDescriptor
-
-
-task sourceJar(type: Jar) {
- from sourceSets.main.allSource
-}
-
-apply plugin: 'maven-publish'
-
-publishing {
- publications {
- dokkaMavenPlugin(MavenPublication) { MavenPublication publication ->
- artifactId = 'dokka-maven-plugin'
-
- artifact sourceJar {
- classifier "sources"
- }
-
- CorrectShadowPublishing.configure(publication, project)
- }
- }
-}
-
-bintrayPublication(project, ['dokkaMavenPlugin'])
diff --git a/runners/maven-plugin/build.gradle.kts b/runners/maven-plugin/build.gradle.kts
new file mode 100644
index 00000000..2dffd71c
--- /dev/null
+++ b/runners/maven-plugin/build.gradle.kts
@@ -0,0 +1,115 @@
+import org.jetbrains.configureBintrayPublication
+
+/**
+ * [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 maven_version: String by project
+
+dependencies {
+ implementation(project(":core"))
+ implementation("org.apache.maven:maven-core:$maven_version")
+ implementation("org.apache.maven:maven-plugin-api:$maven_version")
+ val maven_plugin_tools_version: String by project
+ implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version")
+ val maven_archiver_version: String by project
+ implementation("org.apache.maven:maven-archiver:$maven_archiver_version")
+
+ mavenBin(group = "org.apache.maven", name = "apache-maven", version = maven_version, classifier = "bin", ext = "zip")
+ compileOnly(kotlin("stdlib-jdk8"))
+}
+
+val mavenBinDir = "$buildDir/maven-bin"
+val mavenBuildDir = "$buildDir/maven"
+val mvn = File(mavenBinDir, "apache-maven-$maven_version/bin/mvn")
+
+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)
+}
+
+/**
+ * Generate pom.xml for Maven Plugin Plugin
+ */
+val generatePom by tasks.registering(Copy::class) {
+ val dokka_version: String by project
+ val maven_plugin_tools_version: String by project
+
+ from("$projectDir/pom.tpl.xml") {
+ rename("(.*).tpl.xml", "$1.xml")
+ }
+ into(mavenBuildDir)
+
+ eachFile {
+ filter { line ->
+ line.replace("<maven.version></maven.version>", "<maven.version>$maven_version</maven.version>")
+ }
+ filter { line ->
+ line.replace("<version>dokka_version</version>", "<version>$dokka_version</version>")
+ }
+ filter { line ->
+ line.replace("<version>maven-plugin-plugin</version>", "<version>$maven_plugin_tools_version</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("$mavenBuildDir/classes/java")
+
+ preserve {
+ include("**/*.class")
+ }
+}
+
+val helpMojo by tasks.registering(org.jetbrains.CrossPlatformExec::class) {
+ dependsOn(setupMaven, generatePom, syncClasses)
+ workingDir(mavenBuildDir)
+ commandLine(mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:helpmojo")
+}
+
+val pluginDescriptor by tasks.registering(org.jetbrains.CrossPlatformExec::class) {
+ dependsOn(setupMaven, generatePom, syncClasses)
+ workingDir(mavenBuildDir)
+ commandLine(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("$mavenBuildDir/classes/java/main/META-INF")
+ }
+ manifest {
+ attributes("Class-Path" to configurations.runtimeClasspath.get().files.joinToString(" ") { it.name })
+ }
+}
+
+publishing {
+ publications {
+ register<MavenPublication>("dokkaMavenPlugin") {
+ artifactId = "dokka-maven-plugin"
+ from(components["java"])
+ artifact(sourceJar.get())
+ }
+ }
+}
+
+configureBintrayPublication("dokkaMavenPlugin")
diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
index fb11ecac..67188325 100644
--- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
+++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
@@ -189,7 +189,8 @@ abstract class AbstractDokkaMojo : AbstractMojo() {
impliedPlatforms = impliedPlatforms,
cacheRoot = cacheRoot,
passesConfigurations = listOf(passConfiguration),
- generateIndexPages = generateIndexPages
+ generateIndexPages = generateIndexPages,
+ pluginsClasspath = emptyList() //TODO fix this
)
val gen = DokkaGenerator(configuration, MavenDokkaLogger(log))
diff --git a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt
index a535c807..950af3e0 100644
--- a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt
+++ b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt
@@ -1,17 +1,21 @@
package org.jetbrains.dokka.maven
import org.apache.maven.plugin.logging.Log
-import org.jetbrains.dokka.DokkaLogger
+import org.jetbrains.dokka.utilities.DokkaLogger
class MavenDokkaLogger(val log: Log) : DokkaLogger {
override fun error(message: String) {
log.error(message)
}
+ override fun debug(message: String) = log.debug(message)
+
override fun info(message: String) {
log.info(message)
}
+ override fun progress(message: String) = log.info(message)
+
override fun warn(message: String) {
log.warn(message)
}