blob: 42033f6ac731e96e0e75a5311c6756e2106c235c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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 Tony Vaagenes
* @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);
}
}
}
|