/*
 * Copyright (C) 2011 Google Inc.
 *
 * 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.
 */

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

buildscript {
  apply from: "buildscript.gradle"
}

apply plugin: "catkin"
apply plugin: "maven-publish"

allprojects {
  group 'org.ros.rosjava_core'
  version = project.catkin.pkg.version
}

subprojects {
  if (name != 'docs') {
    /*
     * The ros plugin configures a few things:
     *
     *  - local deployment repository : where it dumps the jars and packaged artifacts)
     *  - local maven repositories    : where it finds your locally installed/built artifacts)
     *  - external maven repositories : where it goes looking if it can't find dependencies locally
     *
     * To modify, or add repos to the default external maven repositories list, pull request against this code:
     *
     *   https://github.com/rosjava/rosjava_bootstrap/blob/kinetic/gradle_plugins/src/main/groovy/org/ros/gradle_plugins/RosPlugin.groovy#L31
     */
    apply plugin: "ros-java"
    apply plugin: "osgi"
    apply plugin: "idea"
    apply plugin: "eclipse"
    apply plugin: "java-library"
  }
}

dependencies{

    // https://mvnrepository.com/artifact/com.google.guava/guava
    api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'

    // https://mvnrepository.com/artifact/org.jboss.netty/netty
    api group: 'org.jboss.netty', name: 'netty', version: '3.2.10.Final'

    // https://mvnrepository.com/artifact/commons-codec/commons-codec
    api group: 'commons-codec', name: 'commons-codec', version: '1.15'

    // https://mvnrepository.com/artifact/commons-pool/commons-pool
    api group: 'commons-pool', name: 'commons-pool', version: '1.6'

    // https://mvnrepository.com/artifact/commons-httpclient/commons-httpclient
    api group: 'commons-httpclient', name: 'commons-httpclient', version: '3.1'

    // https://mvnrepository.com/artifact/org.apache.ws.commons.util/ws-commons-util
    api group: 'org.apache.ws.commons.util', name: 'ws-commons-util', version: '1.0.2'

    // https://mvnrepository.com/artifact/dnsjava/dnsjava
    api group: 'dnsjava', name: 'dnsjava', version: '2.1.1'

}

publishing {
    publications {
        maven0(MavenPublication) {
            artifactId = 'rosjava'
            artifact("rosjava/build/libs/rosjava-${version}.jar") {
                extension 'jar'
            }
        }
        
        maven1(MavenPublication) {
            artifactId = 'apache_xmlrpc_client'
            artifact("apache_xmlrpc_client/build/libs/apache_xmlrpc_client-${version}.jar") {
                extension 'jar'
            }
        }
        
        maven2(MavenPublication) {
            artifactId = 'apache_xmlrpc_common'
            artifact("apache_xmlrpc_common/build/libs/apache_xmlrpc_common-${version}.jar") {
                extension 'jar'
            }
        }
        
        maven3(MavenPublication) {
            artifactId = 'apache_xmlrpc_server'
            artifact("apache_xmlrpc_server/build/libs/apache_xmlrpc_server-${version}.jar") {
                extension 'jar'
            }
        }
        
        maven4(MavenPublication) {
            artifactId = 'rosjava_helpers'
            artifact("rosjava_helpers/build/libs/rosjava_helpers-${version}.jar") {
                extension 'jar'
            }
        }
    }
    repositories {
        maven {
            url "https://git-st.inf.tu-dresden.de/api/v4/projects/1106/packages/maven"

            credentials(HttpHeaderCredentials) {
                name = 'Job-Token'
                value = System.getenv("CI_JOB_TOKEN")
            }
            authentication {
                header(HttpHeaderAuthentication)
            }
        }

    }
}


defaultTasks 'publish', 'installDist'