diff --git a/.github/workflows/reusable-assemble.yml b/.github/workflows/reusable-assemble.yml index 85002c8a0f8..5cc7b3e0d85 100644 --- a/.github/workflows/reusable-assemble.yml +++ b/.github/workflows/reusable-assemble.yml @@ -27,7 +27,7 @@ jobs: uses: gradle/gradle-build-action@v2 with: # javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/ - arguments: assemble -x javadoc ${{ inputs.no-build-cache && '--no-build-cache' || '' }} + arguments: assemble -Dai.etw.native.build=release -x javadoc ${{ inputs.no-build-cache && '--no-build-cache' || '' }} - name: Upload snapshot uses: actions/upload-artifact@v3 diff --git a/.pipelines/pipeline.user.windows.buddy.yml b/.pipelines/pipeline.user.windows.buddy.yml index fd4b1724855..8230531907b 100644 --- a/.pipelines/pipeline.user.windows.buddy.yml +++ b/.pipelines/pipeline.user.windows.buddy.yml @@ -9,7 +9,7 @@ build: - !!buildcommand name: 'Assemble' command: '.scripts/gradle.cmd' - arguments: ':agent:agent:assemble --offline' + arguments: ':agent:agent:assemble -Dai.etw.native.build=release --offline' artifacts: - to: 'Artifacts' include: diff --git a/.pipelines/pipeline.user.windows.official.nonrelease.yml b/.pipelines/pipeline.user.windows.official.nonrelease.yml index 803ff9b264c..8d33e2dc81f 100644 --- a/.pipelines/pipeline.user.windows.official.nonrelease.yml +++ b/.pipelines/pipeline.user.windows.official.nonrelease.yml @@ -16,7 +16,7 @@ build: - !!buildcommand name: 'Assemble' command: '.scripts/gradle.cmd' - arguments: ':agent:agent:assemble --offline' + arguments: ':agent:agent:assemble -Dai.etw.native.build=release --offline' artifacts: - to: 'Artifacts' include: diff --git a/.pipelines/pipeline.user.windows.official.yml b/.pipelines/pipeline.user.windows.official.yml index 05a12c56cff..55b12673d5f 100644 --- a/.pipelines/pipeline.user.windows.official.yml +++ b/.pipelines/pipeline.user.windows.official.yml @@ -16,7 +16,7 @@ build: - !!defaultcommand name: 'Assemble' command: '.scripts/gradle.cmd' - arguments: 'publishToMavenLocal -DisRelease=true -Pai.etw.native.build=release --offline' + arguments: 'publishToMavenLocal -DisRelease=true -Dai.etw.native.build=release --offline' - !!buildcommand name: 'Copy files from maven local repository' command: '.scripts/copy-from-maven-local.cmd' diff --git a/etw/build.gradle b/etw/build.gradle index e5e6d4c77f2..dfeffedbb99 100644 --- a/etw/build.gradle +++ b/etw/build.gradle @@ -4,14 +4,6 @@ plugins { id("base") } -clean { - dependsOn(":etw:java:clean") - def buildNative = System.getenv("CI") != null && Os.isFamily(Os.FAMILY_WINDOWS) - if (buildNative) { - dependsOn ":etw:native:clean" - } -} - /** * Configures the native build variant. * Values: release|debug @@ -19,6 +11,14 @@ clean { */ final def NATIVE_BUILD_VARIANT_PROPERTY = "ai.etw.native.build" +clean { + dependsOn(":etw:java:clean") + def buildNative = System.properties[NATIVE_BUILD_VARIANT_PROPERTY] != null && Os.isFamily(Os.FAMILY_WINDOWS) + if (buildNative) { + dependsOn ":etw:native:clean" + } +} + /** * Configures the verbosity of debug output. * This value is ignored if ai.etw.native.build=release @@ -31,14 +31,13 @@ subprojects { ext["NATIVE_BUILD_VARIANT_PROPERTY"] = NATIVE_BUILD_VARIANT_PROPERTY ext["NATIVE_VERBOSE_OUTPUT_PROPERTY"] = NATIVE_VERBOSE_OUTPUT_PROPERTY + String buildNativeProperty = System.properties[NATIVE_BUILD_VARIANT_PROPERTY] // if prop does not exist, use isRelease value, otherwise override isRelease value. - if (!project.hasProperty(NATIVE_BUILD_VARIANT_PROPERTY)) { - if (System.getProperty(NATIVE_BUILD_VARIANT_PROPERTY) == null) { - ext[NATIVE_BUILD_VARIANT_PROPERTY] = isRelease ? "release" : "debug" - logger.info "setting ai.etw.native.build for ${project.name}: ${ext[NATIVE_BUILD_VARIANT_PROPERTY]}" - } else { - ext[NATIVE_BUILD_VARIANT_PROPERTY] = System.getProperty(NATIVE_BUILD_VARIANT_PROPERTY) - } + if (buildNativeProperty == null) { + ext[NATIVE_BUILD_VARIANT_PROPERTY] = isRelease ? "release" : "debug" + logger.info "setting ai.etw.native.build for ${project.name}: ${ext[NATIVE_BUILD_VARIANT_PROPERTY]}" + } else { + ext[NATIVE_BUILD_VARIANT_PROPERTY] = buildNativeProperty } if (!project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY)) { @@ -47,7 +46,7 @@ subprojects { } } - if (project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY) && project.hasProperty(NATIVE_BUILD_VARIANT_PROPERTY)) { + if (project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY) && buildNativeProperty != null) { // verbose=true is not allowed for release builds if ("true".equalsIgnoreCase(ext[NATIVE_VERBOSE_OUTPUT_PROPERTY]) && "release".equalsIgnoreCase(ext[NATIVE_BUILD_VARIANT_PROPERTY])) { logger.warn "$NATIVE_VERBOSE_OUTPUT_PROPERTY cannot be true when $NATIVE_BUILD_VARIANT_PROPERTY=relese." diff --git a/etw/java/build.gradle b/etw/java/build.gradle index a2fab02dad4..54d7c070931 100644 --- a/etw/java/build.gradle +++ b/etw/java/build.gradle @@ -24,16 +24,15 @@ sourceSets { archivesBaseName = "applicationinsights-java-etw-provider" -logger.info "project ${project.path} prop: ai.etw.native.build=${project.properties['ai.etw.native.build']}" - -def buildNative = System.getenv("CI") != null && Os.isFamily(Os.FAMILY_WINDOWS) +logger.info "project ${project.path} prop: ai.etw.native.build=${System.properties['ai.etw.native.build']}" +def buildNative = System.properties['ai.etw.native.build'] != null && Os.isFamily(Os.FAMILY_WINDOWS) dependencies { implementation("org.slf4j:slf4j-api") if (buildNative) { - jni32 project(path: ":etw:native", configuration: "${project.properties['ai.etw.native.build']}X86RuntimeElements") - jni64 project(path: ":etw:native", configuration: "${project.properties['ai.etw.native.build']}X86-64RuntimeElements") + jni32 project(path: ":etw:native", configuration: "${System.properties['ai.etw.native.build']}X86RuntimeElements") + jni64 project(path: ":etw:native", configuration: "${System.properties['ai.etw.native.build']}X86-64RuntimeElements") } else { logger.info "Skipping build of :etw:native. EtwAppender/EtwProvider will not work because library is missing" } @@ -58,7 +57,7 @@ if (hasProperty("ai.etw.native.generateHeaders")) { if (buildNative) { tasks.register("processNativeResources", Copy) { - def useReleaseBuild = project.getProperty("ai.etw.native.build").equalsIgnoreCase("release") + def useReleaseBuild = System.properties["ai.etw.native.build"].equalsIgnoreCase("release") dependsOn project(":etw:native").tasks.named("assemble${useReleaseBuild ? 'Release' : 'Debug'}X86").get() dependsOn project(":etw:native").tasks.named("assemble${useReleaseBuild ? 'Release' : 'Debug'}X86-64").get() diff --git a/etw/native/build.gradle b/etw/native/build.gradle index cb350d04d6b..7eba9fe3793 100644 --- a/etw/native/build.gradle +++ b/etw/native/build.gradle @@ -38,7 +38,7 @@ library { } -logger.info "$NATIVE_BUILD_VARIANT_PROPERTY = ${project.properties[NATIVE_BUILD_VARIANT_PROPERTY]}" +logger.info "$NATIVE_BUILD_VARIANT_PROPERTY = ${System.properties[NATIVE_BUILD_VARIANT_PROPERTY]}" logger.info "$NATIVE_VERBOSE_OUTPUT_PROPERTY = ${project.properties[NATIVE_VERBOSE_OUTPUT_PROPERTY]}" // NOTE: these options apply to Visual Studio Build Tools (cl.exe) @@ -51,7 +51,9 @@ tasks.withType(CppCompile).configureEach { compilerArgs.add "/sdl" compilerArgs.add "/std:c++14" - if (project.hasProperty(NATIVE_BUILD_VARIANT_PROPERTY) && "release".equalsIgnoreCase(project.properties[NATIVE_BUILD_VARIANT_PROPERTY])) { + String buildNative = System.properties[NATIVE_BUILD_VARIANT_PROPERTY] + String outputNative = project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY) + if (buildNative != null && "release".equalsIgnoreCase(buildNative)) { logger.info "Configuring ${it} for release build" macros.put("NDEBUG", null) compilerArgs.add "/O2" // optimize for speed @@ -59,7 +61,7 @@ tasks.withType(CppCompile).configureEach { } else { logger.info "Configuring ${it} for debug build" compilerArgs.add "/MDd" // multithreaded, debug mode - if (project.hasProperty(NATIVE_VERBOSE_OUTPUT_PROPERTY) && "true".equalsIgnoreCase(project.properties[NATIVE_VERBOSE_OUTPUT_PROPERTY])) { + if (outputNative != null && "true".equalsIgnoreCase(outputNative)) { logger.info "Verbose output enabled" macros.put("AIETW_VERBOSE", null) } diff --git a/settings.gradle b/settings.gradle index 59cfff4f813..cdff6752fcd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -34,7 +34,7 @@ gradleEnterprise { rootProject.name = 'applicationinsights-java' -def buildNative = System.getenv("CI") != null && Os.isFamily(Os.FAMILY_WINDOWS) +def buildNative = System.properties["ai.etw.native.build"] != null && Os.isFamily(Os.FAMILY_WINDOWS) if (buildNative) { include ':etw:native' } else {