/*==========================================================================
 Copyright since 2013, EPAM Systems

 This file is part of Wilma.

 Wilma is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 Wilma is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Wilma.  If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

description= 'wilma-message-search'

task docs(type: Javadoc) {
    destinationDir = file("$buildDir/docs/all")
    options.memberLevel = JavadocMemberLevel.PRIVATE
    for (subproject in project.subprojects) {
        if (subproject.plugins.hasPlugin(JavaPlugin)){
            source += files(subproject.sourceSets.main.java)
            classpath += files(subproject.sourceSets.main.compileClasspath)
        }
    }
}

task checkstyle(type: Checkstyle) {
    dependsOn subprojects.checkstyleMain
}

task deleteRelease(type: Delete) {
    delete rootProject.rootDir.absolutePath + '/wilma-message-search/release'
    dependsOn(":wilma-message-search:wilma-message-search-engine:shadowJar")
}

def releaseCopySpec = project.copySpec {
   from(rootProject.rootDir.absolutePath + '/wilma-message-search/modules/wilma-message-search-engine/') {
     include 'message.search.conf.properties'
     include 'readme.txt'
   }
   from(rootProject.rootDir.absolutePath + '/wilma-message-search/modules/wilma-message-search-engine/build/libs/') {
     include "wilma-message-search-engine-$version" + '-all.jar'
   }
   from(rootProject.rootDir.absolutePath + '/') {
     include 'COPYRIGHT.txt'
     include 'COPYRIGHTS/'
   }
}

task copyToRelease(type: Copy) {
    dependsOn deleteRelease
    into rootProject.rootDir.absolutePath + '/wilma-message-search/release'
    rename "wilma-message-search-engine-$version" + '-all.jar', "wilma-message-search-" + "$version" + ".jar"
    with releaseCopySpec
}

task release(type: Zip) {
    dependsOn copyToRelease
    from rootProject.rootDir.absolutePath + '/wilma-message-search/release'
}

subprojects {

    repositories {
        maven { url "https://repository.jboss.org/nexus/content/groups/public" }
    }
  
    dependencies {
        implementation(group: 'org.springframework', name: 'spring-context', version:"${orgSpringframework}") {
            exclude(module: 'commons-logging')
        }
        implementation group: 'org.springframework', name: 'spring-webmvc', version:"${orgSpringframework}"
        implementation group: 'org.aspectj', name: 'aspectjrt', version:'1.9.19'
        testImplementation group: 'org.mockito', name: 'mockito-core', version: "${mockitoCoreVersion}"
        testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: "${mockitoCoreVersion}"
        testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "${jUnitVersion}"
        testImplementation(group: 'org.springframework', name: 'spring-test', version:"${orgSpringframework}")
        testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${jUnitVersion}"
    }

    test.useJUnit()
}


