DEV Community

Query Filter
Query Filter

Posted on

store8

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 ddsPath = "${System.properties['java.io.tmpdir']}/$curInst.temp/dds"

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

        // 1. Construct the FULL string for the internal framework
        def fullClasspathFiles = files(instanceClasspath) + quantumJarFile + (sourceSets.main.runtimeClasspath + files(ddsPath) - quantumJarFile)
        def fullClasspathString = fullClasspathFiles.asPath

        // 2. Create Pathing JAR for the command-line length issue
        def pathingJar = new File(buildDir, "pathing-${task_name}.jar")
        pathingJar.parentFile.mkdirs()
        def manifest = new java.util.jar.Manifest()
        manifest.mainAttributes.put(java.util.jar.Attributes.Name.MANIFEST_VERSION, "1.0")
        manifest.mainAttributes.put(java.util.jar.Attributes.Name.CLASS_PATH, 
            fullClasspathFiles.files.collect { it.toURI().toString() }.join(" "))
        new java.util.jar.JarOutputStream(new FileOutputStream(pathingJar), manifest).withCloseable { it.finish() }

        // 3. FIX: Manually set the system property that frameworks/compilers use
        // This tricks the internal 'Quantum' compiler into seeing everything
        systemProperty "java.class.path", fullClasspathString

        // 4. Set the actual task classpath to the Pathing JAR + DDS
        classpath = files(pathingJar, ddsPath)

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

    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
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)