forked from microsoft/ApplicationInsights-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
85 lines (72 loc) · 2.6 KB
/
Copy pathbuild.gradle
File metadata and controls
85 lines (72 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id("ai.java-conventions")
}
configurations {
jni64 {
transitive = false
}
jni32 {
transitive = false
}
}
def jniSrcDir = "src/main/jni"
sourceSets {
main {
java {
srcDir jniSrcDir
}
}
}
base {
archivesName = "applicationinsights-java-etw-provider"
}
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: "${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"
}
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.assertj:assertj-core")
testImplementation("org.mockito:mockito-core")
testImplementation("org.apache.commons:commons-lang3:3.12.0")
testCompileOnly("com.google.code.findbugs:jsr305")
}
// To rebuild naitive code with new headers, first run `gradlew :etw:java:classes -Pai.etw.native.generateHeaders` to generate new header, then update the method implementations.
// After that, :etw:java can be built again.
if (hasProperty("ai.etw.native.generateHeaders")) {
def jniOutDir = "$rootDir/etw/native/src/main/headers"
logger.quiet "New JNI headers will be generated to $jniOutDir"
compileJava {
options.compilerArgs.addAll(["-h", jniOutDir])
}
}
if (buildNative) {
tasks.register("processNativeResources", Copy) {
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()
from configurations.jni32.files
from configurations.jni64.files
include "*.dll"
into "${sourceSets.main.output.resourcesDir}"
}
tasks.named("processResources").configure {
dependsOn "processNativeResources"
}
}
tasks.named("test").configure {
def testprops =
project.properties.findAll {
it.key.startsWith("ai.tests.")
} +
project.properties.findAll {
it.key.startsWith("ai.etw.")
} + ["skipWinNative": !buildNative]
systemProperties testprops
}