aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSimon Ogorodnik <sem-oro@yandex.ru>2016-11-01 02:10:32 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-01 14:46:01 +0300
commit769701f99a1aefbc9d385c1938c9c7d3a7b2e38e (patch)
treec3ea4802d9e627c90870808aba9343eb224a114c /core
parent08bcaa257f7b48929af6ee29007dd6f0d7bb1b52 (diff)
downloaddokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.tar.gz
dokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.tar.bz2
dokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.zip
Total build refactoring, prepare for new development iteration
Removed old and useless build helpers Remove old .xml's from .idea and add .idea/shelf to .gitignore build-docs.xml fixed, dokka_version set to 0.9.10
Diffstat (limited to 'core')
-rw-r--r--core/build.gradle165
-rwxr-xr-xcore/gradlew164
-rw-r--r--core/gradlew.bat90
-rw-r--r--core/settings.gradle1
-rw-r--r--core/src/main/kotlin/Generation/DokkaGenerator.kt (renamed from core/src/main/kotlin/main.kt)141
-rw-r--r--core/src/main/kotlin/Utilities/DokkaLogging.kt27
-rw-r--r--core/src/main/kotlin/ant/dokka.kt101
7 files changed, 55 insertions, 634 deletions
diff --git a/core/build.gradle b/core/build.gradle
index c66fc5a1..f5822725 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -1,26 +1,12 @@
-import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator
-import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
-import groovy.xml.XmlUtil
-import org.apache.tools.zip.ZipEntry
-import org.apache.tools.zip.ZipOutputStream
-
import javax.tools.ToolProvider
-group 'org.jetbrains.dokka'
-version dokka_version
-
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}
-apply plugin: 'java'
apply plugin: 'kotlin'
-apply plugin: 'com.github.johnrengelman.shadow'
-apply plugin: 'maven-publish'
-apply plugin: 'com.jfrog.bintray'
sourceCompatibility = 1.5
@@ -28,23 +14,27 @@ configurations {
provided
}
-dependencies {
- compile "com.google.inject:guice:4.1.0"
- compile "com.github.spullara.cli-parser:cli-parser:1.1.1"
- compile "org.jsoup:jsoup:1.8.3"
- compile "org.apache.ant:ant:1.9.6"
+tasks.withType(AbstractCompile) {
+ classpath += configurations.provided
+}
+tasks.withType(Test) {
+ classpath += configurations.provided
+}
+
+dependencies {
compile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: kotlin_version
compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version
+ compile "com.google.inject:guice:4.1.0"
+ compile "org.jsoup:jsoup:1.8.3"
+
compile files("../lib/intellij-core-analysis.jar")
compile files("../lib/kotlin-compiler.jar")
compile files("../lib/kotlin-ide-common.jar")
compile files("../lib/markdown.jar")
compile files("../lib/picocontainer.jar")
- provided files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs().findAll { it.path.endsWith("jar") })
-
runtime "org.fusesource.jansi:jansi:1.11"
runtime files("../lib/trove4j.jar")
@@ -53,137 +43,10 @@ dependencies {
runtime files("../lib/asm-all.jar")
runtime files("../lib/jps-model.jar")
+ //tools.jar
+ provided files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs().findAll { it.path.endsWith("jar") })
+
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_version
}
-tasks.withType(AbstractCompile) {
- classpath += configurations.provided
-}
-
-tasks.withType(Test) {
- classpath += configurations.provided
-}
-
-jar {
- manifest {
- attributes "Implementation-Title": "Dokka Kotlin Documentation tool"
- attributes "Implementation-Version": version
- attributes "Main-Class": "org.jetbrains.dokka.MainKt"
- }
-}
-
-class PluginXmlTransformer implements com.github.jengelman.gradle.plugins.shadow.transformers.Transformer {
- private Map<String, Node> transformedPluginXmlFiles = new HashMap<>();
-
- @Override
- boolean canTransformResource(FileTreeElement fileTreeElement) {
- return fileTreeElement.relativePath.segments.contains("META-INF") && fileTreeElement.name.endsWith(".xml")
- }
-
- @Override
- void transform(String path, InputStream inputStream, List<Relocator> relocators) {
- Node node = new XmlParser().parse(inputStream)
- relocateXml(node, relocators)
- transformedPluginXmlFiles.put(path, node)
- }
-
- @Override
- boolean hasTransformedResource() {
- return !transformedPluginXmlFiles.isEmpty()
- }
-
- @Override
- void modifyOutputStream(ZipOutputStream zipOutputStream) {
- for (Map.Entry<String, Node> entry : transformedPluginXmlFiles.entrySet()) {
- zipOutputStream.putNextEntry(new ZipEntry(entry.key))
- XmlUtil.serialize(entry.value, zipOutputStream)
- }
- }
-
- private static void relocateXml(Node node, List<Relocator> relocators) {
- Map attributes = node.attributes()
- for (Map.Entry entry : attributes.entrySet()) {
- entry.setValue(relocateClassName((String) entry.getValue(), relocators))
- }
- List<String> localText = node.localText()
- if (localText.size() == 1) {
- node.setValue(relocateClassName(localText[0], relocators))
- }
- node.children().each {
- if (it instanceof Node) {
- relocateXml((Node) it, relocators)
- }
- }
- }
-
- private static String relocateClassName(String className, List<Relocator> relocators) {
- for (Relocator relocator : relocators) {
- if (relocator.canRelocateClass(className)) {
- return relocator.relocateClass(className)
- }
- }
- return className
- }
-}
-
-shadowJar {
- baseName = 'dokka-fatjar'
- classifier = ''
-
- dependencies {
- exclude(dependency('org.apache.ant:ant:1.9.6'))
- exclude(dependency('org.apache.ant:ant-launcher:1.9.6'))
- }
-
- relocate('com.', 'dokkacom.') {
- exclude 'com.sun.**'
- }
-
- relocate('org.', 'dokkaorg.') {
- exclude 'org.jetbrains.dokka.**'
- exclude 'org.xml.**'
- exclude 'org.w3c.**'
- exclude 'org.jaxen.**'
- exclude 'org.apache.xerces.**'
- exclude 'org.apache.xml.**'
- exclude 'org.fusesource.jansi.**'
- exclude 'org.apache.tools.ant.**'
- }
-
- transform(ServiceFileTransformer)
- transform(PluginXmlTransformer)
-
- exclude 'colorScheme/**'
- exclude 'fileTemplates/**'
- exclude 'inspectionDescriptions/**'
- exclude 'intentionDescriptions/**'
-}
-
-publishing {
- publications {
- shadow(MavenPublication) {
- from components.shadow
- artifactId = 'dokka-fatjar'
- }
- }
-}
-
-bintray {
- user = System.getenv('BINTRAY_USER')
- key = System.getenv('BINTRAY_KEY')
-
- pkg {
- repo = dokka_eap.toBoolean() ? 'kotlin-eap' : 'dokka'
- name = 'dokka'
- userOrg = 'kotlin'
- desc = 'Dokka, the Kotlin documentation tool'
- vcsUrl = 'https://github.com/kotlin/dokka.git'
- licenses = ['Apache-2.0']
- version {
- name = dokka_version
- }
- }
-
- publications = ['shadow']
-}
diff --git a/core/gradlew b/core/gradlew
deleted file mode 100755
index 91a7e269..00000000
--- a/core/gradlew
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/core/gradlew.bat b/core/gradlew.bat
deleted file mode 100644
index 8a0b282a..00000000
--- a/core/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/core/settings.gradle b/core/settings.gradle
index 17bdad4c..8b137891 100644
--- a/core/settings.gradle
+++ b/core/settings.gradle
@@ -1,2 +1 @@
-rootProject.name = 'core'
diff --git a/core/src/main/kotlin/main.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index 22859187..8d846904 100644
--- a/core/src/main/kotlin/main.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -7,10 +7,8 @@ import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
-import com.sampullara.cli.Args
-import com.sampullara.cli.Argument
+import org.jetbrains.dokka.*
import org.jetbrains.dokka.Utilities.DokkaModule
-import org.jetbrains.kotlin.cli.common.arguments.ValueDescription
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -24,130 +22,6 @@ import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
import kotlin.system.measureTimeMillis
-class DokkaArguments {
- @set:Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)")
- @ValueDescription("<path>")
- var src: String = ""
-
- @set:Argument(value = "srcLink", description = "Mapping between a source directory and a Web site for browsing the code")
- @ValueDescription("<path>=<url>[#lineSuffix]")
- var srcLink: String = ""
-
- @set:Argument(value = "include", description = "Markdown files to load (allows many paths separated by the system path separator)")
- @ValueDescription("<path>")
- var include: String = ""
-
- @set:Argument(value = "samples", description = "Source root for samples")
- @ValueDescription("<path>")
- var samples: String = ""
-
- @set:Argument(value = "output", description = "Output directory path")
- @ValueDescription("<path>")
- var outputDir: String = "out/doc/"
-
- @set:Argument(value = "format", description = "Output format (text, html, markdown, jekyll, kotlin-website)")
- @ValueDescription("<name>")
- var outputFormat: String = "html"
-
- @set:Argument(value = "module", description = "Name of the documentation module")
- @ValueDescription("<name>")
- var moduleName: String = ""
-
- @set:Argument(value = "classpath", description = "Classpath for symbol resolution")
- @ValueDescription("<path>")
- var classpath: String = ""
-
- @set:Argument(value = "nodeprecated", description = "Exclude deprecated members from documentation")
- var nodeprecated: Boolean = false
-
- @set:Argument(value = "jdkVersion", description = "Version of JDK to use for linking to JDK JavaDoc")
- var jdkVersion: Int = 6
-}
-
-private fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition {
- val (path, urlAndLine) = srcLink.split('=')
- return SourceLinkDefinition(File(path).absolutePath,
- urlAndLine.substringBefore("#"),
- urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#" + it })
-}
-
-fun main(args: Array<String>) {
- val arguments = DokkaArguments()
- val freeArgs: List<String> = Args.parse(arguments, args, false) ?: listOf()
- val sources = if (arguments.src.isNotEmpty()) arguments.src.split(File.pathSeparatorChar).toList() + freeArgs else freeArgs
- val samples = if (arguments.samples.isNotEmpty()) arguments.samples.split(File.pathSeparatorChar).toList() else listOf()
- val includes = if (arguments.include.isNotEmpty()) arguments.include.split(File.pathSeparatorChar).toList() else listOf()
-
- val sourceLinks = if (arguments.srcLink.isNotEmpty() && arguments.srcLink.contains("="))
- listOf(parseSourceLinkDefinition(arguments.srcLink))
- else {
- if (arguments.srcLink.isNotEmpty()) {
- println("Warning: Invalid -srcLink syntax. Expected: <path>=<url>[#lineSuffix]. No source links will be generated.")
- }
- listOf()
- }
-
- val classPath = arguments.classpath.split(File.pathSeparatorChar).toList()
-
- val documentationOptions = DocumentationOptions(
- arguments.outputDir.let { if (it.endsWith('/')) it else it + '/' },
- arguments.outputFormat,
- skipDeprecated = arguments.nodeprecated,
- sourceLinks = sourceLinks
- )
-
- val generator = DokkaGenerator(
- DokkaConsoleLogger,
- classPath,
- sources,
- samples,
- includes,
- arguments.moduleName,
- documentationOptions)
-
- generator.generate()
- DokkaConsoleLogger.report()
-}
-
-interface DokkaLogger {
- fun info(message: String)
- fun warn(message: String)
- fun error(message: String)
-}
-
-object DokkaConsoleLogger: DokkaLogger {
- var warningCount: Int = 0
-
- override fun info(message: String) = println(message)
- override fun warn(message: String) {
- println("WARN: $message")
- warningCount++
- }
-
- override fun error(message: String) = println("ERROR: $message")
-
- fun report() {
- if (warningCount > 0) {
- println("generation completed with $warningCount warnings")
- } else {
- println("generation completed successfully")
- }
- }
-}
-
-class DokkaMessageCollector(val logger: DokkaLogger): MessageCollector {
- private var seenErrors = false
-
- override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
- if (severity == CompilerMessageSeverity.ERROR) {
- seenErrors = true
- }
- logger.error(MessageRenderer.PLAIN_FULL_PATHS.render(severity, message, location))
- }
-
- override fun hasErrors() = seenErrors
-}
-
class DokkaGenerator(val logger: DokkaLogger,
val classpath: List<String>,
val sources: List<String>,
@@ -209,6 +83,19 @@ class DokkaGenerator(val logger: DokkaLogger,
}
}
+class DokkaMessageCollector(val logger: DokkaLogger): MessageCollector {
+ private var seenErrors = false
+
+ override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
+ if (severity == CompilerMessageSeverity.ERROR) {
+ seenErrors = true
+ }
+ logger.error(MessageRenderer.PLAIN_FULL_PATHS.render(severity, message, location))
+ }
+
+ override fun hasErrors() = seenErrors
+}
+
fun buildDocumentationModule(injector: Injector,
moduleName: String,
filesToDocumentFilter: (PsiFile) -> Boolean = { file -> true },
diff --git a/core/src/main/kotlin/Utilities/DokkaLogging.kt b/core/src/main/kotlin/Utilities/DokkaLogging.kt
new file mode 100644
index 00000000..1ef52837
--- /dev/null
+++ b/core/src/main/kotlin/Utilities/DokkaLogging.kt
@@ -0,0 +1,27 @@
+package org.jetbrains.dokka
+
+interface DokkaLogger {
+ fun info(message: String)
+ fun warn(message: String)
+ fun error(message: String)
+}
+
+object DokkaConsoleLogger : DokkaLogger {
+ var warningCount: Int = 0
+
+ override fun info(message: String) = println(message)
+ override fun warn(message: String) {
+ println("WARN: $message")
+ warningCount++
+ }
+
+ override fun error(message: String) = println("ERROR: $message")
+
+ fun report() {
+ if (warningCount > 0) {
+ println("generation completed with $warningCount warnings")
+ } else {
+ println("generation completed successfully")
+ }
+ }
+}
diff --git a/core/src/main/kotlin/ant/dokka.kt b/core/src/main/kotlin/ant/dokka.kt
deleted file mode 100644
index 38dc543b..00000000
--- a/core/src/main/kotlin/ant/dokka.kt
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.jetbrains.dokka.ant
-
-import org.apache.tools.ant.BuildException
-import org.apache.tools.ant.Project
-import org.apache.tools.ant.Task
-import org.apache.tools.ant.types.Path
-import org.apache.tools.ant.types.Reference
-import org.jetbrains.dokka.DocumentationOptions
-import org.jetbrains.dokka.DokkaGenerator
-import org.jetbrains.dokka.DokkaLogger
-import org.jetbrains.dokka.SourceLinkDefinition
-import java.io.File
-
-class AntLogger(val task: Task): DokkaLogger {
- override fun info(message: String) = task.log(message, Project.MSG_INFO)
- override fun warn(message: String) = task.log(message, Project.MSG_WARN)
- override fun error(message: String) = task.log(message, Project.MSG_ERR)
-}
-
-class AntSourceLinkDefinition(var path: String? = null, var url: String? = null, var lineSuffix: String? = null)
-
-class DokkaAntTask(): Task() {
- var moduleName: String? = null
- var outputDir: String? = null
- var outputFormat: String = "html"
- var jdkVersion: Int = 6
-
- var skipDeprecated: Boolean = false
-
- val compileClasspath: Path by lazy { Path(getProject()) }
- val sourcePath: Path by lazy { Path(getProject()) }
- val samplesPath: Path by lazy { Path(getProject()) }
- val includesPath: Path by lazy { Path(getProject()) }
-
- val antSourceLinks: MutableList<AntSourceLinkDefinition> = arrayListOf()
-
- fun setClasspath(classpath: Path) {
- compileClasspath.append(classpath)
- }
-
- fun setClasspathRef(ref: Reference) {
- compileClasspath.createPath().refid = ref
- }
-
- fun setSrc(src: Path) {
- sourcePath.append(src)
- }
-
- fun setSrcRef(ref: Reference) {
- sourcePath.createPath().refid = ref
- }
-
- fun setSamples(samples: Path) {
- samplesPath.append(samples)
- }
-
- fun setSamplesRef(ref: Reference) {
- samplesPath.createPath().refid = ref
- }
-
- fun setInclude(include: Path) {
- includesPath.append(include)
- }
-
- fun createSourceLink(): AntSourceLinkDefinition {
- val def = AntSourceLinkDefinition()
- antSourceLinks.add(def)
- return def
- }
-
- override fun execute() {
- if (sourcePath.list().size == 0) {
- throw BuildException("At least one source path needs to be specified")
- }
- if (moduleName == null) {
- throw BuildException("Module name needs to be specified")
- }
- if (outputDir == null) {
- throw BuildException("Output directory needs to be specified")
- }
- val sourceLinks = antSourceLinks.map {
- val path = it.path ?: throw BuildException("'path' attribute of a <sourceLink> element is required")
- val url = it.url ?: throw BuildException("'url' attribute of a <sourceLink> element is required")
- SourceLinkDefinition(File(path).canonicalFile.absolutePath, url, it.lineSuffix)
- }
-
- val generator = DokkaGenerator(
- AntLogger(this),
- compileClasspath.list().toList(),
- sourcePath.list().toList(),
- samplesPath.list().toList(),
- includesPath.list().toList(),
- moduleName!!,
- DocumentationOptions(outputDir!!, outputFormat,
- skipDeprecated = skipDeprecated,
- sourceLinks = sourceLinks,
- jdkVersion = jdkVersion)
- )
- generator.generate()
- }
-} \ No newline at end of file