Skip to content

Commit

Permalink
Handle bundle folders in VirtualArtifactRepository.transferArtifact
Browse files Browse the repository at this point in the history
The implementation currently assumes all bundles are jars, but bundles
from the shared bundle pool may be unpacked as folders.

eclipse-pde#962
  • Loading branch information
merks committed Dec 14, 2023
1 parent 75fdc0d commit 77df22c
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.pde.internal.core.target;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -34,6 +35,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.metadata.expression.QueryResult;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
Expand Down Expand Up @@ -123,8 +125,25 @@ private void transferArtifact(Object artifactModel, OutputStream destination) th
if (location == null) {
throw new FileNotFoundException(bundleInfo.getSymbolicName());
}
try (InputStream is = location.toURL().openStream()) {
is.transferTo(destination);

File bundleLocation = new File(location);
if (bundleLocation.isFile()) {
try (InputStream is = new FileInputStream(bundleLocation)) {
is.transferTo(destination);
}
} else {
File zipFile = null;
try {
zipFile = File.createTempFile(bundleLocation.getName(), ".jar", null); //$NON-NLS-1$
FileUtils.zip(bundleLocation.listFiles(), null, zipFile,
FileUtils.createRootPathComputer(bundleLocation));
FileInputStream fis = new FileInputStream(zipFile);
FileUtils.copyStream(fis, true, destination, false);
} finally {
if (zipFile != null) {
zipFile.delete();
}
}
}
} else if (artifactModel instanceof IFeatureModel featureModel) {
String installLocation = featureModel.getInstallLocation();
Expand Down

0 comments on commit 77df22c

Please sign in to comment.