Vendordep Templating. (#41)

* Added templating to the vendordep json.

* Fixed driver reference

* Moved copy to an artifact.

* Moved vendordep generation to `$buildDir/repos/` and added zip task. Maven publication commented out.

* Fixed zip function, uncommented maven publishing for vendordep.

* Update publish.gradle

* Change basename of vendordepJson

Added deps fix.

---------

Co-authored-by: thenetworkgrinch <thenetworkgrinch@users.noreply.github.com>
This commit is contained in:
T Grinch 2024-12-03 00:23:23 -06:00 committed by GitHub
parent 136fdda420
commit 93767cf757
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 54 additions and 13 deletions

View File

@ -1,7 +1,7 @@
{ {
"fileName": "ExampleVendorJson.json", "fileName": "ExampleVendorJson.json",
"name": "ExampleVendorDep", "name": "ExampleVendorDep",
"version": "0.0.1", "version": "${version}",
"frcYear": "2025", "frcYear": "2025",
"uuid": "Generate A Unique GUID https://guidgenerator.com/online-guid-generator.aspx and insert it here", This line is to purposely make this fail to parse "uuid": "Generate A Unique GUID https://guidgenerator.com/online-guid-generator.aspx and insert it here", This line is to purposely make this fail to parse
"mavenUrls": [ "mavenUrls": [
@ -10,16 +10,16 @@
"jsonUrl": "InsertSomeUrlHere", "jsonUrl": "InsertSomeUrlHere",
"javaDependencies": [ "javaDependencies": [
{ {
"groupId": "com.vendor.frc", "groupId": "${groupId}",
"artifactId": "Vendor-java", "artifactId": "${artifactId}-java",
"version": "0.0.1" "version": "${version}"
} }
], ],
"jniDependencies": [ "jniDependencies": [
{ {
"groupId": "com.vendor.frc", "groupId": "${groupId}",
"artifactId": "Vendor-driver", "artifactId": "${artifactId}-driver",
"version": "0.0.1", "version": "${version}",
"skipInvalidPlatforms": true, "skipInvalidPlatforms": true,
"isJar": false, "isJar": false,
"validPlatforms": [ "validPlatforms": [
@ -35,9 +35,9 @@
], ],
"cppDependencies": [ "cppDependencies": [
{ {
"groupId": "com.vendor.frc", "groupId": "${groupId}",
"artifactId": "Vendor-cpp", "artifactId": "${artifactId}-cpp",
"version": "0.0.1", "version": "${version}",
"libName": "Vendor", "libName": "Vendor",
"headerClassifier": "headers", "headerClassifier": "headers",
"sharedLibrary": false, "sharedLibrary": false,
@ -53,9 +53,9 @@
] ]
}, },
{ {
"groupId": "com.vendor.frc", "groupId": "${groupId}",
"artifactId": "Vendor-driver", "artifactId": "${artifactId}-driver",
"version": "0.0.1", "version": "${version}",
"libName": "VendorDriver", "libName": "VendorDriver",
"headerClassifier": "headers", "headerClassifier": "headers",
"sharedLibrary": false, "sharedLibrary": false,

View File

@ -1,7 +1,12 @@
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
ext.licenseFile = files("$rootDir/LICENSE.txt") ext.licenseFile = files("$rootDir/LICENSE.txt")
def templateVendorFile = "ExampleVendorJson.json"
def pubVersion = '0.0.1' def pubVersion = '0.0.1'
def outputsFolder = file("$buildDir/outputs") def outputsFolder = file("$buildDir/outputs")
@ -127,6 +132,32 @@ task outputJavadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir from javadoc.destinationDir
} }
// Apply template variables from the vendordep file.
// Replaces ${VARIABLE} with VARIABLE: value in expand()
task vendordepJson() {
description = 'Builds the vendordep json file.'
group = 'Build'
outputs.file("$buildDir/repos/$templateVendorFile")
copy {
from templateVendorFile
into "$buildDir/repos/"
expand(version: pubVersion,
groupId: artifactGroupId,
artifactId: baseArtifactId)
}
}
task vendordepJsonZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = "vendordepJson"
from("$buildDir/repos/$templateVendorFile") {
into '/'
}
dependsOn vendordepJson
}
artifacts { artifacts {
archives sourcesJar archives sourcesJar
archives javadocJar archives javadocJar
@ -138,10 +169,12 @@ artifacts {
addTaskToCopyAllOutputs(outputSourcesJar) addTaskToCopyAllOutputs(outputSourcesJar)
addTaskToCopyAllOutputs(outputJavadocJar) addTaskToCopyAllOutputs(outputJavadocJar)
addTaskToCopyAllOutputs(outputJar) addTaskToCopyAllOutputs(outputJar)
addTaskToCopyAllOutputs(vendordepJsonZip)
build.dependsOn outputSourcesJar build.dependsOn outputSourcesJar
build.dependsOn outputJavadocJar build.dependsOn outputJavadocJar
build.dependsOn outputJar build.dependsOn outputJar
build.dependsOn vendordepJsonZip
libraryBuild.dependsOn build libraryBuild.dependsOn build
@ -200,6 +233,14 @@ model {
groupId artifactGroupId groupId artifactGroupId
version pubVersion version pubVersion
} }
vendordep(MavenPublication) {
artifact vendordepJsonZip
artifactId = "${baseArtifactId}-vendordep"
groupId artifactGroupId
version pubVersion
}
} }
} }
} }