fix: qbit metadata version comes from the build #15

Merged
KofTwentyTwo merged 1 commits from fix/producer-version-from-build into develop 2026-10-15 06:42:59 +00:00
6 changed files with 55 additions and 2 deletions

No files matched your search

+1
View File
@@ -5,6 +5,7 @@ All notable changes to this project are documented here. The format follows Keep
## [0.1.0] - Unreleased
### Fixed
- Read the QBit metadata version from the build so release artifacts report their actual version, matching the help bundle.
- Use dropdowns for tier, scope, source, strategy, metric, comparator and severity, preserving existing stored values.
- Allow manual Tested Pages inserts with a URL. Validate absolute HTTPS URLs and fill in the site, path and Manual source automatically; validate URL edits too.
+11
View File
@@ -137,6 +137,7 @@
<filtering>true</filtering>
<includes>
<include>help/*.yaml</include>
<include>qbit-web-performance.properties</include>
</includes>
</resource>
<resource>
@@ -144,10 +145,20 @@
<filtering>false</filtering>
<excludes>
<exclude>help/*.yaml</exclude>
<exclude>qbit-web-performance.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables combine.children="append">
<qbit.artifactVersion>${project.version}</qbit.artifactVersion>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
@@ -21,8 +21,11 @@
package com.kingsrook.qbits.webperf;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.kingsrook.qbits.webperf.metadata.WebPerfMetaData;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.logging.QLogger;
@@ -62,13 +65,41 @@ public class WebPerfQBitProducer implements QBitMetaDataProducer<WebPerfQBitConf
public static final String GROUP_ID = "com.kingsrook.qbits";
public static final String ARTIFACT_ID = "web-performance";
public static final String VERSION = "0.1.0";
public static final String VERSION = loadVersion();
private WebPerfQBitConfig qBitConfig;
private String namespace;
/*******************************************************************************
** Read the artifact version from the Maven-filtered properties resource.
*******************************************************************************/
private static String loadVersion()
{
try(InputStream inputStream = WebPerfQBitProducer.class.getClassLoader().getResourceAsStream("qbit-web-performance.properties"))
{
if(inputStream == null)
{
throw (new IllegalStateException("Missing qbit-web-performance.properties; build with Maven to generate the 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-web-performance.properties; build with Maven"));
}
return (version);
}
catch(IOException e)
{
throw (new IllegalStateException("Could not read artifact version from qbit-web-performance.properties", e));
}
}
/*******************************************************************************
** Fluent setter for the config.
**
@@ -0,0 +1 @@
version=${project.version}
@@ -45,7 +45,13 @@ class WebPerfHelpBundleTest
assertThat(qInstance.getTable("helpContent")).isNull();
assertThat(HelpBundles.of(qInstance).getBundles()).singleElement()
.satisfies(bundle -> assertThat(bundle.getId()).isEqualTo("qbit-web-performance"));
.satisfies(bundle ->
{
assertThat(bundle.getId()).isEqualTo("qbit-web-performance");
assertThat(System.getProperty("qbit.artifactVersion")).isNotBlank();
assertThat(bundle.getVersion()).isEqualTo(System.getProperty("qbit.artifactVersion"))
.isEqualTo(WebPerfQBitProducer.VERSION);
});
HelpBundleAssertions.forInstance(qInstance)
.bundles("help/qbit-web-performance.yaml")
.owning(target -> target.name().startsWith("web_performance_") || target.name().startsWith("webPerformance"))
@@ -74,6 +74,9 @@ class WebPerfQBitProducerTest
@Test
void testRegistersIntoAFreshInstance() throws Exception
{
assertThat(System.getProperty("qbit.artifactVersion")).isNotBlank();
assertThat(WebPerfQBitProducer.VERSION).isEqualTo(System.getProperty("qbit.artifactVersion"));
assertThat(new WebPerfQBitProducer().getQBitMetaData().getVersion()).isEqualTo(WebPerfQBitProducer.VERSION);
QInstance qInstance = WebPerfTestSupport.newInstance();
new WebPerfQBitProducer().withQBitConfig(WebPerfTestSupport.config()
.withUrlSource(new SitemapUrlSource("https://www.example.com/sitemap.xml"))