Files
allwpilib/wpilibcExamples/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

100 lines
2.3 KiB
Groovy

apply plugin: 'maven-publish'
def baseExamplesArtifactId = 'examples'
def baseTemplatesArtifactId = 'templates'
def baseCommandsArtifactId = 'commands'
def artifactGroupId = 'org.wpilib.wpilibc'
def examplesZipBaseName = makeZipBaseName(artifactGroupId, baseExamplesArtifactId)
def templatesZipBaseName = makeZipBaseName(artifactGroupId, baseTemplatesArtifactId)
def commandsZipBaseName = makeZipBaseName(artifactGroupId, baseCommandsArtifactId)
def outputsFolder = file("$project.buildDir/outputs")
task cppExamplesZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = examplesZipBaseName
from(licenseFile) {
into '/'
}
from('src/main/cpp/examples') {
into 'examples'
}
from('src/test/cpp/examples') {
into 'examples_test'
}
}
task cppTemplatesZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = templatesZipBaseName
from(licenseFile) {
into '/'
}
from('src/main/cpp/templates') {
into 'templates'
}
from('src/test/cpp/templates') {
into 'templates_test'
}
}
task cppCommandsZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = commandsZipBaseName
from(licenseFile) {
into '/'
}
from('src/main/cpp/commands') {
into 'commands'
}
from('src/test/cpp/commands') {
into 'commands_test'
}
}
build.dependsOn cppTemplatesZip
build.dependsOn cppExamplesZip
build.dependsOn cppCommandsZip
addTaskToCopyAllOutputs(cppTemplatesZip)
addTaskToCopyAllOutputs(cppExamplesZip)
addTaskToCopyAllOutputs(cppCommandsZip)
publishing {
publications {
examples(MavenPublication) {
artifact cppExamplesZip
artifactId = baseExamplesArtifactId
groupId = artifactGroupId
version = wpilibVersioning.version.get()
}
templates(MavenPublication) {
artifact cppTemplatesZip
artifactId = baseTemplatesArtifactId
groupId = artifactGroupId
version = wpilibVersioning.version.get()
}
commands(MavenPublication) {
artifact cppCommandsZip
artifactId = baseCommandsArtifactId
groupId = artifactGroupId
version = wpilibVersioning.version.get()
}
}
}