/********************************************************************************
 * Copyright (c) 2020, 2023 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 ********************************************************************************/
plugins {
    id 'java-library'
}

apply from: "$rootDir/gradle/java.gradle"

jar {
    def version = project.version.toString()

    manifest {
        attributes(
                "Bundle-SymbolicName": "org.eclipse.jifa.hda.implementation; singleton:=true",
                "Require-Bundle": "org.eclipse.mat.api,org.eclipse.mat.parser,org.eclipse.mat.hprof,org.eclipse.osgi,MatCalcitePlugin",
                "Bundle-Activator": "org.eclipse.jifa.hda.impl.Activator",
                "Import-Package":
                        "org.eclipse.mat.snapshot,org.eclipse.mat.util,org.eclipse.mat.query,org.eclipse.mat.parser.model,org.eclipse.mat.hprof.extension",
                "Bundle-Version": version.endsWith("-SNAPSHOT") ? version.substring(0, version.indexOf('-')) : version
        )
    }

    archiveBaseName.set("heap-dump-analysis-impl")
}

dependencies {
    implementation project(':analysis:heap-dump:api')

    def prefix = "${mat_deps_dir_path}/"
    implementation fileTree(prefix) {
        include osgi_jar
        include "org.eclipse.mat.parser_*.jar"
        include "org.eclipse.mat.report_*.jar"
        include "org.eclipse.mat.api_*.jar"
        include "org.eclipse.mat.hprof_*.jar"
    }

    testImplementation project(':analysis:heap-dump:provider')
}

compileJava.dependsOn(':analysis:heap-dump:hook:hookPreferences')

tasks.register('installJar', Copy) {
    dependsOn jar
    from "${buildDir}/libs"
    into "${mat_deps_dir_path}"
    include "*${project.version}.jar"
}

compileTestJava.dependsOn installJar