|
| 1 | +/* |
| 2 | + * Copyright OpenSearch Contributors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +import com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin |
| 7 | +import org.opensearch.gradle.test.RestIntegTestTask |
| 8 | + |
| 9 | +plugins { |
| 10 | + id 'com.github.johnrengelman.shadow' |
| 11 | + id 'jacoco' |
| 12 | + id 'maven-publish' |
| 13 | + id 'signing' |
| 14 | +} |
| 15 | + |
| 16 | +apply plugin: 'opensearch.java' |
| 17 | + |
| 18 | +repositories { |
| 19 | + mavenLocal() |
| 20 | + mavenCentral() |
| 21 | + maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } |
| 22 | +} |
| 23 | + |
| 24 | +ext { |
| 25 | + projectSubstitutions = [:] |
| 26 | + licenseFile = rootProject.file('LICENSE.txt') |
| 27 | + noticeFile = rootProject.file('NOTICE') |
| 28 | +} |
| 29 | + |
| 30 | +jacoco { |
| 31 | + toolVersion = '0.8.7' |
| 32 | + reportsDirectory = file("$buildDir/JacocoReport") |
| 33 | +} |
| 34 | + |
| 35 | +jacocoTestReport { |
| 36 | + reports { |
| 37 | + xml.required = false |
| 38 | + csv.required = false |
| 39 | + html.destination file("${buildDir}/jacoco/") |
| 40 | + } |
| 41 | +} |
| 42 | +check.dependsOn jacocoTestReport |
| 43 | + |
| 44 | +def slf4j_version_of_cronutils = "1.7.36" |
| 45 | +dependencies { |
| 46 | + compileOnly "org.opensearch:opensearch:${opensearch_version}" |
| 47 | + |
| 48 | + testImplementation "org.opensearch.test:framework:${opensearch_version}" |
| 49 | + testImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}" |
| 50 | +} |
| 51 | + |
| 52 | +configurations.all { |
| 53 | + if (it.state != Configuration.State.UNRESOLVED) return |
| 54 | + resolutionStrategy { |
| 55 | + force "org.slf4j:slf4j-api:${slf4j_version_of_cronutils}" |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +shadowJar { |
| 60 | + archiveClassifier = null |
| 61 | +} |
| 62 | + |
| 63 | +test { |
| 64 | + doFirst { |
| 65 | + test.classpath -= project.files(project.tasks.named('shadowJar')) |
| 66 | + test.classpath -= project.configurations.getByName(ShadowBasePlugin.CONFIGURATION_NAME) |
| 67 | + test.classpath += project.extensions.getByType(SourceSetContainer).getByName(SourceSet.MAIN_SOURCE_SET_NAME).runtimeClasspath |
| 68 | + } |
| 69 | + systemProperty 'tests.security.manager', 'false' |
| 70 | +} |
| 71 | + |
| 72 | +task integTest(type: RestIntegTestTask) { |
| 73 | + description 'Run integ test with opensearch test framework' |
| 74 | + group 'verification' |
| 75 | + systemProperty 'tests.security.manager', 'false' |
| 76 | + dependsOn test |
| 77 | +} |
| 78 | +check.dependsOn integTest |
| 79 | + |
| 80 | +task sourcesJar(type: Jar) { |
| 81 | + archiveClassifier.set 'sources' |
| 82 | + from sourceSets.main.allJava |
| 83 | +} |
| 84 | + |
| 85 | +task javadocJar(type: Jar) { |
| 86 | + archiveClassifier.set 'javadoc' |
| 87 | + from javadoc.destinationDir |
| 88 | + dependsOn javadoc |
| 89 | +} |
| 90 | + |
| 91 | +publishing { |
| 92 | + repositories { |
| 93 | + maven { |
| 94 | + name = 'staging' |
| 95 | + url = "${rootProject.buildDir}/local-staging-repo" |
| 96 | + } |
| 97 | + maven { |
| 98 | + name = "Snapshots" // optional target repository name |
| 99 | + url = "https://aws.oss.sonatype.org/content/repositories/snapshots" |
| 100 | + credentials { |
| 101 | + username "$System.env.SONATYPE_USERNAME" |
| 102 | + password "$System.env.SONATYPE_PASSWORD" |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + publications { |
| 107 | + shadow(MavenPublication) { publication -> |
| 108 | + project.shadow.component(publication) |
| 109 | + artifact sourcesJar |
| 110 | + artifact javadocJar |
| 111 | + |
| 112 | + pom { |
| 113 | + name = "OpenSearch ML Commons SPI" |
| 114 | + packaging = "jar" |
| 115 | + url = "https://github.com/opensearch-project/ml-commons" |
| 116 | + description = "OpenSearch ML spi" |
| 117 | + scm { |
| 118 | + connection = "scm:git@github.com:opensearch-project/ml-commons.git" |
| 119 | + developerConnection = "scm:git@github.com:opensearch-project/ml-commons.git" |
| 120 | + url = "git@github.com:opensearch-project/ml-commons.git" |
| 121 | + } |
| 122 | + licenses { |
| 123 | + license { |
| 124 | + name = "The Apache License, Version 2.0" |
| 125 | + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" |
| 126 | + } |
| 127 | + } |
| 128 | + developers { |
| 129 | + developer { |
| 130 | + name = "OpenSearch" |
| 131 | + url = "https://github.com/opensearch-project/ml-commons" |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + } |
| 136 | + } |
| 137 | +} |
0 commit comments