DEV Community

Query Filter
Query Filter

Posted on

store7

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()

        // 1. Identify the dynamic dds path
        def ddsPath = files("${System.properties['java.io.tmpdir']}/$curInst.temp/dds")

        // 2. Filter your jars as before
        def quantumJarFile = sourceSets.main.runtimeClasspath.filter {
            it.toPath().getFileName().toString().endsWith('.jar') && it.toPath().getFileName().toString().contains("quantum")
        }

        // 3. This is the bulk of the classpath (the part that is too long)
        def bulkClasspath = files(instanceClasspath) + quantumJarFile + (sourceSets.main.runtimeClasspath - quantumJarFile)

        // 4. Create the Pathing JAR for the bulk only
        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, 
            bulkClasspath.files.collect { it.toURI().toString() }.join(" "))

        new java.util.jar.JarOutputStream(new FileOutputStream(pathingJar), manifest).withCloseable { it.finish() }

        // 5. SET CLASSPATH: Pathing JAR + DDS directory
        // This puts the DDS directory directly on the command line so the framework sees it
        classpath = files(pathingJar) + ddsPath

        // 6. REDUNDANCY: Pass the DDS path as a system property as well
        // Many rule compilers look for a specific property if they can't find it on the CP
        systemProperty "quantum.rules.classpath", ddsPath.asPath

        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)