diff --git a/ExampleVendorJson.json b/ExampleVendorJson.json index 8250cdc..f939ff7 100644 --- a/ExampleVendorJson.json +++ b/ExampleVendorJson.json @@ -1,7 +1,7 @@ { "fileName": "ExampleVendorJson.json", "name": "ExampleVendorDep", - "version": "0.0.1", + "version": "${version}", "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 "mavenUrls": [ @@ -10,16 +10,16 @@ "jsonUrl": "InsertSomeUrlHere", "javaDependencies": [ { - "groupId": "com.vendor.frc", - "artifactId": "Vendor-java", - "version": "0.0.1" + "groupId": "${groupId}", + "artifactId": "${artifactId}-java", + "version": "${version}" } ], "jniDependencies": [ { - "groupId": "com.vendor.frc", - "artifactId": "Vendor-driver", - "version": "0.0.1", + "groupId": "${groupId}", + "artifactId": "${artifactId}-driver", + "version": "${version}", "skipInvalidPlatforms": true, "isJar": false, "validPlatforms": [ @@ -35,9 +35,9 @@ ], "cppDependencies": [ { - "groupId": "com.vendor.frc", - "artifactId": "Vendor-cpp", - "version": "0.0.1", + "groupId": "${groupId}", + "artifactId": "${artifactId}-cpp", + "version": "${version}", "libName": "Vendor", "headerClassifier": "headers", "sharedLibrary": false, @@ -53,9 +53,9 @@ ] }, { - "groupId": "com.vendor.frc", - "artifactId": "Vendor-driver", - "version": "0.0.1", + "groupId": "${groupId}", + "artifactId": "${artifactId}-driver", + "version": "${version}", "libName": "VendorDriver", "headerClassifier": "headers", "sharedLibrary": false, diff --git a/publish.gradle b/publish.gradle index 59c6f5e..8122af6 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,7 +1,12 @@ +import org.apache.tools.ant.filters.FixCrLfFilter +import org.apache.tools.ant.filters.ReplaceTokens + apply plugin: 'maven-publish' ext.licenseFile = files("$rootDir/LICENSE.txt") +def templateVendorFile = "ExampleVendorJson.json" + def pubVersion = '0.0.1' def outputsFolder = file("$buildDir/outputs") @@ -127,6 +132,32 @@ task outputJavadocJar(type: Jar, dependsOn: javadoc) { 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 { archives sourcesJar archives javadocJar @@ -138,10 +169,12 @@ artifacts { addTaskToCopyAllOutputs(outputSourcesJar) addTaskToCopyAllOutputs(outputJavadocJar) addTaskToCopyAllOutputs(outputJar) +addTaskToCopyAllOutputs(vendordepJsonZip) build.dependsOn outputSourcesJar build.dependsOn outputJavadocJar build.dependsOn outputJar +build.dependsOn vendordepJsonZip libraryBuild.dependsOn build @@ -200,6 +233,14 @@ model { groupId artifactGroupId version pubVersion } + + vendordep(MavenPublication) { + artifact vendordepJsonZip + + artifactId = "${baseArtifactId}-vendordep" + groupId artifactGroupId + version pubVersion + } } } }