+
+ // target coordinates
+ final String targetGroupId;
+ if (origArtifact.getGroupId().startsWith("org.eclipse"))
+ targetGroupId = "org.argeo.tp.eclipse";
+ else
+ targetGroupId = "org.argeo.tp";
+
+ String targetArtifactId = targetSymbolicName.split(";")[0];
+ Artifact targetArtifact = new DefaultArtifact(targetGroupId,
+ targetArtifactId, "jar", origArtifact.getVersion());
+ String targetParentPath = MavenConventionsUtils.artifactParentPath(
+ artifactBasePath, targetArtifact);
+ String targetFileName = MavenConventionsUtils
+ .artifactFileName(targetArtifact);
+ String targetJarPath = targetParentPath + '/' + targetFileName;
+
+ // copy
+ Node targetParentNode = JcrUtils.mkfolders(targetSession,
+ targetParentPath);
+ targetSession.save();
+ if (manifestModified) {
+ Binary origBinary = origJarNode.getNode(Node.JCR_CONTENT)
+ .getProperty(Property.JCR_DATA).getBinary();
+ byte[] targetJarBytes = RepoUtils.modifyManifest(
+ origBinary.getStream(), targetManifest);
+ JcrUtils.copyBytesAsFile(targetParentNode, targetFileName,
+ targetJarBytes);
+ JcrUtils.closeQuietly(origBinary);
+ } else {// just copy
+ targetSession.getWorkspace().copy(sourceWorkspace,
+ origJarNode.getPath(), targetJarPath);
+ }
+ targetSession.save();
+
+ // reindex
+ Node targetJarNode = targetSession.getNode(targetJarPath);
+ artifactIndexer.index(targetJarNode);
+ jarFileIndexer.index(targetJarNode);
+
+ targetSession.save();