diff --git a/build.gradle b/build.gradle index fbe8a99e..ddc30f62 100644 --- a/build.gradle +++ b/build.gradle @@ -73,6 +73,7 @@ opensearchplugin { name 'opensearch-job-scheduler' description 'OpenSearch Job Scheduler plugin' classname 'org.opensearch.jobscheduler.JobSchedulerPlugin' + extendedPlugins = ['opensearch-job-scheduler-spi'] } configurations { @@ -217,6 +218,24 @@ publishing { name = "opensearch-job-scheduler" description = "OpenSearch Job Scheduler plugin" groupId = "org.opensearch.plugin" + + // Add required license information + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + + // Add required developer information + developers { + developer { + name = 'OpenSearch' + url = 'https://github.com/opensearch-project/job-scheduler' + } + } + + inceptionYear = '2021' } } } @@ -240,7 +259,7 @@ repositories { } dependencies { - implementation project(path: ":${rootProject.name}-spi", configuration: 'shadow') + implementation project(path: ":${rootProject.name}-spi") implementation ("org.opensearch:opensearch-remote-metadata-sdk-ddb-client:${opensearch_build}") implementation "org.opensearch:opensearch-remote-metadata-sdk:${opensearch_build}" testImplementation group: 'org.mockito', name: 'mockito-core', version: "${versions.mockito}" diff --git a/sample-extension-plugin/build.gradle b/sample-extension-plugin/build.gradle index 7c02b632..58f1ad92 100644 --- a/sample-extension-plugin/build.gradle +++ b/sample-extension-plugin/build.gradle @@ -26,7 +26,7 @@ opensearchplugin { name 'opensearch-job-scheduler-sample-extension' description 'Sample plugin that extends OpenSearch Job Scheduler plugin' classname 'org.opensearch.jobscheduler.sampleextension.SampleExtensionPlugin' - extendedPlugins = ['opensearch-job-scheduler'] + extendedPlugins = ['opensearch-job-scheduler-spi'] } ext { @@ -47,7 +47,7 @@ configurations { } dependencies { - compileOnly project(path: ":${rootProject.name}-spi", configuration: 'shadow') + compileOnly project(path: ":${rootProject.name}-spi") testImplementation('org.awaitility:awaitility:4.3.0') { exclude(group: 'org.hamcrest', module: 'hamcrest') } diff --git a/spi/build.gradle b/spi/build.gradle index 8a606818..386e9e9d 100644 --- a/spi/build.gradle +++ b/spi/build.gradle @@ -3,20 +3,24 @@ * SPDX-License-Identifier: Apache-2.0 */ -import com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin -import org.opensearch.gradle.test.RestIntegTestTask - plugins { - id 'com.gradleup.shadow' id 'jacoco' id 'maven-publish' id 'signing' id "org.gradle.test-retry" version "1.6.2" } -apply plugin: 'opensearch.java' +apply plugin: 'opensearch.opensearchplugin' +apply plugin: 'opensearch.pluginzip' apply plugin: 'opensearch.testclusters' apply plugin: 'opensearch.java-agent' +apply plugin: 'opensearch.rest-test' + +opensearchplugin { + name 'opensearch-job-scheduler-spi' + description 'OpenSearch Job Scheduler SPI Plugin' + classname 'org.opensearch.jobscheduler.spi.JobSchedulerSpiPlugin' +} repositories { mavenLocal() @@ -66,93 +70,49 @@ configurations.all { } } -shadowJar { - relocate 'com.cronutils', 'org.opensearch.jobscheduler.repackage.com.cronutils' - relocate 'org.slf4j', 'org.opensearch.jobscheduler.repackage.org.slf4j' // dependency of cron-utils - archiveClassifier = null -} - test { retry { failOnPassedAfterRetry = false maxRetries = 5 } - doFirst { - // reverse operation of https://github.com/elastic/elasticsearch/blob/7.6/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy#L736-L743 - // to fix the classpath for unit tests - test.classpath -= project.files(project.tasks.named('shadowJar')) - test.classpath -= project.configurations.getByName(ShadowBasePlugin.CONFIGURATION_NAME) - test.classpath += project.extensions.getByType(SourceSetContainer).getByName(SourceSet.MAIN_SOURCE_SET_NAME).runtimeClasspath - } // add "-Dtests.security.manager=false" to VM options if you want to run integ tests in IntelliJ systemProperty 'tests.security.manager', 'true' } -task integTest(type: RestIntegTestTask) { - description 'Run integ test with opensearch test framework' - group 'verification' - systemProperty 'tests.security.manager', 'true' -} - -task sourcesJar(type: Jar) { - archiveClassifier.set 'sources' - from sourceSets.main.allJava -} - -task javadocJar(type: Jar) { - archiveClassifier.set 'javadoc' - from javadoc.destinationDir - dependsOn javadoc -} - publishing { - repositories { - maven { - name = 'staging' - url = "${rootProject.buildDir}/local-staging-repo" - } - maven { - name = "Snapshots" // optional target repository name - url = "https://central.sonatype.com/repository/maven-snapshots/" - credentials { - username System.getenv("SONATYPE_USERNAME") - password System.getenv("SONATYPE_PASSWORD") - } - } - } publications { - shadow(MavenPublication) { publication -> - project.shadow.component(publication) - artifact sourcesJar - artifact javadocJar - + // Only keep the pluginZip publication + pluginZip(MavenPublication) { publication -> pom { - name = "OpenSearch Job Scheduler SPI" - packaging = "jar" - url = "https://github.com/opensearch-project/job-scheduler" - description = "OpenSearch Job Scheduler" - scm { - connection = "scm:git@github.com:opensearch-project/job-scheduler.git" - developerConnection = "scm:git@github.com:opensearch-project/job-scheduler.git" - url = "git@github.com:opensearch-project/job-scheduler.git" - } - licenses { - license { - name = "The Apache License, Version 2.0" - url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + name = "opensearch-job-scheduler-spi" + description = "OpenSearch Job Scheduler SPI Plugin" + groupId = "org.opensearch.plugin" + + // Add required license information + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } } - } - developers { - developer { - name = "OpenSearch" - url = "https://github.com/opensearch-project/job-scheduler" + + // Add required developer information + developers { + developer { + name = 'OpenSearch' + url = 'https://github.com/opensearch-project/job-scheduler' + } } - } + + inceptionYear = '2021' } } } +} - // TODO - enabled debug logging for the time being, remove this eventually - gradle.startParameter.setShowStacktrace(ShowStacktrace.ALWAYS) - gradle.startParameter.setLogLevel(LogLevel.DEBUG) +// Clean up conflicting publications +afterEvaluate { + publishing.publications.removeAll { pub -> + pub.name in ['nebula', 'shadow'] + } } diff --git a/spi/src/main/java/org/opensearch/jobscheduler/spi/JobSchedulerSpiPlugin.java b/spi/src/main/java/org/opensearch/jobscheduler/spi/JobSchedulerSpiPlugin.java new file mode 100644 index 00000000..fe43bde9 --- /dev/null +++ b/spi/src/main/java/org/opensearch/jobscheduler/spi/JobSchedulerSpiPlugin.java @@ -0,0 +1,32 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ +package org.opensearch.jobscheduler.spi; + +import org.opensearch.plugins.Plugin; + +/** + * OpenSearch Job Scheduler SPI Plugin + * + * This plugin provides the Service Provider Interface (SPI) for the OpenSearch Job Scheduler. + * It contains the interfaces and utilities needed for other plugins to extend the job scheduler functionality. + */ +public class JobSchedulerSpiPlugin extends Plugin { + + /** + * Plugin constructor + */ + public JobSchedulerSpiPlugin() { + // Plugin initialization + } + + @Override + public String toString() { + return "JobSchedulerSpiPlugin"; + } +}