|
| 1 | +plugins { |
| 2 | + id 'java-library' |
| 3 | + id 'maven-publish' |
| 4 | + id 'signing' |
| 5 | + id 'com.github.spotbugs' version '6.4.8' |
| 6 | +} |
| 7 | + |
| 8 | +group 'com.microsoft' |
| 9 | +version = '0.1.0' |
| 10 | +archivesBaseName = 'durabletask-scheduledtasks' |
| 11 | + |
| 12 | +def jacksonVersion = '2.18.3' |
| 13 | + |
| 14 | +// Java 11 is used to compile and run all tests. Set the JDK_11 env var to your |
| 15 | +// local JDK 11 home directory, e.g. C:/Program Files/Java/openjdk-11.0.12_7/ |
| 16 | +// If unset, falls back to the current JDK running Gradle. |
| 17 | +def rawJdkPath = System.env.JDK_11 ?: System.getProperty("java.home") |
| 18 | +def PATH_TO_TEST_JAVA_RUNTIME = rawJdkPath |
| 19 | +if (rawJdkPath != null) { |
| 20 | + def f = new File(rawJdkPath) |
| 21 | + if (f.isFile()) { |
| 22 | + PATH_TO_TEST_JAVA_RUNTIME = f.parentFile.parentFile.absolutePath |
| 23 | + } |
| 24 | +} |
| 25 | +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") |
| 26 | +def exeSuffix = isWindows ? ".exe" : "" |
| 27 | + |
| 28 | +dependencies { |
| 29 | + api project(':client') |
| 30 | + |
| 31 | + // Jackson annotations and databind — required for the .NET-compatible entity-state |
| 32 | + // wire shape (explicit PascalCase names, numeric status ordinals, TimeSpan/DateTimeOffset |
| 33 | + // converters). The core :client module declares Jackson as 'implementation', so it is not |
| 34 | + // exposed transitively; declare it explicitly here. |
| 35 | + implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}" |
| 36 | + implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" |
| 37 | + |
| 38 | + // JSR-305 nullability annotations (javax.annotation.Nullable), matching the core :client module's usage. |
| 39 | + implementation "com.google.code.findbugs:jsr305:3.0.2" |
| 40 | + |
| 41 | + testImplementation 'org.mockito:mockito-core:5.21.0' |
| 42 | + testImplementation 'org.mockito:mockito-junit-jupiter:5.21.0' |
| 43 | + // Integration tests target a Durable Task Scheduler emulator through the azuremanaged worker/client. |
| 44 | + testImplementation project(':azuremanaged') |
| 45 | +} |
| 46 | + |
| 47 | +compileJava { |
| 48 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 49 | + targetCompatibility = JavaVersion.VERSION_1_8 |
| 50 | +} |
| 51 | +compileTestJava { |
| 52 | + sourceCompatibility = JavaVersion.VERSION_11 |
| 53 | + targetCompatibility = JavaVersion.VERSION_11 |
| 54 | + options.fork = true |
| 55 | + options.forkOptions.executable = "${PATH_TO_TEST_JAVA_RUNTIME}/bin/javac${exeSuffix}" |
| 56 | +} |
| 57 | + |
| 58 | +tasks.withType(Test) { |
| 59 | + executable = new File("${PATH_TO_TEST_JAVA_RUNTIME}", "bin/java${exeSuffix}") |
| 60 | +} |
| 61 | + |
| 62 | +test { |
| 63 | + useJUnitPlatform { |
| 64 | + // Skip tests tagged as "integration" since those require an external DTS emulator. |
| 65 | + excludeTags "integration" |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +// Integration tests require a DTS emulator (default localhost:4001). |
| 70 | +task integrationTest(type: Test) { |
| 71 | + useJUnitPlatform { |
| 72 | + includeTags 'integration' |
| 73 | + } |
| 74 | + dependsOn build |
| 75 | + shouldRunAfter test |
| 76 | + testLogging.showStandardStreams = true |
| 77 | + ignoreFailures = false |
| 78 | +} |
| 79 | + |
| 80 | +spotbugs { |
| 81 | + toolVersion = '4.9.8' |
| 82 | + effort = com.github.spotbugs.snom.Effort.valueOf('MAX') |
| 83 | + reportLevel = com.github.spotbugs.snom.Confidence.valueOf('HIGH') |
| 84 | + ignoreFailures = true |
| 85 | +} |
| 86 | + |
| 87 | +spotbugsMain { |
| 88 | + reports { |
| 89 | + html { |
| 90 | + required = true |
| 91 | + stylesheet = 'fancy-hist.xsl' |
| 92 | + } |
| 93 | + xml { |
| 94 | + required = true |
| 95 | + } |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +spotbugsTest { |
| 100 | + reports { |
| 101 | + html { |
| 102 | + required = true |
| 103 | + stylesheet = 'fancy-hist.xsl' |
| 104 | + } |
| 105 | + xml { |
| 106 | + required = true |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +publishing { |
| 112 | + repositories { |
| 113 | + maven { |
| 114 | + url "file://$project.rootDir/repo" |
| 115 | + } |
| 116 | + } |
| 117 | + publications { |
| 118 | + mavenJava(MavenPublication) { |
| 119 | + from components.java |
| 120 | + artifactId = archivesBaseName |
| 121 | + pom { |
| 122 | + name = 'Durable Task Scheduled Tasks for Java' |
| 123 | + description = 'This package provides recurring scheduled tasks for the Durable Task Java SDK.' |
| 124 | + url = "https://github.com/microsoft/durabletask-java/tree/main/scheduledtasks" |
| 125 | + licenses { |
| 126 | + license { |
| 127 | + name = "MIT License" |
| 128 | + url = "https://opensource.org/licenses/MIT" |
| 129 | + distribution = "repo" |
| 130 | + } |
| 131 | + } |
| 132 | + developers { |
| 133 | + developer { |
| 134 | + id = "Microsoft" |
| 135 | + name = "Microsoft Corporation" |
| 136 | + } |
| 137 | + } |
| 138 | + scm { |
| 139 | + connection = "scm:git:https://github.com/microsoft/durabletask-java" |
| 140 | + developerConnection = "scm:git:git@github.com:microsoft/durabletask-java" |
| 141 | + url = "https://github.com/microsoft/durabletask-java/tree/main/scheduledtasks" |
| 142 | + } |
| 143 | + withXml { |
| 144 | + project.configurations.compileOnly.allDependencies.each { dependency -> |
| 145 | + asNode().dependencies[0].appendNode("dependency").with { |
| 146 | + it.appendNode("groupId", dependency.group) |
| 147 | + it.appendNode("artifactId", dependency.name) |
| 148 | + it.appendNode("version", dependency.version) |
| 149 | + it.appendNode("scope", "provided") |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | +} |
| 157 | + |
| 158 | +signing { |
| 159 | + required = !project.hasProperty("skipSigning") |
| 160 | + sign publishing.publications.mavenJava |
| 161 | +} |
| 162 | + |
| 163 | +java { |
| 164 | + withSourcesJar() |
| 165 | + withJavadocJar() |
| 166 | +} |
0 commit comments