From d9e7b5a0a4706669819e91dd19404891f437e6d8 Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Fri, 10 Jul 2015 18:47:46 +0300 Subject: Gradle initial plugin implementation --- .gitignore | 2 + .idea/ant.xml | 13 +- .idea/compiler.xml | 3 +- .idea/copyright/profiles_settings.xml | 4 + .idea/gradle.xml | 17 + .idea/inspectionProfiles/Project_Default.xml | 12 + .idea/inspectionProfiles/profiles_settings.xml | 8 + .idea/libraries/Gradle__junit_junit_4_12.xml | 12 + .../Gradle__org_fusesource_jansi_jansi_1_11.xml | 12 + .../Gradle__org_hamcrest_hamcrest_core_1_3.xml | 12 + ...radle__org_jetbrains_dokka_dokka_fatjar_1_0.xml | 10 + ...ns_kotlin_kotlin_gradle_plugin_0_1_SNAPSHOT.xml | 12 + ...otlin_kotlin_gradle_plugin_api_0_1_SNAPSHOT.xml | 12 + ...etbrains_kotlin_kotlin_runtime_0_1_SNAPSHOT.xml | 12 + ...jetbrains_kotlin_kotlin_stdlib_0_1_SNAPSHOT.xml | 12 + .idea/misc.xml | 5 +- .idea/modules.xml | 3 +- .idea/vcs.xml | 4 +- gradle-plugin/build.gradle | 60 + gradle-plugin/dokka-gradle-plugin.iml | 1476 ++++++++++++++++++++ gradle-plugin/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 52271 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + gradle-plugin/gradlew | 164 +++ gradle-plugin/gradlew.bat | 90 ++ gradle-plugin/settings.gradle | 2 + gradle-plugin/src/main/kotlin/logger.kt | 18 + gradle-plugin/src/main/kotlin/main.kt | 97 ++ .../gradle-plugins/org.jetbrains.dokka.properties | 1 + maven-plugin/dokka-maven-plugin.iml | 46 + maven-plugin/maven-plugin.iml | 48 - 30 files changed, 2119 insertions(+), 54 deletions(-) create mode 100644 .idea/copyright/profiles_settings.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/libraries/Gradle__junit_junit_4_12.xml create mode 100644 .idea/libraries/Gradle__org_fusesource_jansi_jansi_1_11.xml create mode 100644 .idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml create mode 100644 .idea/libraries/Gradle__org_jetbrains_dokka_dokka_fatjar_1_0.xml create mode 100644 .idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_gradle_plugin_0_1_SNAPSHOT.xml create mode 100644 .idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_gradle_plugin_api_0_1_SNAPSHOT.xml create mode 100644 .idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_0_1_SNAPSHOT.xml create mode 100644 .idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_0_1_SNAPSHOT.xml create mode 100644 gradle-plugin/build.gradle create mode 100644 gradle-plugin/dokka-gradle-plugin.iml create mode 100644 gradle-plugin/gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle-plugin/gradle/wrapper/gradle-wrapper.properties create mode 100755 gradle-plugin/gradlew create mode 100644 gradle-plugin/gradlew.bat create mode 100644 gradle-plugin/settings.gradle create mode 100644 gradle-plugin/src/main/kotlin/logger.kt create mode 100644 gradle-plugin/src/main/kotlin/main.kt create mode 100644 gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.dokka.properties create mode 100644 maven-plugin/dokka-maven-plugin.iml delete mode 100644 maven-plugin/maven-plugin.iml diff --git a/.gitignore b/.gitignore index eecbb95c..ecd04811 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ out doc target +build +.gradle \ No newline at end of file diff --git a/.idea/ant.xml b/.idea/ant.xml index c853cb11..764d23e5 100644 --- a/.idea/ant.xml +++ b/.idea/ant.xml @@ -1,6 +1,17 @@ - + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 1f71f978..e22d39e5 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -22,10 +22,11 @@ - + + diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 00000000..f4aa08e3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 00000000..adc07ffd --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..710a3bbe --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..8c1e55e8 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__junit_junit_4_12.xml b/.idea/libraries/Gradle__junit_junit_4_12.xml new file mode 100644 index 00000000..d9327061 --- /dev/null +++ b/.idea/libraries/Gradle__junit_junit_4_12.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_fusesource_jansi_jansi_1_11.xml b/.idea/libraries/Gradle__org_fusesource_jansi_jansi_1_11.xml new file mode 100644 index 00000000..1c5611d1 --- /dev/null +++ b/.idea/libraries/Gradle__org_fusesource_jansi_jansi_1_11.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 00000000..d7610aef --- /dev/null +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_dokka_dokka_fatjar_1_0.xml b/.idea/libraries/Gradle__org_jetbrains_dokka_dokka_fatjar_1_0.xml new file mode 100644 index 00000000..bf790a6d --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_dokka_dokka_fatjar_1_0.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_gradle_plugin_0_1_SNAPSHOT.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_gradle_plugin_0_1_SNAPSHOT.xml new file mode 100644 index 00000000..6133495f --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_gradle_plugin_0_1_SNAPSHOT.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_gradle_plugin_api_0_1_SNAPSHOT.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_gradle_plugin_api_0_1_SNAPSHOT.xml new file mode 100644 index 00000000..a6742e50 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_gradle_plugin_api_0_1_SNAPSHOT.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_0_1_SNAPSHOT.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_0_1_SNAPSHOT.xml new file mode 100644 index 00000000..841ef8e4 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_0_1_SNAPSHOT.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_0_1_SNAPSHOT.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_0_1_SNAPSHOT.xml new file mode 100644 index 00000000..4664f83f --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_0_1_SNAPSHOT.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 6208e987..a5c40e02 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,9 @@ + + + - + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 3cc41820..669ba41d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,7 +4,8 @@ - + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 275077f8..83067447 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,6 +2,6 @@ + - - + \ No newline at end of file diff --git a/gradle-plugin/build.gradle b/gradle-plugin/build.gradle new file mode 100644 index 00000000..ddc5a460 --- /dev/null +++ b/gradle-plugin/build.gradle @@ -0,0 +1,60 @@ +group 'org.jetbrains.dokka' +version '0.1-SNAPSHOT' + +buildscript { + ext.kotlin_version = '0.1-SNAPSHOT' + repositories { + mavenCentral() + maven { + url 'http://oss.sonatype.org/content/repositories/snapshots' + } + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'java' +apply plugin: 'kotlin' +apply plugin: 'maven-publish' + +sourceCompatibility = 1.6 + +repositories { + maven { + url "file:///${projectDir}/../out/repo" + } + mavenCentral() + maven { + url 'http://oss.sonatype.org/content/repositories/snapshots' + } +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + compile 'org.jetbrains.dokka:dokka-fatjar:1.0' + + compile 'org.fusesource.jansi:jansi:1.11' + + compile gradleApi() + compile localGroovy() +} + +sourceSets { + main.java.srcDirs += 'src/main/kotlin' +} + +task wrapper(type: Wrapper) { + gradleVersion = '2.5' + distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } +} diff --git a/gradle-plugin/dokka-gradle-plugin.iml b/gradle-plugin/dokka-gradle-plugin.iml new file mode 100644 index 00000000..bf48a145 --- /dev/null +++ b/gradle-plugin/dokka-gradle-plugin.iml @@ -0,0 +1,1476 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gradle-plugin/gradle/wrapper/gradle-wrapper.jar b/gradle-plugin/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..30d399d8 Binary files /dev/null and b/gradle-plugin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/gradle-plugin/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..2ac7a704 --- /dev/null +++ b/gradle-plugin/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jul 10 16:29:53 MSK 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip diff --git a/gradle-plugin/gradlew b/gradle-plugin/gradlew new file mode 100755 index 00000000..91a7e269 --- /dev/null +++ b/gradle-plugin/gradlew @@ -0,0 +1,164 @@ +#!/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/gradle-plugin/gradlew.bat b/gradle-plugin/gradlew.bat new file mode 100644 index 00000000..8a0b282a --- /dev/null +++ b/gradle-plugin/gradlew.bat @@ -0,0 +1,90 @@ +@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/gradle-plugin/settings.gradle b/gradle-plugin/settings.gradle new file mode 100644 index 00000000..1faee6f7 --- /dev/null +++ b/gradle-plugin/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'dokka-gradle-plugin' + diff --git a/gradle-plugin/src/main/kotlin/logger.kt b/gradle-plugin/src/main/kotlin/logger.kt new file mode 100644 index 00000000..715c1f04 --- /dev/null +++ b/gradle-plugin/src/main/kotlin/logger.kt @@ -0,0 +1,18 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.logging.Logger +import org.jetbrains.dokka.DokkaLogger + +class DokkaGradleLogger(val logger: Logger) : DokkaLogger { + override fun error(message: String) { + logger.error(message) + } + + override fun info(message: String) { + logger.info(message) + } + + override fun warn(message: String) { + logger.warn(message) + } +} \ No newline at end of file diff --git a/gradle-plugin/src/main/kotlin/main.kt b/gradle-plugin/src/main/kotlin/main.kt new file mode 100644 index 00000000..418af00f --- /dev/null +++ b/gradle-plugin/src/main/kotlin/main.kt @@ -0,0 +1,97 @@ +package org.jetbrains.dokka.gradle + +import groovy.lang.Closure +import org.gradle.api.DefaultTask +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaBasePlugin +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.tasks.SourceSet +import org.gradle.api.tasks.TaskAction +import org.jetbrains.dokka.DokkaGenerator +import org.jetbrains.dokka.SourceLinkDefinition +import java.io.File +import java.util.ArrayList + +public open class DokkaPlugin : Plugin { + override fun apply(project: Project) { + val ext = project.getExtensions().create("dokka", javaClass()) + project.getTasks().create("dokka", javaClass()) + + ext.moduleName = project.getName() + ext.outputDirectory = File(project.getBuildDir(), "dokka").getAbsolutePath() + } +} + +public open class DokkaTask : DefaultTask() { + init { + setGroup(JavaBasePlugin.DOCUMENTATION_GROUP) + setDescription("Generates dokka documentation for Kotlin") + } + + TaskAction + fun generate() { + val project = getProject() + val conf = getProject().getExtensions().getByType(javaClass()) + val javaPluginConvention = getProject().getConvention().getPlugin(javaClass()) + + val sourceSets = javaPluginConvention.getSourceSets()?.findByName(SourceSet.MAIN_SOURCE_SET_NAME) + val sourceDirectories = sourceSets?.getAllSource()?.getSrcDirs()?.filter { it.exists() } ?: emptyList() + val allConfigurations = getProject().getConfigurations() + + val classpath = + conf.processConfigurations + .map { allConfigurations?.getByName(it) ?: throw IllegalArgumentException("No configuration $it found") } + .flatMap { it } + + if (sourceDirectories.isEmpty()) { + getLogger().warn("No source directories found: skipping dokka generation") + return + } + + DokkaGenerator( + DokkaGradleLogger(getLogger()), + classpath.map { it.getAbsolutePath() }, + sourceDirectories.map { it.getAbsolutePath() }, + conf.samples, + conf.includes, + conf.moduleName, + conf.outputDirectory, + conf.outputFormat, + conf.linkMappings.map { SourceLinkDefinition(project.file(it.dir).getAbsolutePath(), it.url, it.suffix) }, + false + ).generate() + } + +} + +public open class DokkaExtension { + var moduleName: String = "" + var outputFormat: String = "html" + var outputDirectory: String = "" + var processConfigurations: ArrayList = arrayListOf("compile") + var includes: ArrayList = arrayListOf() + var linkMappings: ArrayList = arrayListOf() + var samples: ArrayList = arrayListOf() + + fun linkMapping(closure: Closure) { + val mapping = LinkMapping() + closure.setDelegate(mapping) + closure.call() + + if (mapping.dir.isEmpty()) { + throw IllegalArgumentException("Link mapping should have dir") + } + if (mapping.url.isEmpty()) { + throw IllegalArgumentException("Link mapping should have url") + } + + linkMappings.add(mapping) + } +} + +public open class LinkMapping { + var dir: String = "" + var url: String = "" + var suffix: String? = null +} diff --git a/gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.dokka.properties b/gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.dokka.properties new file mode 100644 index 00000000..b42cfe9f --- /dev/null +++ b/gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.dokka.properties @@ -0,0 +1 @@ +implementation-class=org.jetbrains.dokka.gradle.DokkaPlugin \ No newline at end of file diff --git a/maven-plugin/dokka-maven-plugin.iml b/maven-plugin/dokka-maven-plugin.iml new file mode 100644 index 00000000..45a70200 --- /dev/null +++ b/maven-plugin/dokka-maven-plugin.iml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maven-plugin/maven-plugin.iml b/maven-plugin/maven-plugin.iml deleted file mode 100644 index 52e48c92..00000000 --- a/maven-plugin/maven-plugin.iml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- cgit From b166d2ec2418f184ad31159c4307ae858193871f Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Fri, 10 Jul 2015 18:57:17 +0300 Subject: Gradle plugin getting started --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68d82aab..61849bda 100644 --- a/README.md +++ b/README.md @@ -153,4 +153,38 @@ Configuring source links mapping -``` \ No newline at end of file +``` + +### Using Gradle plugin + +```groovy +buildscript { + repositories { + mavenLocal() + jcenter() + } + dependencies { + classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.1-SNAPSHOT" + } +} + +apply plugin: 'org.jetbrains.dokka' +``` + +To configure plugin use dokka lambda in the root scope. For example: + +```groovy +dokka { + linkMapping { + dir = "src/main/kotlin" + url = "https://github.com/cy6erGn0m/vertx3-lang-kotlin/blob/master/src/main/kotlin" + suffix = "#L" + } +} +``` + +To get it generated use gradle `dokka` task + +```bash +./gradlew dokka +``` -- cgit From 698dd15f8d5be356813f24d773057ed7a7fd8253 Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Fri, 10 Jul 2015 19:53:23 +0300 Subject: Ant build to support gradle-plugin build too --- build.xml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 4174195e..f0690aec 100644 --- a/build.xml +++ b/build.xml @@ -7,6 +7,8 @@ + + @@ -52,7 +54,17 @@ - + + + + + + + + + + + -- cgit From 788a957072fba51b353f64bac392adb64c09085c Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Mon, 13 Jul 2015 18:05:53 +0300 Subject: Add Mojo and TaskAction annotations to the list of annotations prohibits unused declaration warning --- .idea/misc.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.idea/misc.xml b/.idea/misc.xml index a5c40e02..dbffc2e7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -2,6 +2,10 @@ + + + + -- cgit From 0352d46db95ba375daa523bd5ec6e2f6b27f81f8 Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Mon, 13 Jul 2015 19:47:09 +0300 Subject: Don't require JDK 1.8 --- .idea/ant.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) mode change 100644 => 100755 .idea/ant.xml diff --git a/.idea/ant.xml b/.idea/ant.xml old mode 100644 new mode 100755 index 764d23e5..13b52a5a --- a/.idea/ant.xml +++ b/.idea/ant.xml @@ -2,16 +2,14 @@ - - - \ No newline at end of file + -- cgit