Files
allwpilib/shared/javacpp/publish.gradle
Gold856 3bf67edc34 [build] Refactor zip base name generation for consistency (#8831)
Right now, the `zipBaseName` variable in various publish.gradle files
contains the group ID and artifact ID for use by the combiner, however,
they are also duplicated in `artifactGroupId` and `baseArtifactId`,
leading to potential mistakes if they aren't updated together. This
fixes that by adding a new utility function `makeZipBaseName` to
automatically create the right name given a group ID and artifact ID.
This also fixes publishing for thirdparty subprojects, which didn't
update `zipBaseName`.
2026-04-27 11:46:11 -07:00

81 lines
1.8 KiB
Groovy

apply plugin: 'maven-publish'
def outputsFolder = file("$buildDir/outputs")
def baseArtifactId = nativeName
def artifactGroupId = "org.wpilib.${nativeName}"
def zipBaseName = makeZipBaseName(artifactGroupId, "${baseArtifactId}-cpp")
def licenseFile = file("$rootDir/license.md")
task cppSourcesZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
archiveClassifier = "sources"
from(licenseFile) {
into '/'
}
from('src/main/native/cpp') {
into '/'
}
from("$buildDir/generated/cpp") {
into '/'
}
from("src/generated/main/native/cpp") {
into '/'
}
}
task cppHeadersZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
archiveClassifier = "headers"
from(licenseFile) {
into '/'
}
ext.includeDirs = [
project.file('src/main/native/include'),
project.file('src/generated/main/native/include')
]
ext.includeDirs.each {
from(it) {
into '/'
}
}
}
artifacts {
tasks.named("assemble") {
dependsOn(cppHeadersZip)
dependsOn(cppSourcesZip)
}
}
addTaskToCopyAllOutputs(cppSourcesZip)
addTaskToCopyAllOutputs(cppHeadersZip)
model {
publishing {
def taskList = createComponentZipTasks($.components, [nativeName], zipBaseName, Zip, project, includeStandardZipFormat)
publications {
cpp(MavenPublication) {
taskList.each {
artifact it
}
artifact cppHeadersZip
artifact cppSourcesZip
artifactId = "${baseArtifactId}-cpp"
groupId = artifactGroupId
version = wpilibVersioning.version.get()
}
}
}
}