Skip to content

Commit f0f9685

Browse files
committed
Migrate to Gradle 9 and the Kotlin DSL
1 parent e514b82 commit f0f9685

112 files changed

Lines changed: 2423 additions & 2704 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ bin/
3232

3333
# Ignore the Gradle cache directory.
3434
.gradle/
35+
36+
# Ignore .kotlin directories
37+
.kotlin/
38+
3539
# Ignore the output that Gradle generates in the "build/" directories...
3640
build/
41+
3742
# ...but not the source code in the "edu.ucar.build" package inside buildSrc
3843
!**/src/**/edu/ucar/build/
3944

bufr/build.gradle

Lines changed: 0 additions & 25 deletions
This file was deleted.

bufr/build.gradle.kts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
6+
plugins {
7+
id("java-library-conventions")
8+
id("protobuf-conventions")
9+
}
10+
11+
description = "Reading BUFR files with the NetCDF-java library."
12+
13+
extra["project.title"] = "BUFR IOSP"
14+
15+
dependencies {
16+
implementation(platform(project(":netcdf-java-platform")))
17+
18+
api(project(":cdm-core"))
19+
20+
implementation(libs.beust.jcommander)
21+
implementation(libs.findbugs.jsr305)
22+
implementation(libs.guava)
23+
implementation(libs.jdom2)
24+
implementation(libs.protobuf)
25+
implementation(libs.re2j)
26+
implementation(libs.slf4j.api)
27+
28+
testImplementation(platform(project(":netcdf-java-testing-platform")))
29+
30+
testImplementation(project(":cdm-test-utils"))
31+
32+
testImplementation(libs.google.truth)
33+
testImplementation(libs.junit4)
34+
testImplementation(libs.junit5.vintageEngine)
35+
36+
testRuntimeOnly(libs.junit5.platformLauncher)
37+
}

build-logic/build.gradle.kts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
6+
plugins {
7+
`kotlin-dsl`
8+
alias(libs.plugins.protobuf)
9+
alias(libs.plugins.spotless)
10+
}
11+
12+
dependencies {
13+
implementation(plugin(libs.plugins.protobuf))
14+
implementation(plugin(libs.plugins.spotless))
15+
}
16+
17+
spotless {
18+
kotlinGradle {
19+
target("*.gradle.kts", "**/*.gradle.kts")
20+
ktfmt().googleStyle()
21+
}
22+
}
23+
24+
// Helper function that transforms a plugin alias from the version catalog
25+
// into a valid dependency notation
26+
fun plugin(plugin: Provider<PluginDependency>) =
27+
plugin.map { "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" }

