plugins {
    id 'java'
    id 'application'
}

// This is a plain Java module (not Android)
java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

// Set the main class for the application plugin
application {
    mainClass = 'com.morefun.tester.MessageTesterMain'
}

dependencies {
    // Local jPOS library
    implementation files('libs/jpos-2.1.10-SNAPSHOT-q2.jar')
    
    // Basic dependencies for logging and utilities
    implementation 'commons-codec:commons-codec:1.15'
    implementation 'org.slf4j:slf4j-simple:1.7.36'
    
    // Test dependencies
    testImplementation 'junit:junit:4.13.2'
}

// Task to run the message tester
task runMessageTester(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    mainClass = 'com.morefun.tester.MessageTesterMain'
    
    // Optional: pass system properties
    systemProperties System.getProperties()
}

// Make the jar executable
jar {
    manifest {
        attributes(
            'Main-Class': 'com.morefun.tester.MessageTesterMain'
        )
    }
    // Include all dependencies in the jar
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}