DEV Community

Query Filter
Query Filter

Posted on

store5

task(dependsOn: [prepareLibDir, classes], task_name, type: JavaExec) {
    systemProperty "org.gradle.scan.acceptTerm", "true"
    logger.info 'Task: ' + task_name + ' started execution'

    doFirst {
        setTmpDir()
        buildFileSystem("$curInst.temp")
        jvmArgs += prepareJvmArgs()

        def quantumJarFile = sourceSets.main.runtimeClasspath.filter {
            it.toPath().getFileName().toString().endsWith('.jar') && it.toPath().getFileName().toString().contains("quantum")
        }

        // Your original dynamic classpath logic
        def fullClasspath = files(instanceClasspath) + quantumJarFile + (sourceSets.main.runtimeClasspath + files("${System.properties['java.io.tmpdir']}/$curInst.temp/dds") - quantumJarFile)

        // --- CORRECTED PATHING JAR LOGIC ---
        def pathingJar = new File(buildDir, "pathing-${task_name}.jar")
        pathingJar.parentFile.mkdirs()

        // Use Gradle's built-in manifest support to create the JAR
        ant.jar(destfile: pathingJar) {
            manifest {
                section(name: "") { // Define the Main-Attributes section
                    attribute(name: "Class-Path", value: fullClasspath.files.collect { it.toURI().toString() }.join(" "))
                }
            }
        }

        // Point the task to use only the Pathing JAR
        classpath = files(pathingJar)
        // ------------------------------------

        if (instance_options.isDevLocal?.toString()?.toBoolean()) {
            setupDevConfig()
        }

        fullClasspath.each { File file -> println 'classpath: ' + file }
    }

    // POINT DIRECTLY TO YOUR REAL SERVER
    main = 'com.citigroup.get.quantum.server.Server' 

    args 'file:///' + file("src/main/config/quantum/$curInst.asset/$curInst.region${curInst.country ? "/$curInst.country" : ""}/$curInst.env"),
         "$curInst.instance",
         'dummy'

    workingDir file('src/main/config')
    standardInput = System.in

    logger.info 'Task: ' + task_name + ' completes execution'
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)