package org.argeo.slc.repo.maven;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;
private String sourceWorkspace;
private String targetWorkspace;
+ private List<String> excludedBundles = new ArrayList<String>();
+ private Map<String, String> symbolicNamesMapping = new HashMap<String, String>();
+
private Session origSession;
private Session targetSession;
public void run() {
try {
- NodeIterator origArtifacts = listArtifactVersions(origSession);
-
// clear target
NodeIterator nit = targetSession.getNode(artifactBasePath)
.getNodes();
while (nit.hasNext()) {
Node node = nit.nextNode();
if (node.isNodeType(NodeType.NT_FOLDER)
- || node.isNodeType(NodeType.NT_UNSTRUCTURED))
+ || node.isNodeType(NodeType.NT_UNSTRUCTURED)) {
node.remove();
+ node.getSession().save();
+ if (log.isDebugEnabled())
+ log.debug("Cleared " + node);
+ }
}
- targetSession.save();
+ NodeIterator origArtifacts = listArtifactVersions(origSession);
// process
while (origArtifacts.hasNext()) {
Node origArtifactNode = origArtifacts.nextNode();
String origSymbolicName = origManifest.getMainAttributes().getValue(
Constants.BUNDLE_SYMBOLICNAME);
final String targetSymbolicName;
- if (origSymbolicName.startsWith(SPRING_SOURCE_PREFIX)
+ if (symbolicNamesMapping.containsKey(origSymbolicName)) {
+ targetSymbolicName = symbolicNamesMapping.get(origSymbolicName);
+ } else if (origSymbolicName.startsWith(SPRING_SOURCE_PREFIX)
&& !origSymbolicName.equals(SPRING_SOURCE_PREFIX + ".json")) {
targetSymbolicName = origSymbolicName
.substring(SPRING_SOURCE_PREFIX.length() + 1);
- if (log.isDebugEnabled())
- log.debug(Constants.BUNDLE_SYMBOLICNAME + " to "
- + targetSymbolicName + " \t\tfrom " + origSymbolicName);
+ } else {
+ targetSymbolicName = origSymbolicName;
+ }
+
+ if (!targetSymbolicName.equals(origSymbolicName)) {
targetManifest.getMainAttributes().putValue(
Constants.BUNDLE_SYMBOLICNAME, targetSymbolicName);
manifestModified = true;
- } else {
- targetSymbolicName = origSymbolicName;
+ if (log.isDebugEnabled())
+ log.debug(Constants.BUNDLE_SYMBOLICNAME + " to "
+ + targetSymbolicName + " \t\tfrom " + origSymbolicName);
}
+ // skip excluded bundles
+ if (excludedBundles.contains(targetSymbolicName))
+ return;
+
// check fragment host
if (origManifest.getMainAttributes().containsKey(
new Name(Constants.FRAGMENT_HOST))) {
String origFragmentHost = origManifest.getMainAttributes()
.getValue(Constants.FRAGMENT_HOST);
- if (origFragmentHost.startsWith(SPRING_SOURCE_PREFIX)
+ String targetFragmentHost;
+ if (symbolicNamesMapping.containsKey(origFragmentHost)) {
+ targetFragmentHost = symbolicNamesMapping.get(origFragmentHost);
+ } else if (origFragmentHost.startsWith(SPRING_SOURCE_PREFIX)
&& !origFragmentHost.equals(SPRING_SOURCE_PREFIX + ".json")) {
- String targetFragmentHost = origFragmentHost
+ targetFragmentHost = origFragmentHost
.substring(SPRING_SOURCE_PREFIX.length() + 1);
- if (log.isDebugEnabled())
- log.debug(Constants.FRAGMENT_HOST + " to "
- + targetFragmentHost + " from " + origFragmentHost);
+ } else {
+ targetFragmentHost = origFragmentHost;
+ }
+
+ if (!targetFragmentHost.equals(origFragmentHost)) {
targetManifest.getMainAttributes().putValue(
Constants.FRAGMENT_HOST, targetFragmentHost);
manifestModified = true;
+ if (log.isDebugEnabled())
+ log.debug(Constants.FRAGMENT_HOST + " to "
+ + targetFragmentHost + " from " + origFragmentHost);
}
}
if (systemPackages.contains(pkg)) {
if (!(sourceVersion.trim().equals("0") || sourceVersion
.trim().equals("0.0.0"))) {
- targetVersion = "0";
+ targetVersion = null;
importPackagesModified = true;
if (log.isDebugEnabled())
log.debug(origSymbolicName
+ sourceVersion);
}
}
- targetImportPackages.append(";version=\"")
- .append(targetVersion).append("\"");
+ if (targetVersion != null)
+ targetImportPackages.append(";version=\"")
+ .append(targetVersion).append("\"");
}
if (importPackage.hasProperty(SLC_OPTIONAL)) {
Boolean optional = importPackage.getProperty(SLC_OPTIONAL)
public void setTargetWorkspace(String targetWorkspace) {
this.targetWorkspace = targetWorkspace;
}
+
+ public void setExcludedBundles(List<String> excludedBundles) {
+ this.excludedBundles = excludedBundles;
+ }
+
+ public void setSymbolicNamesMapping(Map<String, String> symbolicNamesMapping) {
+ this.symbolicNamesMapping = symbolicNamesMapping;
+ }
+
}