From 394c04ac5bdaea3a56ac01f123d09af75f8e550d Mon Sep 17 00:00:00 2001 From: gjoranv Date: Mon, 3 Jul 2023 14:38:24 +0200 Subject: Depend on container-dev and allow embeddeding provided deps for now. --- config-model/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'config-model') diff --git a/config-model/pom.xml b/config-model/pom.xml index a634a40c93b..a05a246cc4b 100644 --- a/config-model/pom.xml +++ b/config-model/pom.xml @@ -300,6 +300,11 @@ com.yahoo.vespa bundle-plugin true + + com.fasterxml.jackson.core:jackson-annotations:2.15.2, com.fasterxml.jackson.core:jackson-core:2.15.2, + com.fasterxml.jackson.core:jackson-databind:2.15.2, com.yahoo.vespa:metrics:*, com.yahoo.vespa:predicate-search-core:*, + com.yahoo.vespa:searchcore:* + org.apache.maven.plugins -- cgit v1.2.3 From bd719b81d00c7015b820c93f2d1ef460c97f64cc Mon Sep 17 00:00:00 2001 From: gjoranv Date: Tue, 4 Jul 2023 13:25:33 +0200 Subject: Do not use version for allowed embedded artifacts. - Rename ArtifactInfo -> ArtifactId and simply ignore versions. --- .../plugin/mojo/GenerateOsgiManifestMojo.java | 23 +++++---- .../mojo/GenerateProvidedArtifactManifestMojo.java | 3 ++ .../yahoo/container/plugin/util/ArtifactId.java | 56 ++++++++++++++++++++ .../yahoo/container/plugin/util/ArtifactInfo.java | 59 ---------------------- .../com/yahoo/container/plugin/util/JarFiles.java | 4 +- cloud-tenant-cd/pom.xml | 4 +- config-model/pom.xml | 6 +-- configserver/pom.xml | 4 +- jdisc-cloud-aws/pom.xml | 4 +- zkfacade/pom.xml | 4 +- 10 files changed, 85 insertions(+), 82 deletions(-) create mode 100644 bundle-plugin/src/main/java/com/yahoo/container/plugin/util/ArtifactId.java delete mode 100644 bundle-plugin/src/main/java/com/yahoo/container/plugin/util/ArtifactInfo.java (limited to 'config-model') diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java index 304845d4dea..8f588ffa5b0 100644 --- a/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java +++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java @@ -8,7 +8,7 @@ import com.yahoo.container.plugin.classanalysis.PackageTally; import com.yahoo.container.plugin.osgi.ExportPackages; import com.yahoo.container.plugin.osgi.ExportPackages.Export; import com.yahoo.container.plugin.osgi.ImportPackages.Import; -import com.yahoo.container.plugin.util.ArtifactInfo; +import com.yahoo.container.plugin.util.ArtifactId; import com.yahoo.container.plugin.util.Artifacts; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; @@ -245,17 +245,20 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo { } private void logProvidedArtifactsIncluded(List includedArtifacts, - List providedArtifacts) throws MojoExecutionException { + List providedArtifacts) throws MojoExecutionException { if (effectiveBundleType() == BundleType.CORE) return; - Set included = includedArtifacts.stream().map(ArtifactInfo::fromArtifact).collect(Collectors.toSet()); - Set providedIncluded = Sets.intersection(included, new HashSet<>(providedArtifacts)); + Set included = includedArtifacts.stream().map(ArtifactId::fromArtifact).collect(Collectors.toSet()); + getLog().debug("Included artifacts: " + included); + getLog().debug("Provided artifacts: " + providedArtifacts); - HashSet allowed = getAllowedEmbeddedArtifacts(providedIncluded); + Set includedProvided = Sets.intersection(included, new HashSet<>(providedArtifacts)); + getLog().debug("Included provided artifacts: " + includedProvided); + HashSet allowed = getAllowedEmbeddedArtifacts(includedProvided); - List violations = providedIncluded.stream() + List violations = includedProvided.stream() .filter(a -> ! allowed.contains(a)) - .map(ArtifactInfo::stringValue) + .map(ArtifactId::stringValue) .sorted().toList(); if (! violations.isEmpty()) { @@ -265,12 +268,12 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo { } } - private HashSet getAllowedEmbeddedArtifacts(Set providedIncluded) throws MojoExecutionException { + private HashSet getAllowedEmbeddedArtifacts(Set providedIncluded) throws MojoExecutionException { if (allowEmbeddedArtifacts.isEmpty()) return new HashSet<>(); - var allowed = new HashSet(); + var allowed = new HashSet(); try { - allowEmbeddedArtifacts.stream().map(ArtifactInfo::fromStringValue).forEach(allowed::add); + allowEmbeddedArtifacts.stream().map(ArtifactId::fromStringValue).forEach(allowed::add); } catch (Exception e) { throw new MojoExecutionException("In config parameter 'allowEmbeddedArtifacts': " + e.getMessage(), e); } diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateProvidedArtifactManifestMojo.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateProvidedArtifactManifestMojo.java index ee35c559e48..b4c474fc72d 100644 --- a/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateProvidedArtifactManifestMojo.java +++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateProvidedArtifactManifestMojo.java @@ -24,6 +24,9 @@ import java.util.jar.JarOutputStream; import java.util.jar.Manifest; /** + * Replaces the Class-Path of a jar file manifest with a list of provided artifacts. + * The Class-Path is used because it is trivial to generate with the maven-jar-plugin. + * * @author gjoranv */ @Mojo(name = "generate-provided-artifact-manifest", requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true) diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/ArtifactId.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/ArtifactId.java new file mode 100644 index 00000000000..2786a9c559f --- /dev/null +++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/ArtifactId.java @@ -0,0 +1,56 @@ +package com.yahoo.container.plugin.util; + +import org.apache.maven.artifact.Artifact; + +import java.util.Objects; + +/** + * Helper class to work with artifacts, where version does not matter. + * + * @author gjoranv + */ +public class ArtifactId { + + private final String groupId; + private final String artifactId; + + private ArtifactId(String groupId, String artifactId) { + this.groupId = groupId; + this.artifactId = artifactId; + } + + public static ArtifactId fromArtifact(Artifact artifact) { + return new ArtifactId(artifact.getGroupId(), artifact.getArtifactId()); + } + + public static ArtifactId fromStringValue(String stringValue) { + var parts = stringValue.trim().split(":"); + if (parts.length == 2 || parts.length == 3) { + return new ArtifactId(parts[0], parts[1]); + } + throw new IllegalArgumentException( + "An artifact should be represented in the format 'groupId:ArtifactId[:version]', not: " + stringValue); + } + + public String stringValue() { + return groupId + ":" + artifactId; + } + + @Override + public String toString() { + return stringValue(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ArtifactId that = (ArtifactId) o; + return Objects.equals(groupId, that.groupId) && Objects.equals(artifactId, that.artifactId); + } + + @Override + public int hashCode() { + return Objects.hash(groupId, artifactId); + } +} diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/ArtifactInfo.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/ArtifactInfo.java deleted file mode 100644 index 490a9241661..00000000000 --- a/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/ArtifactInfo.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.yahoo.container.plugin.util; - -import org.apache.maven.artifact.Artifact; - -import java.util.Objects; - -import static com.yahoo.container.plugin.util.Artifacts.VESPA_GROUP_ID; - -/** - * Helper class to work with artifacts. Vespa artifacts have their version set to '*'. - * - * @author gjoranv - */ -public class ArtifactInfo { - - private final String groupId; - private final String artifactId; - private final String version; - - private ArtifactInfo(String groupId, String artifactId, String version) { - this.groupId = groupId; - this.artifactId = artifactId; - this.version = VESPA_GROUP_ID.equals(groupId) ? "*" : version; - } - - public static ArtifactInfo fromArtifact(Artifact artifact) { - return new ArtifactInfo(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); - } - - public static ArtifactInfo fromStringValue(String stringValue) { - var parts = stringValue.trim().split(":"); - if (parts.length != 3) { - throw new IllegalArgumentException("Invalid artifact string: " + stringValue); - } - return new ArtifactInfo(parts[0], parts[1], parts[2]); - } - - public String stringValue() { - return groupId + ":" + artifactId + ":" + version; - } - - @Override - public String toString() { - return stringValue(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ArtifactInfo that = (ArtifactInfo) o; - return Objects.equals(groupId, that.groupId) && Objects.equals(artifactId, that.artifactId) && Objects.equals(version, that.version); - } - - @Override - public int hashCode() { - return Objects.hash(groupId, artifactId, version); - } -} diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/JarFiles.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/JarFiles.java index 846301ccd5c..3ef58fc87b6 100644 --- a/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/JarFiles.java +++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/JarFiles.java @@ -20,10 +20,10 @@ import static com.yahoo.container.plugin.mojo.GenerateProvidedArtifactManifestMo */ public class JarFiles { - public static List providedArtifactsFromManifest(File jarFile) { + public static List providedArtifactsFromManifest(File jarFile) { return getManifest(jarFile).map(mf -> getMainAttributeValue(mf, PROVIDED_ARTIFACTS_MANIFEST_ENTRY) .map(s -> Arrays.stream(s.split(",")) - .map(ArtifactInfo::fromStringValue) + .map(ArtifactId::fromStringValue) .toList()) .orElse(Collections.emptyList())) .orElse(Collections.emptyList()); diff --git a/cloud-tenant-cd/pom.xml b/cloud-tenant-cd/pom.xml index 11e680f75d8..0574177dd7a 100644 --- a/cloud-tenant-cd/pom.xml +++ b/cloud-tenant-cd/pom.xml @@ -83,8 +83,8 @@ bundle-plugin true - com.fasterxml.jackson.core:jackson-core:2.15.2, com.yahoo.vespa:annotations:8-SNAPSHOT, - org.bouncycastle:bcpkix-jdk18on:1.74, org.bouncycastle:bcprov-jdk18on:1.74, org.bouncycastle:bcutil-jdk18on:1.74 + com.fasterxml.jackson.core:jackson-core, com.yahoo.vespa:annotations, + org.bouncycastle:bcpkix-jdk18on, org.bouncycastle:bcprov-jdk18on, org.bouncycastle:bcutil-jdk18on true diff --git a/config-model/pom.xml b/config-model/pom.xml index a05a246cc4b..afb5a7f49c0 100644 --- a/config-model/pom.xml +++ b/config-model/pom.xml @@ -301,9 +301,9 @@ bundle-plugin true - com.fasterxml.jackson.core:jackson-annotations:2.15.2, com.fasterxml.jackson.core:jackson-core:2.15.2, - com.fasterxml.jackson.core:jackson-databind:2.15.2, com.yahoo.vespa:metrics:*, com.yahoo.vespa:predicate-search-core:*, - com.yahoo.vespa:searchcore:* + com.fasterxml.jackson.core:jackson-annotations, com.fasterxml.jackson.core:jackson-core, + com.fasterxml.jackson.core:jackson-databind, com.yahoo.vespa:metrics, com.yahoo.vespa:predicate-search-core, + com.yahoo.vespa:searchcore diff --git a/configserver/pom.xml b/configserver/pom.xml index 6a9b659e046..5b130969ae4 100644 --- a/configserver/pom.xml +++ b/configserver/pom.xml @@ -296,8 +296,8 @@ com.fasterxml.jackson.jaxrs.json;version="[2.12.6,3)" - com.fasterxml.jackson.core:jackson-annotations:2.15.2, com.fasterxml.jackson.core:jackson-core:2.15.2, - com.yahoo.vespa:airlift-zstd:* + com.fasterxml.jackson.core:jackson-annotations, com.fasterxml.jackson.core:jackson-core, + com.yahoo.vespa:airlift-zstd diff --git a/jdisc-cloud-aws/pom.xml b/jdisc-cloud-aws/pom.xml index a383edfbbc9..66b75bb6407 100644 --- a/jdisc-cloud-aws/pom.xml +++ b/jdisc-cloud-aws/pom.xml @@ -60,8 +60,8 @@ bundle-plugin true - com.fasterxml.jackson.core:jackson-annotations:2.15.2, com.fasterxml.jackson.core:jackson-core:2.15.2, - com.fasterxml.jackson.core:jackson-databind:2.15.2, commons-logging:commons-logging:1.2 + com.fasterxml.jackson.core:jackson-annotations, com.fasterxml.jackson.core:jackson-core, + com.fasterxml.jackson.core:jackson-databind, commons-logging:commons-logging diff --git a/zkfacade/pom.xml b/zkfacade/pom.xml index 365b3e1bea5..6ad514c5307 100644 --- a/zkfacade/pom.xml +++ b/zkfacade/pom.xml @@ -126,8 +126,8 @@ true com.sun.management - com.google.errorprone:error_prone_annotations:2.18.0, com.google.guava:failureaccess:1.0.1, - com.google.guava:guava:27.1-jre, com.google.j2objc:j2objc-annotations:1.1 + com.google.errorprone:error_prone_annotations, com.google.guava:failureaccess, + com.google.guava:guava, com.google.j2objc:j2objc-annotations -- cgit v1.2.3