diff --git a/build.gradle.kts b/build.gradle.kts index 843124bd80..6fdbd31a30 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,6 +37,8 @@ nebulaRelease { addReleaseBranchPattern("""v\d+\.\d+\.x""") } +apply(from = "version.gradle.kts") + nexusPublishing { repositories { sonatype { @@ -71,7 +73,7 @@ allprojects { ktlint("1.4.0").editorConfigOverride(mapOf("indent_size" to "2", "continuation_indent_size" to "2")) // Doesn't support pluginManagement block - targetExclude("settings.gradle.kts") + targetExclude("settings.gradle.kts", "version.gradle.kts") if (!project.path.startsWith(":sample-apps:")) { licenseHeaderFile("${rootProject.projectDir}/config/license/header.java", "plugins|include|import") diff --git a/lambda-layer/build-layer.sh b/lambda-layer/build-layer.sh index 36350cd5b1..a16346e0d2 100755 --- a/lambda-layer/build-layer.sh +++ b/lambda-layer/build-layer.sh @@ -4,13 +4,20 @@ set -e SOURCEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +## Get ADOT version +echo "Info: Getting ADOT Version" +pushd "$SOURCEDIR"/.. +version=$(./gradlew -q printVersion) +echo "Found ADOT Version: ${version}" +popd + ## Get OTel version echo "Info: Getting OTEL Version" file="$SOURCEDIR/../.github/patches/versions" -version=$(awk -F'=v' '/OTEL_JAVA_INSTRUMENTATION_VERSION/ {print $2}' "$file") -echo "Found OTEL Version: ${version}" +otel_instrumentation_version=$(awk -F'=v' '/OTEL_JAVA_INSTRUMENTATION_VERSION/ {print $2}' "$file") +echo "Found OTEL Version: ${otel_instrumentation_version}" # Exit if the version is empty or null -if [[ -z "$version" ]]; then +if [[ -z "$otel_instrumentation_version" ]]; then echo "Error: Version could not be found in ${file}." exit 1 fi @@ -20,7 +27,7 @@ fi echo "Info: Cloning and Patching OpenTelemetry Java Instrumentation Repository" git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git pushd opentelemetry-java-instrumentation -git checkout v${version} -b tag-v${version} +git checkout v${otel_instrumentation_version} -b tag-v${otel_instrumentation_version} # There is another patch in the .github/patches directory for other changes. We should apply them too for consistency. patch -p1 < "$SOURCEDIR"/../.github/patches/opentelemetry-java-instrumentation.patch @@ -61,7 +68,7 @@ popd ## Build ADOT Lambda Java SDK Layer Code echo "Info: Building ADOT Lambda Java SDK Layer Code" -./gradlew build -PotelVersion=${version} +./gradlew build -PotelVersion=${otel_instrumentation_version} -Pversion=${version} ## Copy ADOT Java Agent downloaded using Gradle task and bundle it with the Lambda handler script diff --git a/lambda-layer/build.gradle.kts b/lambda-layer/build.gradle.kts index 059294cfec..ade2a438d3 100644 --- a/lambda-layer/build.gradle.kts +++ b/lambda-layer/build.gradle.kts @@ -27,6 +27,7 @@ val javaagentDependency by configurations.creating { extendsFrom() } +val version: String by project val otelVersion: String by project dependencies { @@ -35,7 +36,7 @@ dependencies { // Already included in wrapper so compileOnly compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") compileOnly("io.opentelemetry:opentelemetry-sdk-extension-aws") - javaagentDependency("software.amazon.opentelemetry:aws-opentelemetry-agent:$otelVersion-adot-lambda1") + javaagentDependency("software.amazon.opentelemetry:aws-opentelemetry-agent:$version-adot-lambda1") } tasks.register("download") { diff --git a/version.gradle.kts b/version.gradle.kts new file mode 100644 index 0000000000..cc16e7f1d0 --- /dev/null +++ b/version.gradle.kts @@ -0,0 +1,24 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +val adotVersion = "2.11.1-dev0" + +allprojects { + version = if (project.hasProperty("release.version")) { + project.property("release.version") as String + } else { + adotVersion + } +}