|
| 1 | +import java.time.Duration |
| 2 | +import org.gradle.external.javadoc.CoreJavadocOptions |
| 3 | + |
| 4 | +buildscript { |
| 5 | + repositories { |
| 6 | + mavenCentral() |
| 7 | + mavenLocal() |
| 8 | + } |
| 9 | +} |
| 10 | + |
| 11 | +plugins { // see Dependencies.kt in buildSrc |
| 12 | + Libs.javaBuiltInGradlePlugins.forEach { id(it) } |
| 13 | + Libs.javaExtGradlePlugins.forEach { (n, v) -> id(n) version v } |
| 14 | +} |
| 15 | + |
| 16 | +repositories { |
| 17 | + mavenLocal() |
| 18 | + // Before LaunchDarkly release artifacts get synced to Maven Central they are here along with snapshots: |
| 19 | + maven { url = uri("https://oss.sonatype.org/content/groups/public/") } |
| 20 | + mavenCentral() |
| 21 | +} |
| 22 | + |
| 23 | +configurations.all { |
| 24 | + // check for updates every build for dependencies with: 'changing: true' |
| 25 | + resolutionStrategy.cacheChangingModulesFor(0, "seconds") |
| 26 | +} |
| 27 | + |
| 28 | +base { |
| 29 | + group = ProjectValues.groupId |
| 30 | + archivesBaseName = ProjectValues.artifactId |
| 31 | + version = version |
| 32 | +} |
| 33 | + |
| 34 | +java { |
| 35 | + withJavadocJar() |
| 36 | + withSourcesJar() |
| 37 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 38 | + targetCompatibility = JavaVersion.VERSION_1_8 |
| 39 | +} |
| 40 | + |
| 41 | +dependencies { // see Dependencies.kt in buildSrc |
| 42 | + Libs.implementation.forEach { implementation(it) } |
| 43 | + Libs.javaTestImplementation.forEach { testImplementation(it) } |
| 44 | +} |
| 45 | + |
| 46 | +checkstyle { |
| 47 | + toolVersion = "9.3" |
| 48 | + configFile = file("${project.rootDir}/checkstyle.xml") |
| 49 | +} |
| 50 | + |
| 51 | +tasks.checkstyleMain { |
| 52 | + // Exclude embedded nanohttpd code from checkstyle |
| 53 | + exclude("com/launchdarkly/testhelpers/httptest/nanohttpd/**") |
| 54 | +} |
| 55 | + |
| 56 | +tasks.jar { |
| 57 | + manifest { |
| 58 | + attributes(mapOf("Implementation-Version" to project.version)) |
| 59 | + } |
| 60 | + // Include NOTICE file in binary distribution |
| 61 | + from(".") { |
| 62 | + include("NOTICE") |
| 63 | + into("META-INF") |
| 64 | + } |
| 65 | + // Include nanohttpd license in binary distribution per BSD 3-Clause requirements |
| 66 | + from("src/main/java/com/launchdarkly/testhelpers/httptest/nanohttpd") { |
| 67 | + include("LICENSE.md") |
| 68 | + into("META-INF/licenses/nanohttpd") |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +tasks.javadoc { |
| 73 | + // Force the Javadoc build to fail if there are any Javadoc warnings. |
| 74 | + (options as CoreJavadocOptions).addStringOption("Xwerror") |
| 75 | + |
| 76 | + // Exclude embedded nanohttpd code from Javadoc generation |
| 77 | + exclude("com/launchdarkly/testhelpers/httptest/nanohttpd/**") |
| 78 | +} |
| 79 | + |
| 80 | +helpers.Test.configureTask(tasks.compileTestJava, tasks.test, configurations["testRuntimeClasspath"]) |
| 81 | + |
| 82 | +helpers.Jacoco.configureTasks( |
| 83 | + tasks.jacocoTestReport, |
| 84 | + tasks.jacocoTestCoverageVerification |
| 85 | +) |
| 86 | + |
| 87 | +helpers.Idea.configure(idea) |
| 88 | + |
| 89 | +publishing { |
| 90 | + publications { |
| 91 | + create<MavenPublication>("mavenJava") { |
| 92 | + from(components["java"]) |
| 93 | + |
| 94 | + helpers.Pom.standardPom(pom) // see Pom.kt in buildSrc |
| 95 | + } |
| 96 | + } |
| 97 | + repositories { |
| 98 | + mavenLocal() |
| 99 | + } |
| 100 | +} |
| 101 | + |
| 102 | +nexusPublishing { |
| 103 | + clientTimeout.set(Duration.ofMinutes(2)) // we've seen extremely long delays in creating repositories |
| 104 | + repositories { |
| 105 | + sonatype{ |
| 106 | + nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) |
| 107 | + snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) |
| 108 | + } |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +signing { |
| 113 | + setRequired({ findProperty("skipSigning") != "true" }) |
| 114 | + sign(publishing.publications["mavenJava"]) |
| 115 | +} |
0 commit comments