|
| 1 | +import nl.javadude.gradle.plugins.license.DownloadLicensesExtension.license |
| 2 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 3 | +import org.gradle.api.tasks.testing.logging.TestLogEvent.* |
| 4 | + |
| 5 | +plugins { |
| 6 | + java |
| 7 | + alias(libs.plugins.defaults) |
| 8 | + alias(libs.plugins.shadow) |
| 9 | + alias(libs.plugins.license) |
| 10 | + id("com.hivemq.edge-version-updater") |
| 11 | + id("com.hivemq.third-party-license-generator") |
| 12 | +} |
| 13 | + |
| 14 | +group = "com.hivemq" |
| 15 | + |
| 16 | +java { |
| 17 | + toolchain { |
| 18 | + languageVersion.set(JavaLanguageVersion.of(11)) |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +repositories { |
| 23 | + mavenCentral() |
| 24 | + exclusiveContent { |
| 25 | + forRepository { |
| 26 | + maven { |
| 27 | + url = uri("https://jitpack.io") |
| 28 | + } |
| 29 | + } |
| 30 | + filter { |
| 31 | + includeGroup("com.github.simon622.mqtt-sn") |
| 32 | + includeGroup("com.github.simon622") |
| 33 | + } |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +dependencies { |
| 38 | + compileOnly(libs.hivemq.edge.adapterSdk) |
| 39 | + compileOnly(libs.apache.commonsIO) |
| 40 | + compileOnly(libs.jackson.databind) |
| 41 | + compileOnly(libs.iot.communication) |
| 42 | + compileOnly(libs.slf4j.api) |
| 43 | + |
| 44 | + testImplementation(libs.jackson.databind) |
| 45 | + testImplementation(libs.junit.jupiter) |
| 46 | + testImplementation(libs.assertj) |
| 47 | + testImplementation(libs.mockito.junitJupiter) |
| 48 | + testImplementation("com.hivemq:hivemq-edge") |
| 49 | + |
| 50 | +} |
| 51 | + |
| 52 | +tasks.test { |
| 53 | + useJUnitPlatform() |
| 54 | + testLogging { |
| 55 | + events = setOf(STARTED, PASSED, FAILED, SKIPPED, STANDARD_ERROR) |
| 56 | + exceptionFormat = TestExceptionFormat.FULL |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +tasks.register<Copy>("copyAllDependencies") { |
| 61 | + shouldRunAfter("assemble") |
| 62 | + from(configurations.runtimeClasspath) |
| 63 | + into("${buildDir}/deps/libs") |
| 64 | +} |
| 65 | + |
| 66 | +tasks.named("assemble") { finalizedBy("copyAllDependencies") } |
| 67 | + |
| 68 | +/* ******************** artifacts ******************** */ |
| 69 | + |
| 70 | +val releaseBinary: Configuration by configurations.creating { |
| 71 | + isCanBeConsumed = true |
| 72 | + isCanBeResolved = false |
| 73 | + attributes { |
| 74 | + attribute(Category.CATEGORY_ATTRIBUTE, objects.named("binary")) |
| 75 | + attribute(Usage.USAGE_ATTRIBUTE, objects.named("release")) |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +val thirdPartyLicenses: Configuration by configurations.creating { |
| 80 | + isCanBeConsumed = true |
| 81 | + isCanBeResolved = false |
| 82 | + attributes { |
| 83 | + attribute(Category.CATEGORY_ATTRIBUTE, objects.named("third-party-licenses")) |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +artifacts { |
| 88 | + add(releaseBinary.name, tasks.shadowJar) |
| 89 | + add(thirdPartyLicenses.name, tasks.updateThirdPartyLicenses.flatMap { it.outputDirectory }) |
| 90 | +} |
| 91 | + |
| 92 | +/* ******************** compliance ******************** */ |
| 93 | + |
| 94 | +license { |
| 95 | + header = file("HEADER") |
| 96 | + mapping("java", "SLASHSTAR_STYLE") |
| 97 | +} |
| 98 | + |
| 99 | +downloadLicenses { |
| 100 | + aliases = mapOf( |
| 101 | + license("Apache License, Version 2.0", "https://opensource.org/licenses/Apache-2.0") to listOf( |
| 102 | + "Apache 2", |
| 103 | + "Apache 2.0", |
| 104 | + "Apache-2.0", |
| 105 | + "Apache License 2.0", |
| 106 | + "Apache License, 2.0", |
| 107 | + "Apache License v2.0", |
| 108 | + "Apache License, Version 2", |
| 109 | + "Apache License Version 2.0", |
| 110 | + "Apache License, Version 2.0", |
| 111 | + "Apache License, version 2.0", |
| 112 | + "The Apache License, Version 2.0", |
| 113 | + "Apache Software License - Version 2.0", |
| 114 | + "Apache Software License, version 2.0", |
| 115 | + "The Apache Software License, Version 2.0" |
| 116 | + ), |
| 117 | + license("MIT License", "https://opensource.org/licenses/MIT") to listOf( |
| 118 | + "MIT License", |
| 119 | + "MIT license", |
| 120 | + "The MIT License", |
| 121 | + "The MIT License (MIT)" |
| 122 | + ), |
| 123 | + license("CDDL, Version 1.0", "https://opensource.org/licenses/CDDL-1.0") to listOf( |
| 124 | + "CDDL, Version 1.0", |
| 125 | + "Common Development and Distribution License 1.0", |
| 126 | + "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0", |
| 127 | + license("CDDL", "https://glassfish.dev.java.net/public/CDDLv1.0.html") |
| 128 | + ), |
| 129 | + license("CDDL, Version 1.1", "https://oss.oracle.com/licenses/CDDL+GPL-1.1") to listOf( |
| 130 | + "CDDL 1.1", |
| 131 | + "CDDL, Version 1.1", |
| 132 | + "Common Development And Distribution License 1.1", |
| 133 | + "CDDL+GPL License", |
| 134 | + "CDDL + GPLv2 with classpath exception", |
| 135 | + "Dual license consisting of the CDDL v1.1 and GPL v2", |
| 136 | + "CDDL or GPLv2 with exceptions", |
| 137 | + "CDDL/GPLv2+CE" |
| 138 | + ), |
| 139 | + license("LGPL, Version 2.0", "https://opensource.org/licenses/LGPL-2.0") to listOf( |
| 140 | + "LGPL, Version 2.0", |
| 141 | + "GNU General Public License, version 2" |
| 142 | + ), |
| 143 | + license("LGPL, Version 2.1", "https://opensource.org/licenses/LGPL-2.1") to listOf( |
| 144 | + "LGPL, Version 2.1", |
| 145 | + "LGPL, version 2.1", |
| 146 | + "GNU Lesser General Public License version 2.1 (LGPLv2.1)", |
| 147 | + license("GNU Lesser General Public License", "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html") |
| 148 | + ), |
| 149 | + license("LGPL, Version 3.0", "https://opensource.org/licenses/LGPL-3.0") to listOf( |
| 150 | + "LGPL, Version 3.0", |
| 151 | + "Lesser General Public License, version 3 or greater" |
| 152 | + ), |
| 153 | + license("EPL, Version 1.0", "https://opensource.org/licenses/EPL-1.0") to listOf( |
| 154 | + "EPL, Version 1.0", |
| 155 | + "Eclipse Public License - v 1.0", |
| 156 | + "Eclipse Public License - Version 1.0", |
| 157 | + license("Eclipse Public License", "http://www.eclipse.org/legal/epl-v10.html") |
| 158 | + ), |
| 159 | + license("EPL, Version 2.0", "https://opensource.org/licenses/EPL-2.0") to listOf( |
| 160 | + "EPL 2.0", |
| 161 | + "EPL, Version 2.0" |
| 162 | + ), |
| 163 | + license("EDL, Version 1.0", "https://www.eclipse.org/org/documents/edl-v10.php") to listOf( |
| 164 | + "EDL 1.0", |
| 165 | + "EDL, Version 1.0", |
| 166 | + "Eclipse Distribution License - v 1.0" |
| 167 | + ), |
| 168 | + license("BSD 3-Clause License", "https://opensource.org/licenses/BSD-3-Clause") to listOf( |
| 169 | + "BSD 3-clause", |
| 170 | + "BSD-3-Clause", |
| 171 | + "BSD 3-Clause License", |
| 172 | + "3-Clause BSD License", |
| 173 | + "New BSD License", |
| 174 | + license("BSD", "http://asm.ow2.org/license.html"), |
| 175 | + license("BSD", "http://asm.objectweb.org/license.html"), |
| 176 | + license("BSD", "LICENSE.txt") |
| 177 | + ), |
| 178 | + license("Bouncy Castle License", "https://www.bouncycastle.org/licence.html") to listOf( |
| 179 | + "Bouncy Castle Licence" |
| 180 | + ), |
| 181 | + license("W3C License", "https://opensource.org/licenses/W3C") to listOf( |
| 182 | + "W3C License", |
| 183 | + "W3C Software Copyright Notice and License", |
| 184 | + "The W3C Software License" |
| 185 | + ), |
| 186 | + license("CC0", "https://creativecommons.org/publicdomain/zero/1.0/") to listOf( |
| 187 | + "CC0", |
| 188 | + "Public Domain" |
| 189 | + ) |
| 190 | + ) |
| 191 | + |
| 192 | + dependencyConfiguration = "runtimeClasspath" |
| 193 | +} |
| 194 | + |
| 195 | +tasks.updateThirdPartyLicenses { |
| 196 | + dependsOn(tasks.downloadLicenses) |
| 197 | + projectName.set(project.name) |
| 198 | + group = "license" |
| 199 | + dependencyLicense.set(tasks.downloadLicenses.get().xmlDestination.resolve("dependency-license.xml")) |
| 200 | + outputDirectory.set(layout.buildDirectory.dir("distribution/third-party-licenses")) |
| 201 | +} |
| 202 | + |
| 203 | +val javaComponent = components["java"] as AdhocComponentWithVariants |
| 204 | +javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements.get()) { |
| 205 | + skip() |
| 206 | +} |
| 207 | + |
0 commit comments