I am running a gradle task

gradlew -b import.gradle copy_taskName -PinputHost="Host1" -PoutputHost="Host2" -Pduration=1 --stacktrace

In import.gradle , there is a mlcp task, where we are passing a taskName.json(where all the query are written in json format to fetch the data from input host) in query_filter field.

While running the task, I am getting:

Caused by: java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" (in directory "D:\Data1"): CreateProcess error=206, The filename or extension is too long at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25) ... 5 more Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long ... 6 more

When I removed some query from taskName.json, I am not getting any issue. I want to know, are there any constraints over size or number of queries written in taskName.json that we should have to pass in query_filter parameter to run the mlcp task?

total no of line of query content in taskName.json is 398

taskName.json file content sample

{
    "andQuery": {
        "queries": [{
            "collectionQuery": {
                "uris": ["collection1"]
            }
        },
        {
            "orQuery": {
                "queries": [
                {
                    "elementValueQuery": {
                        "element": ["{http://namespace.com/a/b}id"],
                        "text": ["text1"],
                        "options": ["lang=en"]
                    }
                },
                {
                    "elementValueQuery": {
                        "element": ["{http://namespace.com/a/b}id"],
                        "text": ["text2"],
                        "options": ["lang=en"]
                    }
                }]
            }
        },
        {
            "notQuery": {
                "query": {
                    "elementRangeQuery": {
                        "element": ["{http://namespace.com/a/b}date"],
                        "operator": ">",
                        "value": [{
                            "type": "dateTime",
                            "val": "%%now%%"
                        }]
                    }
                }
            }
        }]
    }
}

import.gradle

def importDirs =  new File("./teams").listFiles()

importDirs.each { importDir ->
    def queries = importDir.listFiles()
    queries.each { file ->
        def taskname = importDir.name + "_" +file.name.replace('.json', '')        
        task "copy_$taskname" (
                    type: com.marklogic.gradle.task.MlcpTask,
                    group: 'abc',
                    dependsOn: []) {            
                classpath = configurations.mlcp
                command = 'COPY'
                input_database = mlAppConfig.contentDatabaseName
                input_host = inputHost
                input_port = port
                input_username = inputUsername
                input_password = inputPassword
                output_database = mlAppConfig.contentDatabaseName
                output_host = outputHost
                output_port = port
                output_username = outputUsername
                output_password = outputPassword
                query_filter = file.text.replaceAll('"','\\\\"').replaceAll('%%now%%', now).replaceAll('%%targetDate%%', targetDate)
                max_split_size = 500                   
        }
    }
}
1

There are 1 answers

0
rjrudin On

MlcpTask is extending Gradle's JavaExec task, and the error is coming from the net.rubygrapefruit.platform.internal.DefaultProcessLauncher class. So my hunch is that since the contents of task.json is being tossed into the command line arguments, some limit within the JavaExec class is being reached. You could try extending JavaExec instead to confirm this - I am thinking you'd run into the same error.

One possible solution would be to use the MLCP options_file option. Since you're parameterizing the contents of task.json, you'd likely need to generate the contents of that file dynamically, presumably in a doFirst block on each Gradle task. But that will avoid very long command line arguments, as you'll instead toss them into options_file - and you may only need to toss query_filter in there.