diff options
author | jonmv <venstad@gmail.com> | 2022-08-31 11:59:02 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-08-31 11:59:02 +0200 |
commit | bd9d2aa6675d5834a91d91df4e754cd9b75dd34b (patch) | |
tree | 086f0657ddad37db64a78a9b59b7e124993f0926 /vespa-maven-plugin | |
parent | afe641a143b569d4f9b772bae6891a7c933dfce6 (diff) |
Upper bound compile version by parent version
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r-- | vespa-maven-plugin/pom.xml | 5 | ||||
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java | 16 |
2 files changed, 15 insertions, 6 deletions
diff --git a/vespa-maven-plugin/pom.xml b/vespa-maven-plugin/pom.xml index c7ea54a3977..e5b7dec71e4 100644 --- a/vespa-maven-plugin/pom.xml +++ b/vespa-maven-plugin/pom.xml @@ -26,6 +26,11 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> + <artifactId>component</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> <artifactId>config-provisioning</artifactId> <version>${project.version}</version> </dependency> diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java index 4e5c80e1099..5c334935a26 100644 --- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.hosted.plugin; +import com.yahoo.component.Version; +import com.yahoo.component.Vtag; import com.yahoo.text.XML; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -30,14 +32,16 @@ public class CompileVersionMojo extends AbstractVespaMojo { protected void doExecute() throws IOException { Path output = Paths.get(outputFile).toAbsolutePath(); OptionalInt allowMajor = majorVersion(new File(project.getBasedir(), "src/main/application/deployment.xml").toPath()); - String compileVersion = controller.compileVersion(id, allowMajor); - if (allowMajor.isPresent()) { - getLog().info("Allowing major version " + allowMajor.getAsInt() + "."); - } - getLog().info("Vespa version to compile against is '" + compileVersion + "'."); + allowMajor.ifPresent(major -> getLog().info("Allowing only major version " + major + ".")); + + Version compileVersion = Version.fromString(controller.compileVersion(id, allowMajor)); + if (compileVersion.isAfter(Vtag.currentVersion)) + compileVersion = Vtag.currentVersion; + + getLog().info("Vespa version to compile against is '" + compileVersion.toFullString() + "'."); getLog().info("Writing compile version to '" + output + "'."); Files.createDirectories(output.getParent()); - Files.writeString(output, compileVersion); + Files.writeString(output, compileVersion.toFullString()); } /** Returns the major version declared in given deploymentXml, if any */ |