import org.opensearch.gradle.test.RestIntegTestTask apply plugin: 'java' apply plugin: 'idea' apply plugin: 'opensearch.opensearchplugin' apply plugin: 'opensearch.yaml-rest-test' apply plugin: 'opensearch.pluginzip' def pluginName = 'rename' def pluginDescription = 'Custom plugin' def projectPath = 'org.opensearch' def pathToPlugin = 'path.to.plugin' def pluginClassName = 'RenamePlugin' group = "RenameGroup" tasks.register("preparePluginPathDirs") { mustRunAfter clean doLast { def newPath = pathToPlugin.replace(".", "/") mkdir "src/main/java/org/opensearch/$newPath" mkdir "src/test/java/org/opensearch/$newPath" mkdir "src/yamlRestTest/java/org/opensearch/$newPath" } } publishing { publications { pluginZip(MavenPublication) { publication -> pom { name = pluginName description = pluginDescription licenses { license { name = "The Apache License, Version 2.0" url = "http://www.apache.org/licenses/LICENSE-2.0.txt" } } developers { developer { name = "OpenSearch" url = "https://github.com/opensearch-project/opensearch-plugin-template-java" } } } } } } opensearchplugin { name pluginName description pluginDescription classname "${projectPath}.${pathToPlugin}.${pluginClassName}" licenseFile rootProject.file('LICENSE.txt') noticeFile rootProject.file('NOTICE.txt') } // This requires an additional Jar not published as part of build-tools loggerUsageCheck.enabled = false // No need to validate pom, as we do not upload to maven/sonatype validateNebulaPom.enabled = false buildscript { ext { opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT") } repositories { mavenLocal() maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "org.opensearch.gradle:build-tools:${opensearch_version}" } } repositories { mavenLocal() maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } test { include '**/*Tests.class' } task integTest(type: RestIntegTestTask) { description = "Run tests against a cluster" testClassesDirs = sourceSets.test.output.classesDirs classpath = sourceSets.test.runtimeClasspath } tasks.named("check").configure { dependsOn(integTest) } integTest { // The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable if (System.getProperty("test.debug") != null) { jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' } } testClusters.integTest { testDistribution = "INTEG_TEST" // This installs our plugin into the testClusters plugin(project.tasks.bundlePlugin.archiveFile) } run { useCluster testClusters.integTest } // updateVersion: Task to auto update version to the next development iteration task updateVersion { onlyIf { System.getProperty('newVersion') } doLast { ext.newVersion = System.getProperty('newVersion') println "Setting version to ${newVersion}." // String tokenization to support -SNAPSHOT ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true) } }