
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors
 * as indicated by the @authors tag. All rights reserved.
 * See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'application'
apply plugin: 'checkstyle'

group = 'org.aesh'
archivesBaseName = 'aesh'
version = '1.5-SNAPSHOT'

ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

ext {
  if(!project.hasProperty('ossrhUsername'))
    ossrhUsername = ''

  if(!project.hasProperty('ossrhPassword')) {
    ossrhPassword = ''
  }
}

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

jar {
    manifest {
        attributes 'Implementation-Title': 'Aesh', 'Implementation-Version': version, 'Main-Class': 'example.AeshExample'
    }
}

test {
    testLogging.showStandardStreams = true
    //maxParallelForks = 1
    //forkEvery = 1
    //onOutput { descriptor, event ->
    //logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
    //}
}

repositories {
    mavenCentral()
    mavenLocal()
    maven {
        url "http://repository.jboss.org/nexus/content/groups/public/"
    }
}

dependencies {
    compile group: 'org.aesh', name: 'aesh-readline', version: '1.9'
    testCompile 'junit:junit:4.12'
}

mainClassName = "examples.Example"

install.dependsOn 'check'

if (JavaVersion.current().isJava8Compatible()) {
    tasks.withType(Javadoc) {
        // disable the crazy super-strict doclint tool in Java 8
        //noinspection SpellCheckingInspection
        options.addStringOption('Xdoclint:none', '-quiet')
    }
}

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

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

artifacts {
    archives javadocJar, sourcesJar
}

signing {
    required {isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives
}

def projectPom = {
    name = 'aesh'
    packaging = 'jar'
    // optionally artifactId can be defined here
    description = 'Aesh - Another Extendable SHell. Simple to use terminal API in Java'
    url = 'http://aeshell.github.io/'

    scm {
        connection = 'scm:git:github.com/aeshell/aesh.git'
        developerConnection = 'scm:git:github.com/aeshell/aesh.git'
        url = 'github.com/aeshell/aesh.git'
    }

    licenses {
        license {
            name = 'The Apache License, Version 2.0'
            url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
        }
    }
}

install {
  repositories.mavenInstaller.pom.project(projectPom)
}

uploadArchives {
    repositories {
        mavenDeployer {
            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

            
            repository(url: "http://repository.jboss.org/nexus/content/groups/public/") {
                authentication(userName: ossrhUsername, password: ossrhPassword)
            }

            snapshotRepository(url: "http://repository.jboss.org/nexus/content/groups/public/") {
                authentication(userName: ossrhUsername, password: ossrhPassword)
            }

            pom.project(projectPom)
        }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.0.1'
}
