summaryrefslogtreecommitdiffstats
path: root/bundle-plugin
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@yahoo-inc.com>2017-07-24 13:20:29 +0200
committerBjørn Christian Seime <bjorncs@yahoo-inc.com>2017-07-24 13:20:29 +0200
commit60ff23428ee8d742330a413b1a890f9a751698e0 (patch)
treef23404a4fbfd827f38515f84808e0f57ba6efbb8 /bundle-plugin
parent3d4e9930aead5c46b00a94a6ba8d9d9f3372214e (diff)
Remove cyclic dependency between vespajlib and bundle-plugin
Diffstat (limited to 'bundle-plugin')
-rw-r--r--bundle-plugin/pom.xml9
-rw-r--r--bundle-plugin/src/main/java/com/yahoo/container/plugin/osgi/ProjectBundleClassPaths.java80
-rw-r--r--bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/GenerateBundleClassPathMappingsMojo.scala4
3 files changed, 88 insertions, 5 deletions
diff --git a/bundle-plugin/pom.xml b/bundle-plugin/pom.xml
index 60facd877ed..b881af3c551 100644
--- a/bundle-plugin/pom.xml
+++ b/bundle-plugin/pom.xml
@@ -73,9 +73,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>vespajlib</artifactId>
- <version>${project.version}</version>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/osgi/ProjectBundleClassPaths.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/osgi/ProjectBundleClassPaths.java
new file mode 100644
index 00000000000..545b76b32d7
--- /dev/null
+++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/osgi/ProjectBundleClassPaths.java
@@ -0,0 +1,80 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.container.plugin.osgi;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Represents the bundles in a maven project and the classpath elements
+ * corresponding to code that would end up in the bundle.
+ *
+ * @author tonytv
+ * @author bjorncs
+ */
+public class ProjectBundleClassPaths {
+ public static final String CLASSPATH_MAPPINGS_FILENAME = "bundle-plugin.bundle-classpath-mappings.json";
+
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @JsonProperty("mainBundle") public final BundleClasspathMapping mainBundle;
+ @JsonProperty("providedDependencies") public final List<BundleClasspathMapping> providedDependencies;
+
+ @JsonCreator
+ public ProjectBundleClassPaths(@JsonProperty("mainBundle") BundleClasspathMapping mainBundle,
+ @JsonProperty("providedDependencies") List<BundleClasspathMapping> providedDependencies) {
+ this.mainBundle = mainBundle;
+ this.providedDependencies = providedDependencies;
+ }
+
+ public static void save(Path path, ProjectBundleClassPaths mappings) throws IOException {
+ Files.createDirectories(path.getParent());
+ mapper.writeValue(path.toFile(), mappings);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ProjectBundleClassPaths that = (ProjectBundleClassPaths) o;
+ return Objects.equals(mainBundle, that.mainBundle) &&
+ Objects.equals(providedDependencies, that.providedDependencies);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mainBundle, providedDependencies);
+ }
+
+ public static class BundleClasspathMapping {
+ @JsonProperty("bundleSymbolicName") public final String bundleSymbolicName;
+ @JsonProperty("classPathElements") public final List<String> classPathElements;
+
+ @JsonCreator
+ public BundleClasspathMapping(@JsonProperty("bundleSymbolicName") String bundleSymbolicName,
+ @JsonProperty("classPathElements") List<String> classPathElements) {
+ this.bundleSymbolicName = bundleSymbolicName;
+ this.classPathElements = classPathElements;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ BundleClasspathMapping that = (BundleClasspathMapping) o;
+ return Objects.equals(bundleSymbolicName, that.bundleSymbolicName) &&
+ Objects.equals(classPathElements, that.classPathElements);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bundleSymbolicName, classPathElements);
+ }
+ }
+}
diff --git a/bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/GenerateBundleClassPathMappingsMojo.scala b/bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/GenerateBundleClassPathMappingsMojo.scala
index 4f463e7b494..2bd146a3920 100644
--- a/bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/GenerateBundleClassPathMappingsMojo.scala
+++ b/bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/GenerateBundleClassPathMappingsMojo.scala
@@ -6,8 +6,8 @@ import java.nio.file.Paths
import com.google.common.base.Preconditions
import com.yahoo.container.plugin.bundle.AnalyzeBundle
-import com.yahoo.osgi.maven.ProjectBundleClassPaths
-import com.yahoo.osgi.maven.ProjectBundleClassPaths.BundleClasspathMapping
+import com.yahoo.container.plugin.osgi.ProjectBundleClassPaths
+import com.yahoo.container.plugin.osgi.ProjectBundleClassPaths.BundleClasspathMapping
import org.apache.maven.artifact.Artifact
import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugins.annotations.{Mojo, Parameter, ResolutionScope}