diff --git a/CHANGELOG.md b/CHANGELOG.md index cf7b4b3..080b061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ All notable changes to this project are documented here. The format follows Keep ### Fixed +- Derive the CDN qbit metadata version from the Maven artifact version, keeping release metadata and the help bundle in sync. - Tag rules accept ignored fields in `onlyWhenFieldsChange`, such as `!viewCount`, so counter-only updates do not purge rendered pages. Plain allow-lists still work, and ignored fields take precedence in mixed lists. No schema change is needed. - Purge actions warn when providers are NONE or hostnames are OFF, and report requests as recorded but not sent. The home explains recorded-only purges and that this version does not run origin header checks. - Tag rule `{prefix.field}` placeholders now resolve the joined table from the `Id` field's possible-value source, so prefixed tables (`cms_blog`) work; a missing joined table is logged instead of silently skipped. diff --git a/pom.xml b/pom.xml index ed193b2..d35fbb3 100644 --- a/pom.xml +++ b/pom.xml @@ -113,6 +113,7 @@ true help/*.yaml + qbit-cdn.properties @@ -120,6 +121,7 @@ false help/*.yaml + qbit-cdn.properties diff --git a/src/main/java/com/kingsrook/qbits/cdn/CdnQBitProducer.java b/src/main/java/com/kingsrook/qbits/cdn/CdnQBitProducer.java index 9d8a32c..e477d41 100644 --- a/src/main/java/com/kingsrook/qbits/cdn/CdnQBitProducer.java +++ b/src/main/java/com/kingsrook/qbits/cdn/CdnQBitProducer.java @@ -17,8 +17,11 @@ package com.kingsrook.qbits.cdn; +import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import com.kingsrook.qbits.cdn.app.CdnWidgets; import com.kingsrook.qbits.cdn.health.CdnProviderHealthChecks; import com.kingsrook.qbits.cdn.model.CdnTables; @@ -48,13 +51,41 @@ public class CdnQBitProducer implements QBitMetaDataProducer { public static final String GROUP_ID = "com.kingsrook.qbits"; public static final String ARTIFACT_ID = "qbit-cdn"; - public static final String VERSION = "0.1.0"; + public static final String VERSION = loadVersion(); private CdnQBitConfig qBitConfig; private String namespace; + /******************************************************************************* + ** Read the artifact version from the Maven-filtered resource. + *******************************************************************************/ + private static String loadVersion() + { + try(InputStream inputStream = CdnQBitProducer.class.getClassLoader().getResourceAsStream("qbit-cdn.properties")) + { + if(inputStream == null) + { + throw (new IllegalStateException("Missing qbit-cdn.properties; cannot determine the CDN qbit artifact version.")); + } + Properties properties = new Properties(); + properties.load(inputStream); + String version = properties.getProperty("version"); + if(version == null || version.isBlank() || version.contains("${")) + { + throw (new IllegalStateException("Missing or unfiltered version in qbit-cdn.properties; build with Maven resource filtering.")); + } + return (version); + } + catch(IOException e) + { + throw (new IllegalStateException("Could not read the CDN qbit artifact version from qbit-cdn.properties.", e)); + } + } + + + /******************************************************************************* ** Fluent setter for the config. *******************************************************************************/ diff --git a/src/main/resources/qbit-cdn.properties b/src/main/resources/qbit-cdn.properties new file mode 100644 index 0000000..defbd48 --- /dev/null +++ b/src/main/resources/qbit-cdn.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/src/test/java/com/kingsrook/qbits/cdn/CdnHelpBundleTest.java b/src/test/java/com/kingsrook/qbits/cdn/CdnHelpBundleTest.java index d4466b1..210c756 100644 --- a/src/test/java/com/kingsrook/qbits/cdn/CdnHelpBundleTest.java +++ b/src/test/java/com/kingsrook/qbits/cdn/CdnHelpBundleTest.java @@ -65,7 +65,7 @@ class CdnHelpBundleTest assertThat(instance.getTable("helpContent")).isNull(); var bundle = HelpBundles.of(instance).getBundles().get(0); assertThat(bundle.getId()).isEqualTo("qbit-cdn"); - assertThat(bundle.getVersion()).as("the help bundle carries the artifact version").isEqualTo(System.getProperty("qbit.artifactVersion")); + assertThat(bundle.getVersion()).as("the help bundle carries the artifact version").isEqualTo(System.getProperty("qbit.artifactVersion")).isEqualTo(CdnQBitProducer.VERSION); assertThat(bundle.getLayer()).isEqualTo(HelpBundleLayer.QBIT); assertThat(bundle.getEntries()).extracting(entry -> entry.getKey()).doesNotHaveDuplicates(); // Core's gate does not require widgets or possible-value sources yet. diff --git a/src/test/java/com/kingsrook/qbits/cdn/CdnQBitProducerTest.java b/src/test/java/com/kingsrook/qbits/cdn/CdnQBitProducerTest.java index 5dc3ff6..77a431d 100644 --- a/src/test/java/com/kingsrook/qbits/cdn/CdnQBitProducerTest.java +++ b/src/test/java/com/kingsrook/qbits/cdn/CdnQBitProducerTest.java @@ -34,6 +34,18 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; *******************************************************************************/ class CdnQBitProducerTest { + /******************************************************************************* + ** Metadata must report the version of the artifact being built. + *******************************************************************************/ + @Test + void metadataVersionMatchesArtifact() + { + assertThat(System.getProperty("qbit.artifactVersion")).isNotBlank().isEqualTo(CdnQBitProducer.VERSION); + assertThat(new CdnQBitProducer().getQBitMetaData().getVersion()).isEqualTo(System.getProperty("qbit.artifactVersion")); + } + + + /******************************************************************************* ** Everything is produced and the instance is valid. *******************************************************************************/