build-logic/settings.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
6+
dependencyResolutionManagement {
7+
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
8+
repositories {
9+
mavenCentral()
10+
gradlePluginPortal()
11+
}
12+
versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } }
13+
}
14+
15+
rootProject.name = "build-logic"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
6+
plugins { `maven-publish` }
7+
8+
publishing {
9+
repositories {
10+
maven {
11+
if ((project.extra.get("project.isRelease") as? Boolean ?: false)) {
12+
name = "releases"
13+
url = uri("https://artifacts.unidata.ucar.edu/repository/unidata-releases/")
14+
} else {
15+
name = "snapshots"
16+
url = uri("https://artifacts.unidata.ucar.edu/repository/unidata-snapshots/")
17+
}
18+
credentials {
19+
username = extra.properties["nexus.username"] as? String
20+
password = extra.properties["nexus.password"] as? String
21+
}
22+
}
23+
}
24+
}
25+
26+
tasks.withType<GenerateModuleMetadata> { enabled = false }
27+
28+
val augmentPom =
29+
tasks.register("augmentPom") {
30+
publishing.publications.filterIsInstance<MavenPublication>().forEach { pub ->
31+
pub.pom {
32+
name.set("${project.group}:${project.name}")
33+
url.set("${project.extra.get("project.url")}")
34+
description.set("${project.description}")
35+
licenses {
36+
license {
37+
name.set("BSD 3-Clause License")
38+
url.set("https://github.com/Unidata/netcdf-java/blob/maint-5.x/LICENSE")
39+
}
40+
}
41+
developers {
42+
developer {
43+
name.set("netCDF-Java Developers")
44+
email.set("support-netcdf-java@unidata.ucar.edu")
45+
organization.set("NSF Unidata")
46+
organizationUrl.set("https://unidata.ucar.edu")
47+
}
48+
}
49+
scm {
50+
connection.set("scm:git:https://github.com/unidata/netcdf-java.git")
51+
developerConnection.set("scm:git:https://github.com/unidata/netcdf-java.git")
52+
url.set("https://github.com/unidata/netcdf-java")
53+
}
54+
}
55+
}
56+
}
57+
58+
tasks.withType<GenerateMavenPom>().configureEach { dependsOn(augmentPom) }
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
6+
plugins { base }
7+
8+
val catalogs = extensions.getByType<VersionCatalogsExtension>()
9+
10+
group = "edu.ucar"
11+
12+
version = catalogs.named("libs").findVersion("netcdf-java").get().requiredVersion
13+
14+
description = "A component to the Unidata netCDF-Java library (aka CDM)."
15+
16+
extra["project.isRelease"] = !version.toString().endsWith("SNAPSHOT")
17+
18+
extra["project.title"] = "CDM modules"
19+
20+
extra["project.vendor"] = "UCAR/Unidata"
21+
22+
extra["project.url"] = "https://www.unidata.ucar.edu/software/netcdf-java/"
23+
24+
val docVersionParts = version.toString().split("-")[0].split(".")
25+
26+
assert(docVersionParts.size == 3)
27+
28+
extra["docVersion"] = docVersionParts[0] + "." + docVersionParts[1]
29+
30+
// list of subprojects that are intended for public use and make up the netCDF-Java project
31+
// this is used by the netcdf-java-bom, docs, and code-coverage-report
32+
// subprojects
33+
val publicArtifacts =
34+
listOf(
35+
":bufr",
36+
":cdm-core",
37+
":cdm-image",
38+
":cdm-mcidas",
39+
":cdm-misc",
40+
":cdm-radial",
41+
":cdm-s3",
42+
":cdm-vis5d",
43+
":cdm-zarr",
44+
":dap4",
45+
":gcdm",
46+
":grib",
47+
":httpservices",
48+
":legacy",
49+
":libaec-jna",
50+
":libaec-native",
51+
":netcdf4",
52+
":opendap",
53+
":udunits",
54+
":waterml",
55+
)
56+
57+
project.extra["public.artifacts"] = publicArtifacts
58+
59+
// the minimumVersion of java supported
60+
// will be the bytecode produced by the project for all java compilation
61+
// will be used to run the tests (test, not testWithJdkX), generate code coverage reports, etc.
62+
// other versions of java can be used to run the tests, but this is configured in
63+
// testing-conventions.gradle.kts
64+
project.extra["project.minimumJdkVersion"] = "8"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
6+
plugins {
7+
id("base-conventions")
8+
id("testing-conventions")
9+
}
10+
11+
tasks {
12+
// everything gets compiled to the minimum supported version byte code
13+
withType<JavaCompile>().configureEach {
14+
options.release = project.extra["project.minimumJdkVersion"].toString().toInt()
15+
}
16+
17+
withType<Javadoc>().configureEach {
18+
group = "documentation"
19+
options {
20+
encoding = "UTF-8"
21+
// options past here require the standard java doclet
22+
require(this is StandardJavadocDocletOptions)
23+
charSet = "UTF-8"
24+
docEncoding = "UTF-8"
25+
addStringOption("-release", "8")
26+
// so many invalid HTML errors...need to add this for now to
27+
// generate javadocs
28+
addBooleanOption("Xdoclint:none", true)
29+
}
30+
}
31+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
6+
plugins {
7+
id("java-base-conventions")
8+
`java-library`
9+
id("artifact-publishing-conventions")
10+
id("com.diffplug.spotless")
11+
}
12+
13+
java { withSourcesJar() }
14+
15+
tasks.withType<Jar>().configureEach {
16+
duplicatesStrategy = DuplicatesStrategy.FAIL
17+
manifest {
18+
attributes["Implementation-Title"] = project.extra.get("project.title")
19+
attributes["Implementation-Version"] = "${project.version}"
20+
attributes["Implementation-Vendor-Id"] = "${project.group}"
21+
attributes["Implementation-Vendor"] = project.extra.get("project.vendor")
22+
attributes["Implementation-URL"] = project.extra.get("project.url")
23+
attributes["Created-By"] = "Gradle ${gradle.gradleVersion}"
24+
System.getProperty("java.version")?.let { attributes["Build-Jdk"] = it }
25+
System.getProperty("user.name")?.let { attributes["Built-By"] = it }
26+
}
27+
28+
from(rootDir.absolutePath) {
29+
include("LICENSE")
30+
into("META-INF/")
31+
}
32+
}
33+
34+
publishing {
35+
publications {
36+
create<MavenPublication>("mavenJava") {
37+
from(components["java"])
38+
versionMapping {
39+
usage("java-api") { fromResolutionOf("runtimeClasspath") }
40+
usage("java-runtime") { fromResolutionResult() }
41+
}
42+
}
43+
}
44+
}
45+
46+
spotless {
47+
java {
48+
target("src/*/java/**/*.java")
49+
eclipse().configFile("$rootDir/project-files/code-styles/eclipse-style-guide.xml")
50+
encoding("UTF-8")
51+
}
52+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
6+
import org.gradle.api.publish.maven.MavenPublication
7+
import org.gradle.kotlin.dsl.create
8+
9+
plugins {
10+
id("base-conventions")
11+
`java-platform`
12+
id("artifact-publishing-conventions")
13+
}
14+
15+
publishing {
16+
publications { create<MavenPublication>("platform") { from(components["javaPlatform"]) } }
17+
}

0 commit comments

Comments
 (0)