diff options
Diffstat (limited to 'runners/maven-plugin')
-rw-r--r-- | runners/maven-plugin/build.gradle | 161 | ||||
-rw-r--r-- | runners/maven-plugin/build.gradle.kts | 98 | ||||
-rw-r--r-- | runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 258 | ||||
-rw-r--r-- | runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt | 23 |
4 files changed, 299 insertions, 241 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..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" +} diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index 1cbe39f3..514df151 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -3,15 +3,32 @@ package org.jetbrains.dokka.maven import org.apache.maven.archiver.MavenArchiveConfiguration import org.apache.maven.archiver.MavenArchiver import org.apache.maven.execution.MavenSession +import org.apache.maven.model.Dependency import org.apache.maven.plugin.AbstractMojo import org.apache.maven.plugin.MojoExecutionException import org.apache.maven.plugins.annotations.* import org.apache.maven.project.MavenProject import org.apache.maven.project.MavenProjectHelper +import org.apache.maven.repository.internal.MavenRepositorySystemUtils import org.codehaus.plexus.archiver.Archiver import org.codehaus.plexus.archiver.jar.JarArchiver +import org.eclipse.aether.DefaultRepositorySystemSession +import org.eclipse.aether.RepositorySystem +import org.eclipse.aether.RepositorySystemSession +import org.eclipse.aether.artifact.DefaultArtifact +import org.eclipse.aether.collection.CollectRequest +import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory +import org.eclipse.aether.graph.DependencyNode +import org.eclipse.aether.impl.DefaultServiceLocator +import org.eclipse.aether.repository.LocalRepository +import org.eclipse.aether.repository.RemoteRepository +import org.eclipse.aether.resolution.DependencyRequest +import org.eclipse.aether.spi.connector.RepositoryConnectorFactory +import org.eclipse.aether.spi.connector.transport.TransporterFactory +import org.eclipse.aether.transport.file.FileTransporterFactory +import org.eclipse.aether.transport.http.HttpTransporterFactory +import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator import org.jetbrains.dokka.* -import org.jetbrains.dokka.Utilities.defaultLinks import java.io.File import java.net.URL @@ -30,36 +47,47 @@ class ExternalDocumentationLinkBuilder : DokkaConfiguration.ExternalDocumentatio @Parameter(name = "url", required = true) override var url: URL? = null + @Parameter(name = "packageListUrl", required = true) override var packageListUrl: URL? = null } -abstract class AbstractDokkaMojo : AbstractMojo() { +abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List<Dependency>) : AbstractMojo() { class SourceRoot : DokkaConfiguration.SourceRoot { @Parameter(required = true) override var path: String = "" } + @Parameter(defaultValue = "\${project}", readonly = true) + private var mavenProject: MavenProject? = null + + @Parameter() + private var session: RepositorySystemSession? = null + class PackageOptions : DokkaConfiguration.PackageOptions { @Parameter override var prefix: String = "" + @Parameter - override var includeNonPublic: Boolean = false + override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + @Parameter - override var reportUndocumented: Boolean = true + override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + @Parameter - override var skipDeprecated: Boolean = false + override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + @Parameter - override var suppress: Boolean = false + override var suppress: Boolean = DokkaDefaults.suppress } + @Parameter + var sourceSetName: String = "JVM" + @Parameter(required = true, defaultValue = "\${project.compileSourceRoots}") var sourceDirectories: List<String> = emptyList() @Parameter - var sourceRoots: List<SourceRoot> = emptyList() - - @Parameter var samples: List<String> = emptyList() @Parameter @@ -74,18 +102,23 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter(required = true, defaultValue = "\${project.artifactId}") var moduleName: String = "" + @Parameter + var moduleDisplayName: String = "" + @Parameter(required = false, defaultValue = "false") var skip: Boolean = false - @Parameter(required = false, defaultValue = "6") - var jdkVersion: Int = 6 + @Parameter(required = false, defaultValue = "${DokkaDefaults.jdkVersion}") + var jdkVersion: Int = DokkaDefaults.jdkVersion @Parameter - var skipDeprecated: Boolean = false + var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + @Parameter - var skipEmptyPackages: Boolean = true + var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages + @Parameter - var reportUndocumented: Boolean = true + var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented @Parameter var impliedPlatforms: List<String> = emptyList() @@ -96,15 +129,21 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter var externalDocumentationLinks: List<ExternalDocumentationLinkBuilder> = emptyList() - @Parameter(defaultValue = "false") - var noStdlibLink: Boolean = false + @Parameter(defaultValue = "${DokkaDefaults.noStdlibLink}") + var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink - @Parameter(defaultValue = "false") - var noJdkLink: Boolean = false + @Parameter(defaultValue = "${DokkaDefaults.noJdkLink}") + var noJdkLink: Boolean = DokkaDefaults.noJdkLink @Parameter var cacheRoot: String? = null + @Parameter(defaultValue = "JVM") + var displayName: String = "JVM" + + @Parameter(defaultValue = "${DokkaDefaults.offlineMode}") + var offlineMode: Boolean = DokkaDefaults.offlineMode + @Parameter var languageVersion: String? = null @@ -112,33 +151,26 @@ abstract class AbstractDokkaMojo : AbstractMojo() { var apiVersion: String? = null @Parameter - var includeRootPackage: Boolean = false - - @Parameter - var suppressedFiles: List<String> = emptyList() + var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage @Parameter - var collectInheritedExtensionsFromLibraries: Boolean = false + var suppressedFiles: List<String> = emptyList() @Parameter var platform: String = "" @Parameter - var targets: List<String> = emptyList() + var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic @Parameter - var sinceKotlin: String? = null + var failOnWarning: Boolean = DokkaDefaults.failOnWarning @Parameter - var includeNonPublic: Boolean = false - - @Parameter - var generateIndexPages: Boolean = false + var dokkaPlugins: List<Dependency> = emptyList() + get() = field + defaultDokkaPlugins protected abstract fun getOutDir(): String - protected abstract fun getOutFormat(): String - override fun execute() { if (skip) { log.info("Dokka skip parameter is true so no dokka output will be produced") @@ -150,18 +182,36 @@ abstract class AbstractDokkaMojo : AbstractMojo() { throw MojoExecutionException("Incorrect path property, only Unix based path allowed.") } } + fun defaultLinks(config: DokkaSourceSetImpl): List<ExternalDocumentationLinkImpl> { + val links = mutableListOf<ExternalDocumentationLinkImpl>() + if (!config.noJdkLink) + links += DokkaConfiguration.ExternalDocumentationLink + .Builder("https://docs.oracle.com/javase/${config.jdkVersion}/docs/api/") + .build() as ExternalDocumentationLinkImpl + + if (!config.noStdlibLink) + links += DokkaConfiguration.ExternalDocumentationLink + .Builder("https://kotlinlang.org/api/latest/jvm/stdlib/") + .build() as ExternalDocumentationLinkImpl + return links + } - val passConfiguration = PassConfigurationImpl( + val sourceSet = DokkaSourceSetImpl( + moduleDisplayName = moduleDisplayName.takeIf(String::isNotBlank) ?: moduleName, + displayName = displayName, + sourceSetID = DokkaSourceSetID(moduleName, sourceSetName), classpath = classpath, - sourceRoots = sourceDirectories.map { SourceRootImpl(it) } + sourceRoots.map { SourceRootImpl(path = it.path) }, + sourceRoots = sourceDirectories.map { SourceRootImpl(it) }, + dependentSourceSets = emptySet(), samples = samples, includes = includes, - collectInheritedExtensionsFromLibraries = collectInheritedExtensionsFromLibraries, // TODO: Should we implement this? - sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.path, it.url, it.lineSuffix) }, - jdkVersion = jdkVersion, - skipDeprecated = skipDeprecated, - skipEmptyPackages = skipEmptyPackages, + includeNonPublic = includeNonPublic, + includeRootPackage = includeRootPackage, reportUndocumented = reportUndocumented, + skipEmptyPackages = skipEmptyPackages, + skipDeprecated = skipDeprecated, + jdkVersion = jdkVersion, + sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.path, it.url, it.lineSuffix) }, perPackageOptions = perPackageOptions.map { PackageOptionsImpl( prefix = it.prefix, @@ -169,61 +219,132 @@ abstract class AbstractDokkaMojo : AbstractMojo() { reportUndocumented = it.reportUndocumented, skipDeprecated = it.skipDeprecated, suppress = it.suppress - )}, + ) + }, externalDocumentationLinks = externalDocumentationLinks.map { it.build() as ExternalDocumentationLinkImpl }, - noStdlibLink = noStdlibLink, - noJdkLink = noJdkLink, languageVersion = languageVersion, apiVersion = apiVersion, - moduleName = moduleName, + noStdlibLink = noStdlibLink, + noJdkLink = noJdkLink, suppressedFiles = suppressedFiles, - sinceKotlin = sinceKotlin, - analysisPlatform = if (platform.isNotEmpty()) Platform.fromString(platform) else Platform.DEFAULT, - targets = targets, - includeNonPublic = includeNonPublic, - includeRootPackage = includeRootPackage - ) + analysisPlatform = if (platform.isNotEmpty()) Platform.fromString(platform) else Platform.DEFAULT + ).let { + it.copy( + externalDocumentationLinks = defaultLinks(it) + it.externalDocumentationLinks + ) + } - passConfiguration.externalDocumentationLinks += passConfiguration.defaultLinks() + val logger = MavenDokkaLogger(log) val configuration = DokkaConfigurationImpl( outputDir = getOutDir(), - format = getOutFormat(), - impliedPlatforms = impliedPlatforms, + offlineMode = offlineMode, cacheRoot = cacheRoot, - passesConfigurations = listOf(passConfiguration), - generateIndexPages = generateIndexPages + sourceSets = listOf(sourceSet).also { + if (sourceSet.moduleDisplayName.isEmpty()) logger.warn("Not specified module name. It can result in unexpected behaviour while including documentation for module") + }, + pluginsClasspath = getArtifactByAether("org.jetbrains.dokka", "dokka-base", dokkaVersion) + + dokkaPlugins.map { getArtifactByAether(it.groupId, it.artifactId, it.version ?: dokkaVersion) }.flatten(), + pluginsConfiguration = mutableMapOf(), //TODO implement as it is in Gradle + modules = emptyList(), + failOnWarning = failOnWarning ) - val gen = DokkaGenerator(configuration, MavenDokkaLogger(log)) + val gen = DokkaGenerator(configuration, logger) gen.generate() } -} -@Mojo(name = "dokka", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) -class DokkaMojo : AbstractDokkaMojo() { - @Parameter(required = true, defaultValue = "html") - var outputFormat: String = "html" + private fun newRepositorySystem(): RepositorySystem { + val locator: DefaultServiceLocator = MavenRepositorySystemUtils.newServiceLocator() + locator.addService(RepositoryConnectorFactory::class.java, BasicRepositoryConnectorFactory::class.java) + locator.addService(TransporterFactory::class.java, FileTransporterFactory::class.java) + locator.addService(TransporterFactory::class.java, HttpTransporterFactory::class.java) + return locator.getService(RepositorySystem::class.java) + } + + private fun newSession(system: RepositorySystem): RepositorySystemSession { + val session: DefaultRepositorySystemSession = + MavenRepositorySystemUtils.newSession() + val localRepo = LocalRepository(System.getProperty("user.home") + "/.m2/repository") + session.localRepositoryManager = system.newLocalRepositoryManager(session, localRepo) + return session + } + + private fun getArtifactByAether( + groupId: String, + artifactId: String, + version: String + ): List<File> { + val repoSystem: RepositorySystem = newRepositorySystem() + val session: RepositorySystemSession = newSession(repoSystem) + val dependency = + org.eclipse.aether.graph.Dependency(DefaultArtifact("$groupId:$artifactId:$version"), "compile") + val collectRequest = CollectRequest() + collectRequest.root = dependency + val repositories: List<RemoteRepository> = + (mavenProject?.remoteProjectRepositories?.plus(mavenProject?.remotePluginRepositories ?: emptyList()) + ?: mavenProject?.remotePluginRepositories ?: emptyList()) + repositories.forEach { + collectRequest.addRepository( + RemoteRepository.Builder( + "repo", + "default", + it.url + ).build() + ) + } + val node: DependencyNode = repoSystem.collectDependencies(session, collectRequest).root + val dependencyRequest = DependencyRequest() + dependencyRequest.root = node + repoSystem.resolveDependencies(session, dependencyRequest) + val nlg = PreorderNodeListGenerator() + node.accept(nlg) + return nlg.files + } + + private val dokkaVersion: String by lazy { + mavenProject?.pluginArtifacts?.filter { it.groupId == "org.jetbrains.dokka" && it.artifactId == "dokka-maven-plugin" } + ?.firstOrNull()?.version ?: throw IllegalStateException("Not found dokka plugin") + } +} +@Mojo( + name = "dokka", + defaultPhase = LifecyclePhase.PRE_SITE, + threadSafe = true, + requiresDependencyResolution = ResolutionScope.COMPILE, + requiresProject = true +) +class DokkaMojo : AbstractDokkaMojo(emptyList()) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokka") var outputDir: String = "" - override fun getOutFormat() = outputFormat override fun getOutDir() = outputDir } -@Mojo(name = "javadoc", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) -class DokkaJavadocMojo : AbstractDokkaMojo() { +@Mojo( + name = "javadoc", + defaultPhase = LifecyclePhase.PRE_SITE, + threadSafe = true, + requiresDependencyResolution = ResolutionScope.COMPILE, + requiresProject = true +) +class DokkaJavadocMojo : AbstractDokkaMojo(listOf(javadocDependency)) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokkaJavadoc") var outputDir: String = "" - override fun getOutFormat() = "javadoc" override fun getOutDir() = outputDir } -@Mojo(name = "javadocJar", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) -class DokkaJavadocJarMojo : AbstractDokkaMojo() { +@Mojo( + name = "javadocJar", + defaultPhase = LifecyclePhase.PRE_SITE, + threadSafe = true, + requiresDependencyResolution = ResolutionScope.COMPILE, + requiresProject = true +) +class DokkaJavadocJarMojo : AbstractDokkaMojo(listOf(javadocDependency)) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokkaJavadocJar") var outputDir: String = "" @@ -268,12 +389,11 @@ class DokkaJavadocJarMojo : AbstractDokkaMojo() { @Component(role = Archiver::class, hint = "jar") private var jarArchiver: JarArchiver? = null - override fun getOutFormat() = "javadoc" override fun getOutDir() = outputDir override fun execute() { super.execute() - if(!File(outputDir).exists()) { + if (!File(outputDir).exists()) { log.warn("No javadoc generated so no javadoc jar will be generated") return } @@ -298,3 +418,7 @@ class DokkaJavadocJarMojo : AbstractDokkaMojo() { } } +private val javadocDependency = Dependency().apply { + groupId = "org.jetbrains.dokka" + artifactId = "javadoc-plugin" +} diff --git a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt index a535c807..4b5f4fa9 100644 --- a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt +++ b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt @@ -1,18 +1,15 @@ 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 info(message: String) { - log.info(message) - } - - override fun warn(message: String) { - log.warn(message) - } -}
\ No newline at end of file + override var warningsCount: Int = 0 + override var errorsCount: Int = 0 + + 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).also { warningsCount++ } + override fun error(message: String) = log.error(message).also { errorsCount++ } +} |