1

When I trying to deploying the code on ml server(10.0-9.4) ,with below build.gradle file , we are getting the below mentioned error:

In this deployment, I want to avoid the loading of ts(src/test/rule10.test.ts) file , is there any way to do so as it is not required and dependent on other modules.

command used :

./gradlew -b build.gradle loadRules -i -PmlUsername="" -PmlPassword="" -PmlHost="localhost"

build.gradle

plugins {
    // node
   // id "com.moowork.node" version "1.1.1"
    // ML-Gradle will handle the marklogic configuration
    id 'com.marklogic.ml-gradle' version '4.1.0'
    id "com.github.node-gradle.node" version "3.1.1"
}

// Set up extra properties to configure ml-gradle
ext {
    // set up the default IDDN databases
    mlAppConfig {
        contentDatabaseName = 'data1'
        schemasDatabaseName = 'Schemas'
                modulesDatabaseName = 'Modules'
        triggersDatabaseName = 'Triggers'
    }

    mlAppDeployer.getCommand('DeployCustomForestsCommand').setCustomForestsPath("forests")
    //  mlAppDeployer.getCommands().remove(mlAppDeployer.getCommand("DeployRolesCommand"))
    // do not let ml-gradle create a default rest server - we will only use the json config files
    mlAppDeployer.getCommands().remove(mlAppDeployer.getCommand('DeployRestApiServersCommand'))
}

repositories {
    mavenCentral()
    // Needed for mlcp dependencies
    maven { url 'https://developer.marklogic.com/maven2/' }
}

configurations {
    mlcp
}

dependencies {
    mlcp 'com.marklogic:mlcp:10.0.9.2'
    mlcp files('lib')
}

// Control nodejs and NPM build tasks via gradle

node {
    // Version of node to use.
    version = '10.14.1'
    npmVersion = '6.4.1'
    download = true
}

// do not spam NPM error messages, the tools' own messages are fine.
npm_run_clean {
    args = ['--loglevel', 'silent']
}
npm_run_build {
    args = ['--loglevel', 'silent']
}
npm_run_test {
    args = ['--loglevel', 'silent']
}

task loadJSON(type: com.marklogic.gradle.task.MlcpTask, dependsOn: []) {
    classpath = configurations.mlcp
    command = 'IMPORT'
    database = 'Modules'
    input_file_path = './src/main/ml-modules/root/a1.json'
    document_type = 'json'
    output_uri_replace = "^.*root,''"
}

// temp workaround to facilitate ns and collections
task loadJS(type: com.marklogic.gradle.task.MlcpTask, dependsOn: [npm_run_clean, npm_run_build]) {
    classpath = configurations.mlcp
    command = 'IMPORT'
    database = 'Modules'
    input_file_path = './src/main/ml-modules/root'
    document_type = 'text'
    output_uri_replace = "^.*root,''"
}

task loadRules(type: com.marklogic.gradle.task.MlcpTask, dependsOn: [mlClearModulesDatabase, mlClearSchemasDatabase, mlLoadSchemas, loadJS, loadJSON]) {
    classpath = configurations.mlcp
    command = 'IMPORT'
    database = 'Modules'
    input_file_path = './src/main/ml-modules/root'
    document_type = 'text'
    output_uri_replace = "^.*root,''"
    output_uri_suffix = ".sjs"
}

mlLoadSchemas.mustRunAfter(mlClearSchemasDatabase)
npm_run_build{}.mustRunAfter(npm_run_clean)
loadJS.mustRunAfter(npm_run_build)
loadJS.mustRunAfter(mlClearModulesDatabase)
loadJSON.mustRunAfter(loadJS)
loadRules.mustRunAfter(loadJS)

error:

> Task :npm_run_build
Caching disabled for task ':npm_run_build' because:
  Build cache is disabled
Task ':npm_run_build' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Starting process 'command '/var/opt/redaction/.gradle/npm/npm-v6.4.1/bin/npm''. Working directory: /var/opt/redaction Command: /var/opt/redaction/.gradle/npm/npm-v6.4.1/bin/npm run build --loglevel silent
Successfully started process 'command '/var/opt/redaction/.gradle/npm/npm-v6.4.1/bin/npm''
src/test/rule12.test.ts(3,38): error TS2307: Cannot find module 'marklogic-test-harness'.
src/test/rule11.test.ts(3,33): error TS2307: Cannot find module 'marklogic-test-harness'.
src/test/rule10.test.ts(2,38): error TS2307: Cannot find module 'marklogic-test-harness'.
src/test/test7.ts(3,33): error TS2307: Cannot find module 'marklogic-test-harness'.
src/test/test5.ts(3,36): error TS2307: Cannot find module 'marklogic-test-harness'.
src/test/rule3.test.ts(3,33): error TS2307: Cannot find module 'marklogic-test-harness'.
src/test/rule2.test.ts(2,38): error TS2307: Cannot find module 'marklogic-test-harness'.
src/test/rule.test.ts(3,33): error TS2307: Cannot find module 'marklogic-test-harness'.
src/test/rule1.test.ts(3,33): error TS2307: Cannot find module 'marklogic-test-harness'.

> Task :npm_run_build FAILED
:npm_run_build (Thread[Execution worker for ':',5,main]) completed. Took 3.295 secs.

Please any one can help me on this.

ravvi
  • 117
  • 6

1 Answers1

0

You could look to apply properties to only include (or to exclude) certain module filename patterns:

https://github.com/marklogic-community/ml-gradle/wiki/Property-reference#module-and-schema-properties

  • mlModulesRegex New in 3.3.0 - when running mlLoadModules or mlReloadModules, only load modules with a file path matching the given regex pattern. No default value.

  • mlResourceFilenamesToExcludeRegex New in 3.0.0 - regex that defines resource filenames to exclude from processing (exclude = ignore). Useful for when you want to exclude a set of resources when deploying to a certain environment. Cannot be set when mlResourceFilenamesToIncludeRegex is also set. No default value.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • 1
    I got solution of it by passing exclude key as part of tsconfig.json file, to exclude "/src/test/*.ts "module path – ravvi Sep 17 '22 at 06:52