<commit_before>package com.bmuschko.gradle.docker

import org.ajoberstar.gradle.git.publish.GitPublishExtension
import org.ajoberstar.gradle.git.publish.GitPublishPlugin
import org.asciidoctor.gradle.AsciidoctorTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.javadoc.Groovydoc
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.external.javadoc.StandardJavadocDocletOptions
import org.gradle.kotlin.dsl.*

class DocumentationPlugin : Plugin<Project> {
    override fun apply(project: Project): Unit = project.run {
        applyGitPublishPlugin()
        addLinks()
        configureGitPublishExtension()
        configureTaskDependencies()
    }

    private
    fun Project.applyGitPublishPlugin() {
        apply<GitPublishPlugin>()
    }

    private
    fun Project.addLinks() {
        val javaApiUrl = "https://docs.oracle.com/javase/8/docs/api/"
        val groovyApiUrl = "http://docs.groovy-lang.org/2.5.4/html/gapi/"
        val gradleApiUrl = "https://docs.gradle.org/${project.gradle.gradleVersion}/javadoc/"

        tasks.withType<Javadoc>().configureEach {
            (options as StandardJavadocDocletOptions).links(javaApiUrl, groovyApiUrl, gradleApiUrl)
        }

        tasks.withType<Groovydoc>().configureEach {
            link(javaApiUrl, "java", "org.xml", "javax", "org.xml")
            link(groovyApiUrl, "groovy", "org.codehaus.groovy")
            link(gradleApiUrl, "org.gradle")
        }
    }

    private
    fun Project.configureGitPublishExtension() {
        val groovydoc: Groovydoc by tasks
        val asciidoctor: AsciidoctorTask by tasks

        configure<GitPublishExtension> {
            repoUri = "https://github.com/bmuschko/gradle-docker-plugin.git"
            branch = "gh-pages"

            contents {
                from(groovydoc) {
                    into("api")
                }
                from("${asciidoctor.outputDir}/html5")
            }
        }
    }

    private
    fun Project.configureTaskDependencies() {
        val groovydoc: Groovydoc by tasks
        val asciidoctor: AsciidoctorTask by tasks
        tasks["gitPublishCopy"].dependsOn(groovydoc, asciidoctor)
    }
}<commit_msg>Preserve docs per version<commit_after>package com.bmuschko.gradle.docker

import org.ajoberstar.gradle.git.publish.GitPublishExtension
import org.ajoberstar.gradle.git.publish.GitPublishPlugin
import org.asciidoctor.gradle.AsciidoctorTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.javadoc.Groovydoc
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.external.javadoc.StandardJavadocDocletOptions
import org.gradle.kotlin.dsl.*

class DocumentationPlugin : Plugin<Project> {
    override fun apply(project: Project): Unit = project.run {
        applyGitPublishPlugin()
        addLinks()
        configureGitPublishExtension()
        configureTaskDependencies()
    }

    private
    fun Project.applyGitPublishPlugin() {
        apply<GitPublishPlugin>()
    }

    private
    fun Project.addLinks() {
        val javaApiUrl = "https://docs.oracle.com/en/java/javase/11/docs/api"
        val groovyApiUrl = "http://docs.groovy-lang.org/2.5.4/html/gapi/"
        val gradleApiUrl = "https://docs.gradle.org/${project.gradle.gradleVersion}/javadoc/"

        tasks.withType<Javadoc>().configureEach {
            (options as StandardJavadocDocletOptions).links(javaApiUrl, groovyApiUrl, gradleApiUrl)
        }

        tasks.withType<Groovydoc>().configureEach {
            link(javaApiUrl, "java", "org.xml", "javax", "org.xml")
            link(groovyApiUrl, "groovy", "org.codehaus.groovy")
            link(gradleApiUrl, "org.gradle")
        }
    }

    private
    fun Project.configureGitPublishExtension() {
        val groovydoc: Groovydoc by tasks
        val asciidoctor: AsciidoctorTask by tasks

        configure<GitPublishExtension> {
            repoUri = "https://github.com/bmuschko/gradle-docker-plugin.git"
            branch = "gh-pages"

            contents {
                preserve {
                    include("**/*")
                }
                from(groovydoc) {
                    into("current/api")
                }
                from(groovydoc) {
                    into("${version.toString()}/api")
                }
                from("${asciidoctor.outputDir}/html5") {
                    into("current/user-guide")
                }
                from("${asciidoctor.outputDir}/html5") {
                    into("${version.toString()}/user-guide")
                }
            }
        }
    }

    private
    fun Project.configureTaskDependencies() {
        val groovydoc: Groovydoc by tasks
        val asciidoctor: AsciidoctorTask by tasks
        tasks["gitPublishCopy"].dependsOn(groovydoc, asciidoctor)
    }
}
{'fraction_non_alphanumeric': 0.11042439225381129, 'fraction_numerical': 0.002472187886279357, 'mean_word_length': 2.3691880638445526, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2372524', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1415, 'n_words': 216}