Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rename] buildSrc directory, build-tools module #182

Merged
merged 4 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
44 changes: 22 additions & 22 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ plugins {
id 'java-test-fixtures'
}

group = 'org.elasticsearch.gradle'
group = 'org.opensearch.gradle'

String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build opensearch")
}

if (project == rootProject) {
Expand All @@ -47,7 +47,7 @@ if (project == rootProject) {
// we write this back out below to load it in the Build.java which will be shown in rest main action
// to indicate this being a snapshot build or a release build.
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties'))
version = props.getProperty("elasticsearch")
version = props.getProperty("opensearch")

def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) {
outputFile = "${buildDir}/version.properties"
Expand All @@ -64,7 +64,7 @@ processResources {
*****************************************************************************/

if (JavaVersion.current() < JavaVersion.VERSION_11) {
throw new GradleException('At least Java 11 is required to build elasticsearch gradle tools')
throw new GradleException('At least Java 11 is required to build opensearch gradle tools')
}

sourceSets {
Expand Down Expand Up @@ -142,8 +142,8 @@ if (project == rootProject) {
// this happens when included as a normal project in the build, which we do
// to enforce precommit checks like forbidden apis, as well as setup publishing
if (project != rootProject) {
apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.publish'
apply plugin: 'opensearch.build'
apply plugin: 'opensearch.publish'

allprojects {
targetCompatibility = 10
Expand All @@ -159,7 +159,7 @@ if (project != rootProject) {
disableTasks('forbiddenApisMain', 'forbiddenApisTest', 'forbiddenApisIntegTest', 'forbiddenApisTestFixtures')
jarHell.enabled = false
thirdPartyAudit.enabled = false
if (org.elasticsearch.gradle.info.BuildParams.inFipsJvm) {
if (org.opensearch.gradle.info.BuildParams.inFipsJvm) {
// We don't support running gradle with a JVM that is in FIPS 140 mode, so we don't test it.
// WaitForHttpResourceTests tests would fail as they use JKS/PKCS12 keystores
test.enabled = false
Expand All @@ -176,10 +176,10 @@ if (project != rootProject) {
distribution project(':distribution:archives:oss-linux-tar')
distribution project(':distribution:archives:oss-linux-aarch64-tar')

integTestRuntimeOnly(project(":libs:elasticsearch-core"))
integTestRuntimeOnly(project(":libs:opensearch-core"))
}

// for external projects we want to remove the marker file indicating we are running the Elasticsearch project
// for external projects we want to remove the marker file indicating we are running the OpenSearch project
processResources {
exclude 'buildSrc.marker'
into('META-INF') {
Expand Down Expand Up @@ -213,19 +213,19 @@ if (project != rootProject) {
naming.clear()
naming {
Tests {
baseClass 'org.elasticsearch.gradle.test.GradleUnitTestCase'
baseClass 'org.opensearch.gradle.test.GradleUnitTestCase'
}
IT {
baseClass 'org.elasticsearch.gradle.test.GradleIntegrationTestCase'
baseClass 'org.opensearch.gradle.test.GradleIntegrationTestCase'
}
}
}

tasks.register("integTest", Test) {
inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE)
systemProperty 'test.version_under_test', version
onlyIf { org.elasticsearch.gradle.info.BuildParams.inFipsJvm == false }
maxParallelForks = System.getProperty('tests.jvms', org.elasticsearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer
onlyIf { org.opensearch.gradle.info.BuildParams.inFipsJvm == false }
maxParallelForks = System.getProperty('tests.jvms', org.opensearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer
testClassesDirs = sourceSets.integTest.output.classesDirs
classpath = sourceSets.integTest.runtimeClasspath
}
Expand Down Expand Up @@ -265,27 +265,27 @@ class VersionPropertiesLoader {
}

protected static void loadBuildSrcVersion(Properties loadedProps, Properties systemProperties) {
String elasticsearch = loadedProps.getProperty("elasticsearch")
if (elasticsearch == null) {
throw new IllegalStateException("Elasticsearch version is missing from properties.")
String opensearch = loadedProps.getProperty("opensearch")
if (opensearch == null) {
throw new IllegalStateException("OpenSearch version is missing from properties.")
}
if (elasticsearch.matches("[0-9]+\\.[0-9]+\\.[0-9]+") == false) {
if (opensearch.matches("[0-9]+\\.[0-9]+\\.[0-9]+") == false) {
throw new IllegalStateException(
"Expected elasticsearch version to be numbers only of the form X.Y.Z but it was: " +
elasticsearch
"Expected opensearch version to be numbers only of the form X.Y.Z but it was: " +
opensearch
)
}
String qualifier = systemProperties.getProperty("build.version_qualifier", "");
if (qualifier.isEmpty() == false) {
if (qualifier.matches("(alpha|beta|rc)\\d+") == false) {
throw new IllegalStateException("Invalid qualifier: " + qualifier)
}
elasticsearch += "-" + qualifier
opensearch += "-" + qualifier
}
final String buildSnapshotSystemProperty = systemProperties.getProperty("build.snapshot", "true");
switch (buildSnapshotSystemProperty) {
case "true":
elasticsearch += "-SNAPSHOT"
opensearch += "-SNAPSHOT"
break;
case "false":
// do nothing
Expand All @@ -294,6 +294,6 @@ class VersionPropertiesLoader {
throw new IllegalArgumentException(
"build.snapshot was set to [" + buildSnapshotSystemProperty + "] but can only be unset or [true|false]");
}
loadedProps.put("elasticsearch", elasticsearch)
loadedProps.put("opensearch", opensearch)
}
}
2 changes: 1 addition & 1 deletion buildSrc/formatterConfig.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="17">
<profile kind="CodeFormatterProfile" name="Elasticsearch" version="17">
<profile kind="CodeFormatterProfile" name="OpenSearch" version="17">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/reaper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ apply plugin: 'java'
jar {
archiveFileName = "${project.name}.jar"
manifest {
attributes 'Main-Class': 'org.elasticsearch.gradle.reaper.Reaper'
attributes 'Main-Class': 'org.opensearch.gradle.reaper.Reaper'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.elasticsearch.gradle.reaper;
package org.opensearch.gradle.reaper;

import java.io.Closeable;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* under the License.
*/

package org.elasticsearch.gradle
package org.opensearch.gradle

import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
import org.elasticsearch.gradle.transform.SymbolicLinkPreservingUntarTransform

import org.opensearch.gradle.fixtures.AbstractGradleFuncTest
import org.opensearch.gradle.transform.SymbolicLinkPreservingUntarTransform
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Unroll

import static org.elasticsearch.gradle.fixtures.DistributionDownloadFixture.withMockedDistributionDownload
import static org.opensearch.gradle.fixtures.DistributionDownloadFixture.withMockedDistributionDownload

class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest {

Expand All @@ -44,16 +45,16 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest {

where:
version | platform | distType
VersionProperties.getElasticsearch() | ElasticsearchDistribution.Platform.LINUX | "current"
"8.1.0-SNAPSHOT" | ElasticsearchDistribution.Platform.LINUX | "bwc"
"7.0.0" | ElasticsearchDistribution.Platform.WINDOWS | "released"
VersionProperties.getOpenSearch() | OpenSearchDistribution.Platform.LINUX | "current"
"8.1.0-SNAPSHOT" | OpenSearchDistribution.Platform.LINUX | "bwc"
"7.0.0" | OpenSearchDistribution.Platform.WINDOWS | "released"
}


def "transformed versions are kept across builds"() {
given:
def version = VersionProperties.getElasticsearch()
def platform = ElasticsearchDistribution.Platform.LINUX
def version = VersionProperties.getOpenSearch()
def platform = OpenSearchDistribution.Platform.LINUX

buildFile << applyPluginAndSetupDistro(version, platform)
buildFile << """
Expand All @@ -76,24 +77,24 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest {

def "transforms are reused across projects"() {
given:
def version = VersionProperties.getElasticsearch()
def platform = ElasticsearchDistribution.Platform.LINUX
def version = VersionProperties.getOpenSearch()
def platform = OpenSearchDistribution.Platform.LINUX

3.times {
settingsFile << """
include ':sub-$it'
"""
}
buildFile.text = """
import org.elasticsearch.gradle.Architecture
import org.opensearch.gradle.Architecture

plugins {
id 'elasticsearch.distribution-download'
id 'opensearch.distribution-download'
}

subprojects {
apply plugin: 'elasticsearch.distribution-download'
apply plugin: 'opensearch.distribution-download'

${setupTestDistro(version, platform)}
${setupDistroTask()}
}
Expand All @@ -108,35 +109,35 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest {

then:
result.tasks.size() == 3
result.output.count("Unpacking elasticsearch-oss-${version}-linux-x86_64.tar.gz " +
result.output.count("Unpacking opensearch-oss-${version}-linux-x86_64.tar.gz " +
"using SymbolicLinkPreservingUntarTransform.") == 1
}

private boolean assertExtractedDistroCreated(String relativePath) {
File distroExtracted = new File(testProjectDir.root, relativePath)
assert distroExtracted.exists()
assert distroExtracted.isDirectory()
assert new File(distroExtracted, "elasticsearch-1.2.3/bin/elasticsearch").exists()
assert new File(distroExtracted, "opensearch-1.2.3/bin/opensearch").exists()
true
}

private static String applyPluginAndSetupDistro(String version, ElasticsearchDistribution.Platform platform) {
private static String applyPluginAndSetupDistro(String version, OpenSearchDistribution.Platform platform) {
"""
import org.elasticsearch.gradle.Architecture
import org.opensearch.gradle.Architecture

plugins {
id 'elasticsearch.distribution-download'
id 'opensearch.distribution-download'
}

${setupTestDistro(version, platform)}
${setupDistroTask()}

"""
}

private static String setupTestDistro(String version, ElasticsearchDistribution.Platform platform) {
private static String setupTestDistro(String version, OpenSearchDistribution.Platform platform) {
return """
elasticsearch_distributions {
opensearch_distributions {
test_distro {
version = "$version"
type = "archive"
Expand All @@ -150,7 +151,7 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest {
private static String setupDistroTask() {
return """
tasks.register("setupDistro", Sync) {
from(elasticsearch_distributions.test_distro.extracted)
from(opensearch_distributions.test_distro.extracted)
into("build/distro")
}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* under the License.
*/

package org.elasticsearch.gradle
package org.opensearch.gradle

import com.github.tomakehurst.wiremock.WireMockServer
import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
import org.elasticsearch.gradle.fixtures.WiremockFixture
import org.elasticsearch.gradle.transform.SymbolicLinkPreservingUntarTransform
import org.elasticsearch.gradle.transform.UnzipTransform
import org.opensearch.gradle.fixtures.AbstractGradleFuncTest
import org.opensearch.gradle.transform.SymbolicLinkPreservingUntarTransform
import org.opensearch.gradle.transform.UnzipTransform
import org.opensearch.gradle.fixtures.WiremockFixture
import spock.lang.Unroll

import java.nio.file.Files
Expand All @@ -32,8 +32,8 @@ import java.nio.file.Paths
import java.util.regex.Matcher
import java.util.regex.Pattern

import static org.elasticsearch.gradle.JdkDownloadPlugin.VENDOR_ADOPTOPENJDK
import static org.elasticsearch.gradle.JdkDownloadPlugin.VENDOR_OPENJDK
import static JdkDownloadPlugin.VENDOR_ADOPTOPENJDK
import static JdkDownloadPlugin.VENDOR_OPENJDK

class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {

Expand All @@ -49,9 +49,9 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
def mockedContent = filebytes(jdkVendor, platform)
buildFile.text = """
plugins {
id 'elasticsearch.jdk-download'
id 'opensearch.jdk-download'
}

jdks {
myJdk {
vendor = '$jdkVendor'
Expand Down Expand Up @@ -104,12 +104,12 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
}
buildFile.text = """
plugins {
id 'elasticsearch.jdk-download' apply false
id 'opensearch.jdk-download' apply false
}

subprojects {
apply plugin: 'elasticsearch.jdk-download'
apply plugin: 'opensearch.jdk-download'

jdks {
myJdk {
vendor = '$jdkVendor'
Expand Down Expand Up @@ -149,10 +149,10 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
def mockedContent = filebytes(VENDOR_ADOPTOPENJDK, platform)
buildFile.text = """
plugins {
id 'elasticsearch.jdk-download'
id 'opensearch.jdk-download'
}
apply plugin: 'base'
apply plugin: 'elasticsearch.jdk-download'
apply plugin: 'opensearch.jdk-download'

jdks {
myJdk {
Expand All @@ -162,7 +162,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
architecture = "x64"
}
}

tasks.register("getJdk") {
dependsOn jdks.myJdk
doLast {
Expand Down
Loading