Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestFram

plugins {
id 'java'
id 'java-library'
id "com.diffplug.spotless" version "6.18.0" apply false
id 'jacoco'
id "com.form.diff-coverage" version "0.9.5"
Expand All @@ -33,12 +34,6 @@ apply plugin: 'application'
apply from: 'gradle/formatting.gradle'
apply plugin: 'maven-publish'

// Temporary to keep "gradle run" working
// TODO: change this to an extension designed for testing instead of duplicating a sample
// https://github.com/opensearch-project/opensearch-sdk-java/issues/175
mainClassName = 'org.opensearch.sdk.sample.helloworld.HelloWorldExtension'


group 'org.opensearch.sdk'
version '2.0.0-SNAPSHOT'

Expand Down Expand Up @@ -77,6 +72,15 @@ repositories {
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/"}
}

subprojects {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/"}
}
}

dependencies {

def opensearchVersion = "3.0.0-SNAPSHOT"
Expand All @@ -90,13 +94,14 @@ dependencies {
def junitPlatform = "1.9.3"
def jaxbVersion = "2.3.1"

implementation("org.opensearch:opensearch:${opensearchVersion}")
api("org.opensearch:opensearch:${opensearchVersion}")

implementation("org.apache.logging.log4j:log4j-api:${log4jVersion}")
implementation("org.apache.logging.log4j:log4j-core:${log4jVersion}")
implementation("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
implementation("org.opensearch.client:opensearch-rest-high-level-client:${opensearchVersion}")
implementation("org.opensearch.client:opensearch-rest-client:${opensearchVersion}")
implementation("org.opensearch.client:opensearch-java:${opensearchVersion}")
api("org.opensearch.client:opensearch-rest-high-level-client:${opensearchVersion}")
api("org.opensearch.client:opensearch-rest-client:${opensearchVersion}")
api("org.opensearch.client:opensearch-java:${opensearchVersion}")
implementation("org.opensearch.plugin:transport-netty4-client:${opensearchVersion}")
implementation("io.netty:netty-all:${nettyVersion}")
testCompileOnly("junit:junit:${junit4Version}") {
Expand All @@ -109,25 +114,17 @@ dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonDatabindVersion}")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-guava:${jacksonDatabindVersion}")
constraints {
implementation("com.google.guava:guava:${guavaVersion}") {
api("com.google.guava:guava:${guavaVersion}") {
because 'versions below 30.0 have active CVE'
}
}
implementation("com.google.inject:guice:${guiceVersion}")
api("com.google.inject:guice:${guiceVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${junit5Version}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junit5Version}")
testImplementation("org.opensearch.test:framework:${opensearchVersion}")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:${junitPlatform}")
}

// this task runs the helloworld sample extension
task helloWorld(type: JavaExec) {
group = 'Execution'
description = 'Run HelloWorld Extension.'
mainClass = 'org.opensearch.sdk.sample.helloworld.HelloWorldExtension'
classpath = sourceSets.main.runtimeClasspath
}

test {
// Temporary workaround for https://github.com/gradle/gradle/issues/23995
getTestFrameworkProperty().convention(getProviderFactory().provider(() -> new JUnitPlatformTestFramework(it.getFilter(), false)))
Expand Down
29 changes: 29 additions & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
100 changes: 100 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestFramework

/*
* 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.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

plugins {
id 'java'
id "com.diffplug.spotless" version "6.18.0" apply false
id 'jacoco'
id "com.form.diff-coverage" version "0.9.5"
// for javadocs and checks spotless doesn't do
id 'checkstyle'
}

ext {
projectSubstitutions = [:]
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
}


apply plugin: 'application'
apply plugin: 'maven-publish'

// Temporary to keep "gradle run" working
// TODO: change this to an extension designed for testing instead of duplicating a sample
// https://github.com/opensearch-project/opensearch-sdk-java/issues/175
mainClassName = 'org.opensearch.sdk.sample.helloworld.HelloWorldExtension'


group 'org.opensearch.sdk.sample'
version '2.0.0-SNAPSHOT'

java {
withSourcesJar()
withJavadocJar()
}

publishing {
publications {
group = "${group}"
version = "${version}"
mavenJava(MavenPublication) {
from components.java
}
sourceCompatibility = 11
targetCompatibility = 11
}

repositories {
maven {
name = "Snapshots" // optional target repository name
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
credentials {
username "$System.env.SONATYPE_USERNAME"
password "$System.env.SONATYPE_PASSWORD"
}
}
}
}

test {
getTestFrameworkProperty().convention(getProviderFactory().provider(() -> new JUnitPlatformTestFramework(it.getFilter(), false)))
jvmArgs '--enable-preview'
systemProperty 'tests.security.manager', 'false'
}

dependencies {
def opensearchVersion = "3.0.0-SNAPSHOT"
def jobSchedulerVersion = "3.0.0.0-SNAPSHOT"
def junit5Version = "5.9.3"
def junitPlatform = "1.9.3"

implementation project(':')
implementation("org.opensearch.plugin:opensearch-job-scheduler:${jobSchedulerVersion}")
implementation("org.opensearch:opensearch-job-scheduler:${jobSchedulerVersion}")
implementation("org.opensearch:opensearch-job-scheduler-spi:${jobSchedulerVersion}")

testImplementation project(':').sourceSets.test.output
testImplementation("org.junit.jupiter:junit-jupiter-api:${junit5Version}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junit5Version}")
testImplementation("org.opensearch.test:framework:${opensearchVersion}")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:${junitPlatform}")
}

// this task runs the helloworld sample extension
task helloWorld(type: JavaExec) {
group = 'Execution'
description = 'Run HelloWorld Extension.'
mainClass = 'org.opensearch.sdk.sample.helloworld.HelloWorldExtension'
classpath = sourceSets.main.runtimeClasspath
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,29 @@

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import com.google.common.collect.ImmutableList;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionResponse;
import org.opensearch.common.settings.Setting;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.sdk.BaseExtension;
import org.opensearch.sdk.Extension;
import org.opensearch.sdk.ExtensionSettings;
import org.opensearch.sdk.ExtensionsRunner;
import org.opensearch.sdk.SDKClient;
import org.opensearch.sdk.api.ActionExtension;
import org.opensearch.sdk.rest.ExtensionRestHandler;
import org.opensearch.sdk.sample.helloworld.rest.RestHelloAction;
import org.opensearch.sdk.sample.helloworld.rest.RestRemoteHelloAction;
import org.opensearch.sdk.sample.helloworld.schedule.GreetJob;
import org.opensearch.sdk.sample.helloworld.transport.HWJobParameterAction;
import org.opensearch.sdk.sample.helloworld.transport.HWJobParameterTransportAction;
import org.opensearch.sdk.sample.helloworld.transport.HWJobRunnerAction;
import org.opensearch.sdk.sample.helloworld.transport.HWJobRunnerTransportAction;
import org.opensearch.sdk.sample.helloworld.transport.SampleAction;
import org.opensearch.sdk.sample.helloworld.transport.SampleTransportAction;

Expand Down Expand Up @@ -61,7 +71,30 @@ public List<ExtensionRestHandler> getExtensionRestHandlers() {

@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return Arrays.asList(new ActionHandler<>(SampleAction.INSTANCE, SampleTransportAction.class));
return Arrays.asList(
new ActionHandler<>(SampleAction.INSTANCE, SampleTransportAction.class),
new ActionHandler<>(HWJobRunnerAction.INSTANCE, HWJobRunnerTransportAction.class),
new ActionHandler<>(HWJobParameterAction.INSTANCE, HWJobParameterTransportAction.class)
);
}

@Override
public List<NamedXContentRegistry.Entry> getNamedXContent() {
return ImmutableList.of(GreetJob.XCONTENT_REGISTRY);
}

@Deprecated
private SDKClient.SDKRestClient createRestClient(ExtensionsRunner runner) {
@SuppressWarnings("resource")
SDKClient.SDKRestClient client = runner.getSdkClient().initializeRestClient();
return client;
}

@Override
public Collection<Object> createComponents(ExtensionsRunner runner) {
SDKClient.SDKRestClient sdkRestClient = createRestClient(runner);

return Collections.singletonList(sdkRestClient);
}

/**
Expand Down
Loading