zkovari/gradle-mermaid-plugin

View on GitHub
build.gradle

Summary

Maintainability
Test Coverage
buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
        maven {
            url 'https://dl.bintray.com/zkovari/maven'
        }
    }

    dependencies {
        classpath 'com.adarshr:gradle-test-logger-plugin:2.0.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+'
        classpath 'org.zkovari.changelog:changelog-automation-gradle-plugin:0.+'
    }
}

plugins {
    id 'eclipse'
    id 'idea'
    id 'java-library'
    id 'maven-publish'
    id 'jacoco'
    id 'java-gradle-plugin'
    id 'com.gradle.plugin-publish' version '0.10.1'
    id 'groovy'
}

apply plugin: 'com.adarshr.test-logger'
apply plugin: 'com.jfrog.bintray'
apply plugin: "org.zkovari.changelog"


configurations {
    jacocoRuntime
}


repositories {
    mavenCentral()
}


dependencies {
    compileOnly 'org.immutables:value:2.8.2'
    compileOnly 'org.immutables:builder:2.8.2'
    annotationProcessor 'org.immutables:value:2.8.2'
    
    implementation gradleApi()

    jacocoRuntime "org.jacoco:org.jacoco.agent:${jacoco.toolVersion}:runtime"
    
    testImplementation 'junit:junit:4.12'
    testImplementation "org.spockframework:spock-core:1.3-groovy-2.5"
    testImplementation files("$buildDir/testkit")
    testImplementation 'org.assertj:assertj-core:3.15.0'
}


project.group = 'org.zkovari.mermaid'
project.version = project.rootProject.version
project.description = 'Gradle plugin for generating dependency graphs as Mermaid diagrams'

if (project.hasProperty('SNAPSHOT')) {
    version = "$version-SNAPSHOT"
}


sourceCompatibility = 1.8
targetCompatibility = 1.8


jacocoTestReport {
    getAdditionalSourceDirs().from files(sourceSets.main.allSource.srcDirs)
    getSourceDirectories().from files(sourceSets.main.allSource.srcDirs)
    getClassDirectories().from files(sourceSets.main.output)
    reports {
        xml.enabled true
        html.enabled true
        csv.enabled false
    }
}


test {
    testLogging {
        events "failed"
        exceptionFormat "full"
    }

    jacoco {
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
        classDumpDir = file("$buildDir/jacoco/classpathdumps")
    }
}


task createTestkitFiles {
    def outputDir = file("$buildDir/testkit")
    
    outputs.dir outputDir

    doLast {
        outputDir.mkdirs()
        String jacocoPath = configurations.jacocoRuntime.asPath.replace('\\', '/')
        
        file("$outputDir/testkit-gradle.properties").text = "org.gradle.jvmargs=-javaagent:${jacocoPath}=destfile=${buildDir.path.replace('\\', '/')}/jacoco/jacocoTest.exec"
    }
}

test.dependsOn createTestkitFiles


gradlePlugin {
    plugins {
        mermaid {
            id = 'org.zkovari.mermaid'
            displayName = 'Mermaid diagram generation plugin'
            description = project.description
            implementationClass = 'org.zkovari.mermaid.api.MermaidGenerationPlugin'
        }
        mermaid_gitlab {
            id = 'org.zkovari.mermaid.ext.gitlab'
            displayName = 'Mermaid diagram generation plugin. GitLab extension'
            description = "${project.description}. GitLab extension."
            implementationClass = 'org.zkovari.mermaid.api.GitLabMermaidGenerationPlugin'
        }
    }
}


task sourcesJar(type: Jar) {
    from sourceSets.main.allJava
    archiveClassifier = 'sources'
}

task javadocJar(type: Jar) {
    from javadoc
    archiveClassifier = 'javadoc'
}

pluginBundle {
    website = 'https://gitlab.com/zkovari/gradle-mermaid-plugin'
    vcsUrl = 'https://gitlab.com/zkovari/gradle-mermaid-plugin'
    tags = ['mermaid', 'graph', 'generation', 'dependency graph']
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java

            artifact sourcesJar
            artifact javadocJar
            
            pom {
                name = project.name
                project.afterEvaluate {
                    description = project.description
                }
                url = 'https://gitlab.com/zkovari/gradle-mermaid-plugin'
                licenses {
                    license {
                        name = 'The Apache License, Version 2.0'
                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id = 'zkovari'
                        name = 'Zsolt Kovari'
                        email = 'zsolt@kovaridev.com'
                    }
                }
                
                scm {
                    url = 'https://gitlab.com/zkovari/gradle-mermaid-plugin'
                }
            }
        }
    }
}


bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')
    pkg {
        repo = 'maven'
        name = project.name
        userOrg = 'zkovari'
        licenses = ['Apache-2.0']
        vcsUrl = 'https://gitlab.com/zkovari/gradle-mermaid-plugin'
        version {
            name = project.version
            desc = project.description
            released  = new Date()
            vcsTag = "v${project.version}"
        }
    }
    publications = ['mavenJava']
    publish = true
}


task copyJarsToLib(type: Copy) {
    into "$buildDir/dependencies/libs"
    from configurations.compileOnly + configurations.default
}


task bumpVersion {
    doLast {
        def versionArray = version.toString().split(/\./)
        def last = Integer.parseInt(versionArray[versionArray.length - 1])
        versionArray[versionArray.length - 1] = Integer.toString(last + 1)
        def bumpedVersion = versionArray.join('.')

        ant.propertyfile(file: 'gradle.properties') {
            entry(key: 'version', value: bumpedVersion)
        }
    }
}