How to use MavenFilteringHack to replace var from YAML files

I wrote my own rest-api-spec above, and I want to replace the ${} from in gradle build

processTestResources {
Map<String, Object> expansions = [
    'bucket': cosBucket,
    'base_path': cosBasePath,
]
inputs.properties(expansions)
MavenFilteringHack.filter(it, expansions)

When I run this code in gradle build, it doesn't worked. I seems gradle build could not find the value of ${cosBucket}.

Anyone who have developed ES plugin, Please help :smiling_face_with_three_hearts:

Is there any error or just no replacement?

no error just no replacement,I attach build.gradle below

import org.elasticsearch.gradle.MavenFilteringHack

buildscript {
    ext {
        pluginName = project.properties['pluginName']
        publishedPluginVersion = project.properties['esVersion']
        pluginVersion = project.properties['esVersion']
        esVersion = project.properties['esVersion']
    }
    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'org.elasticsearch.gradle:build-tools:'  + esVersion
        classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'
    }
}

// import external plugin
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'maven'
apply plugin: 'license'

ext.projectSubstitutions = [:]
// license of this project
licenseFile = rootProject.file('LICENSE.txt')

license {
    header rootProject.file('LicenseHeader.txt')
    skipExistingHeaders true
    useDefaultMappings = false
    mapping {
        java = 'SLASHSTAR_STYLE'
    }
}

// copyright notices
noticeFile = rootProject.file('NOTICE.txt')

esplugin {
    name pluginName
    description 'The Cos Repository plugin adds support for using Tencent Cloud Cos as a repository fro Snapshot/Restore.'
    classname 'org.elasticsearch.repositories.cos.COSRepositoryPlugin'
    version pluginVersion
    licenseFile rootProject.file('LICENSE.txt')
    noticeFile rootProject.file('NOTICE.txt')
}

repositories {
    mavenCentral()
}

dependencies {
    compile "org.elasticsearch:elasticsearch:" + esVersion
    compile "com.qcloud:cos_api:5.6.8"
    compile "commons-codec:commons-codec:1.11"
    compile "commons-logging:commons-logging:1.1.3"
    compile "org.slf4j:slf4j-log4j12:1.7.21"
    compile "org.slf4j:slf4j-api:1.7.21"
    compile "log4j:log4j:1.2.17"
    compile "com.fasterxml.jackson.core:jackson-core:2.8.11"
    compile "com.fasterxml.jackson.core:jackson-annotations:2.9.4"
    compile "com.fasterxml.jackson.core:jackson-databind:2.9.4"
    compile "org.apache.httpcomponents:httpclient:4.5.8"
    compile "org.apache.httpcomponents:httpcore:4.4.11"
}

bundlePlugin {

}

test {
    exclude '**/CosRepositoryThirdPartyTests.class'
    dependsOn processTestResources
}

String cosAccessKeyId = System.getenv("qcloud_cos_access_key_id")
String cosAccessKeySecret = System.getenv("qcloud_cos_access_key_secret")
String cosBucket = System.getenv("qcloud_cos_bucket")
String cosBasePath = System.getenv("qcloud_cos_base_path")
String cosRegion = System.getenv("qcloud_cos_region")

task thirdPartyTest(type: Test) {
    include '**/CosRepositoryThirdPartyTests.class'
    systemProperty 'es.allow_insecure_settings', 'true'
    systemProperty 'access_key_id', cosAccessKeyId
    systemProperty 'access_key_secret', cosAccessKeySecret
    systemProperty 'bucket', cosBucket
    systemProperty 'base_path', cosBasePath
    systemProperty 'region', cosRegion
}

thirdPartyTest {
    dependsOn tasks.bundlePlugin
}

processTestResources {
    Map<String, Object> expansions = [
            'bucket': cosBucket,
            'base_path': cosBasePath,
    ]
    inputs.properties(expansions)
    MavenFilteringHack.filter(it, expansions)
}

integTest {
    dependsOn processTestResources
}

// elasticsearch.esplugin task configure
checkstyleMain.enabled = false
checkstyleTest.enabled = false
dependencyLicenses.enabled = false
licenseMain.enabled = false
thirdPartyAudit.enabled = false
licenseHeaders.enabled = false
forbiddenApisMain.enabled = false
forbiddenApisTest.enabled = false
licenseTest.enabled = false

It worked. Because I did not match the var name both in MavenFilteringHack and YAML file.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.