From e337a30ca89055a6aa3f7aa9267d2f1e523e7bdd Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Tue, 7 Jun 2022 13:21:48 +0200 Subject: Add back support for version in config definition Add warning message, add TODO to remove in Vespa 9 --- .../java/com/yahoo/config/codegen/DefParser.java | 7 +++++ .../com/yahoo/config/codegen/DefParserTest.java | 33 +++++++++++++++++----- 2 files changed, 33 insertions(+), 7 deletions(-) (limited to 'configgen/src') diff --git a/configgen/src/main/java/com/yahoo/config/codegen/DefParser.java b/configgen/src/main/java/com/yahoo/config/codegen/DefParser.java index 63cd1deb1f7..2ed0bc62d0b 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/DefParser.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/DefParser.java @@ -18,6 +18,8 @@ public class DefParser { public static final String DEFAULT_PACKAGE_PREFIX = "com.yahoo."; static final Pattern commentPattern = Pattern.compile("^\\s*#+\\s*(.*?)\\s*$"); + // TODO: Version is ignored, remove in Vespa 9 + public static final Pattern versionPattern = Pattern.compile("^(version\\s*=\\s*)([0-9][0-9-]*)$"); // Namespace/package must start with a letter, since Java (Java language Spec, section 3.8) and C++ identifiers cannot start with a digit public static final Pattern namespacePattern = getNamespacePattern("namespace"); public static final Pattern packagePattern = getNamespacePattern("package"); @@ -123,6 +125,11 @@ public class DefParser { parseCommentLine(commentMatch); return; } + Matcher versionMatch = versionPattern.matcher(line); + if (versionMatch.matches()) { + System.err.println("Warning: In config definition '" + name + "': version is deprecated and ignored, please remove, support will be removed in Vespa 9"); + return; + } Matcher namespaceMatcher = namespacePattern.matcher(line); if (namespaceMatcher.matches()) { parseNamespaceLine(namespaceMatcher.group(2)); diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java index 5ba2c01449b..915edce1440 100644 --- a/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java +++ b/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java @@ -1,19 +1,18 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.codegen; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.Test; import org.junit.Ignore; - +import org.junit.Test; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.StringReader; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Unit tests for DefParser. * @@ -83,6 +82,26 @@ public class DefParserTest { assertEquals("a5e5fdbb2b27e56ba7d5e60e335c598b", root.defMd5); } + // TODO: Version is not used anymore, remove test in Vespa 9 + @Test + public void testValidVersions() { + try { + parse("version=8"); + parse("version=8-1"); + parse("version =8"); + parse("version = 8"); + parse("version = 8 "); + parse("version =\t8"); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + private void parse(String versionLine) { + InnerCNode ignored = createParser(versionLine).getTree(); + } + @Test public void testInvalidType() { String line = "a sting"; -- cgit v1.2.3