From c5ff94bfdc281689a80164d030202d6d675b62f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 24 Nov 2023 17:57:18 +0100 Subject: [PATCH] Remove support for deployableFeature option The deployableFeature option will create "standard eclipse update site directory with feature content will be created under target folder" but we already removed site-packaging from tycho for a while, if one wants to archive similar a category.xml with eclipse-repository packaging gives much more control and power to the user. --- RELEASE_NOTES.md | 9 + .../tycho/core/ArtifactDependencyWalker.java | 6 - .../AbstractArtifactDependencyWalker.java | 15 - .../core/osgitools/OsgiBundleProject.java | 41 +-- .../tycho/core/osgitools/P2IUProject.java | 9 +- .../tycho/core/osgitools/P2SiteProject.java | 9 +- .../core/osgitools/TargetPlatformProject.java | 15 +- .../DeployableFeatureTest.java | 26 +- .../tycho/packaging/PackageFeatureMojo.java | 19 -- .../tycho/packaging/UpdateSiteAssembler.java | 264 ------------------ 10 files changed, 27 insertions(+), 386 deletions(-) delete mode 100644 tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteAssembler.java diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c3cd9feebc..55cd186ed1 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -128,6 +128,7 @@ If filtering provided artifacts is enabled, the repository references automatica using exclusion and inclusion patterns and therefore allows more fine-grained control which references are added. Additionally the automatically added references can be filter based on if they provide any of the filtered units or not. If `addOnlyProviding` is `true` repositories that don't provide any filtered unit are not added to the assembled repo. + ```xml org.eclipse.tycho @@ -148,6 +149,14 @@ If `addOnlyProviding` is `true` repositories that don't provide any filtered uni ``` +### Remove support for deployableFeature option + +The deployableFeature option will create "standard eclipse update site directory with feature content will +be created under target folder" but we already removed site-packaging from Tycho for a while, if one wants to +archive similar a category.xml with eclipse-repository packaging gives much more control and power to the user. +Alternativly new `mirror-target-platform` mojo can be used. + + ## 4.0.4 Backports: diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/ArtifactDependencyWalker.java b/tycho-core/src/main/java/org/eclipse/tycho/core/ArtifactDependencyWalker.java index 2c1d57f0c5..e460c03780 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/ArtifactDependencyWalker.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/ArtifactDependencyWalker.java @@ -15,8 +15,6 @@ import java.io.File; import org.eclipse.tycho.model.Feature; -import org.eclipse.tycho.model.ProductConfiguration; -import org.eclipse.tycho.model.UpdateSite; public interface ArtifactDependencyWalker { /** @@ -31,8 +29,4 @@ public interface ArtifactDependencyWalker { */ void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor); - void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor visitor); - - void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor); - } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractArtifactDependencyWalker.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractArtifactDependencyWalker.java index befe4e65d2..d8272da98d 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractArtifactDependencyWalker.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractArtifactDependencyWalker.java @@ -39,7 +39,6 @@ import org.eclipse.tycho.model.PluginRef; import org.eclipse.tycho.model.ProductConfiguration; import org.eclipse.tycho.model.ProductConfiguration.ProductType; -import org.eclipse.tycho.model.UpdateSite; public abstract class AbstractArtifactDependencyWalker implements ArtifactDependencyWalker { @@ -56,15 +55,6 @@ protected AbstractArtifactDependencyWalker(DependencyArtifacts artifacts, Target this.environments = environments; } - @Override - public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor visitor) { - WalkbackPath visited = new WalkbackPath(); - - for (FeatureRef ref : site.getFeatures()) { - traverseFeature(ref, visitor, visited); - } - } - @Override public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) { traverseFeature(location, feature, null, visitor, new WalkbackPath()); @@ -111,11 +101,6 @@ protected ArtifactDescriptor getArtifact(File location, String id) { return null; } - @Override - public void traverseProduct(ProductConfiguration product, ArtifactDependencyVisitor visitor) { - traverseProduct(product, visitor, new WalkbackPath()); - } - protected void traverseProduct(ProductConfiguration product, ArtifactDependencyVisitor visitor, WalkbackPath visited) { ProductType type = product.getType(); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java index 5c51557638..a7487f81ff 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java @@ -40,7 +40,6 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; -import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.metadata.IRequirement; import org.eclipse.osgi.container.namespaces.EclipsePlatformNamespace; import org.eclipse.osgi.internal.framework.FilterImpl; @@ -61,11 +60,9 @@ import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TargetPlatform; import org.eclipse.tycho.TychoConstants; -import org.eclipse.tycho.core.ArtifactDependencyVisitor; import org.eclipse.tycho.core.ArtifactDependencyWalker; import org.eclipse.tycho.core.BundleProject; import org.eclipse.tycho.core.DependencyResolverConfiguration; -import org.eclipse.tycho.core.PluginDescription; import org.eclipse.tycho.core.TargetPlatformConfiguration; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils; @@ -77,9 +74,6 @@ import org.eclipse.tycho.core.osgitools.project.EclipsePluginProjectImpl; import org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts; import org.eclipse.tycho.core.resolver.P2ResolverFactory; -import org.eclipse.tycho.model.Feature; -import org.eclipse.tycho.model.ProductConfiguration; -import org.eclipse.tycho.model.UpdateSite; import org.eclipse.tycho.model.classpath.JUnitBundle; import org.eclipse.tycho.model.classpath.JUnitClasspathContainerEntry; import org.eclipse.tycho.model.classpath.LibraryClasspathEntry; @@ -122,40 +116,7 @@ public class OsgiBundleProject extends AbstractTychoProject implements BundlePro @Override public ArtifactDependencyWalker getDependencyWalker(ReactorProject project) { - final DependencyArtifacts artifacts = getDependencyArtifacts(project); - - final List cp = getClasspath(project); - - return new ArtifactDependencyWalker() { - @Override - public void walk(ArtifactDependencyVisitor visitor) { - for (ClasspathEntry entry : cp) { - ArtifactDescriptor artifact = artifacts.getArtifact(entry.getArtifactKey()); - ArtifactKey key = artifact.getKey(); - File location = artifact.getLocation(true); - ReactorProject project = artifact.getMavenProject(); - String classifier = artifact.getClassifier(); - Collection installableUnits = artifact.getInstallableUnits(); - - PluginDescription plugin = new DefaultPluginDescription(key, location, project, classifier, null, - installableUnits); - - visitor.visitPlugin(plugin); - } - } - - @Override - public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) { - } - - @Override - public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor artifactDependencyVisitor) { - } - - @Override - public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) { - } - }; + throw new UnsupportedOperationException(); } @Override diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/P2IUProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/P2IUProject.java index f862cfe623..c3fb1e53de 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/P2IUProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/P2IUProject.java @@ -19,7 +19,6 @@ import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.TargetEnvironment; -import org.eclipse.tycho.core.ArtifactDependencyVisitor; import org.eclipse.tycho.core.ArtifactDependencyWalker; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.model.IU; @@ -28,13 +27,7 @@ public class P2IUProject extends AbstractArtifactBasedProject { @Override protected ArtifactDependencyWalker newDependencyWalker(ReactorProject project, TargetEnvironment environment) { - return new AbstractArtifactDependencyWalker(getDependencyArtifacts(project, environment), - getEnvironments(project, environment)) { - @Override - public void walk(ArtifactDependencyVisitor visitor) { - //Nothing to do - } - }; + throw new UnsupportedOperationException(); } @Override diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/P2SiteProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/P2SiteProject.java index 221d0aed48..bc6c61fd6d 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/P2SiteProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/P2SiteProject.java @@ -21,7 +21,6 @@ import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.TargetEnvironment; -import org.eclipse.tycho.core.ArtifactDependencyVisitor; import org.eclipse.tycho.core.ArtifactDependencyWalker; import org.eclipse.tycho.core.TychoProject; @@ -29,13 +28,7 @@ public class P2SiteProject extends AbstractArtifactBasedProject { @Override protected ArtifactDependencyWalker newDependencyWalker(ReactorProject project, TargetEnvironment environment) { - return new AbstractArtifactDependencyWalker(getDependencyArtifacts(project, environment), - getEnvironments(project, environment)) { - @Override - public void walk(ArtifactDependencyVisitor visitor) { - //Nothing to do - } - }; + throw new UnsupportedOperationException(); } @Override diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java index fca2c72aab..1dc6feae4c 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java @@ -34,8 +34,6 @@ import org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts; import org.eclipse.tycho.core.resolver.target.ArtifactTypeHelper; import org.eclipse.tycho.model.Feature; -import org.eclipse.tycho.model.ProductConfiguration; -import org.eclipse.tycho.model.UpdateSite; import org.eclipse.tycho.targetplatform.P2TargetPlatform; @Component(role = TychoProject.class, hint = PackagingType.TYPE_ECLIPSE_TARGET_DEFINITION) @@ -50,16 +48,6 @@ public void walk(ArtifactDependencyVisitor visitor) { } - @Override - public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor visitor) { - - } - - @Override - public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) { - - } - @Override public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) { @@ -78,8 +66,7 @@ public DependencyArtifacts getDependencyArtifacts(ReactorProject reactorProject) DefaultDependencyArtifacts artifacts = new DefaultDependencyArtifacts(reactorProject); MavenSession mavenSession = getMavenSession(reactorProject); MavenProject mavenProject = getMavenProject(reactorProject); - TargetPlatform targetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession, - mavenProject); + TargetPlatform targetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession, mavenProject); if (targetPlatform instanceof P2TargetPlatform p2) { Set installableUnits = p2.getInstallableUnits(); for (IInstallableUnit iu : installableUnits) { diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/TYCHO321deployableFeature/DeployableFeatureTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/TYCHO321deployableFeature/DeployableFeatureTest.java index 7f567204e6..2d634f968d 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/TYCHO321deployableFeature/DeployableFeatureTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/TYCHO321deployableFeature/DeployableFeatureTest.java @@ -17,24 +17,26 @@ import org.apache.maven.it.Verifier; import org.eclipse.tycho.test.AbstractTychoIntegrationTest; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; +@Ignore("deployable feature no longer supported") public class DeployableFeatureTest extends AbstractTychoIntegrationTest { - @Test - public void testDeployableFeature() throws Exception { - Verifier v01 = getVerifier("TYCHO321deployableFeature"); - v01.executeGoal("install"); - v01.verifyErrorFreeLog(); + @Test + public void testDeployableFeature() throws Exception { + Verifier v01 = getVerifier("TYCHO321deployableFeature"); + v01.executeGoal("install"); + v01.verifyErrorFreeLog(); - File site = new File(v01.getBasedir(), "target/site"); - Assert.assertTrue(site.isDirectory()); + File site = new File(v01.getBasedir(), "target/site"); + Assert.assertTrue(site.isDirectory()); - Assert.assertTrue(new File(site, "features").list().length > 0); - Assert.assertTrue(new File(site, "plugins").list().length > 0); + Assert.assertTrue(new File(site, "features").list().length > 0); + Assert.assertTrue(new File(site, "plugins").list().length > 0); - Assert.assertTrue(new File(site, "artifacts.jar").isFile()); - Assert.assertTrue(new File(site, "content.jar").isFile()); - } + Assert.assertTrue(new File(site, "artifacts.jar").isFile()); + Assert.assertTrue(new File(site, "content.jar").isFile()); + } } diff --git a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackageFeatureMojo.java b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackageFeatureMojo.java index 74319d9c3d..8af5d29cc3 100644 --- a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackageFeatureMojo.java +++ b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackageFeatureMojo.java @@ -102,16 +102,6 @@ public class PackageFeatureMojo extends AbstractTychoPackagingMojo { @Parameter(property = "project.build.finalName", alias = "jarName", required = true) private String finalName; - /** - * If set to true, standard eclipse update site directory with - * feature content will be created under target folder. - * - * @deprecated use the new mirror-target-platform instead. - */ - @Parameter(defaultValue = "false") - @Deprecated - private boolean deployableFeature = false; - @Parameter(defaultValue = "${project.build.directory}/site") private File target; @@ -203,10 +193,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { } project.getArtifact().setFile(outputJar); - - if (deployableFeature) { - assembleDeployableFeature(); - } } } @@ -281,11 +267,6 @@ private FileSet getManuallyIncludedFiles(BuildProperties buildProperties) { return getFileSet(basedir, buildProperties.getBinIncludes(), binExcludes); } - private void assembleDeployableFeature() throws MojoExecutionException { - UpdateSiteAssembler assembler = new UpdateSiteAssembler(plexus, target); - getTychoProjectFacet().getDependencyWalker(DefaultReactorProject.adapt(project)).walk(assembler); - } - private void expandVersionQualifiers(Feature feature) throws MojoFailureException { ReactorProject reactorProject = DefaultReactorProject.adapt(project); feature.setVersion(reactorProject.getExpandedVersion()); diff --git a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteAssembler.java b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteAssembler.java deleted file mode 100644 index bd22800ab7..0000000000 --- a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteAssembler.java +++ /dev/null @@ -1,264 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2022 Sonatype Inc. and others. - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.tycho.packaging; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.util.Map; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.archiver.ArchiverException; -import org.codehaus.plexus.archiver.zip.ZipArchiver; -import org.codehaus.plexus.archiver.zip.ZipUnArchiver; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.util.FileUtils; -import org.eclipse.tycho.FileLockService; -import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.core.ArtifactDependencyVisitor; -import org.eclipse.tycho.core.FeatureDescription; -import org.eclipse.tycho.core.PluginDescription; -import org.eclipse.tycho.model.PluginRef; - -/** - * Assembles standard eclipse update site directory structure on local filesystem. - * - * @author igor - */ -public class UpdateSiteAssembler extends ArtifactDependencyVisitor { - - public static final String PLUGINS_DIR = "plugins/"; - - public static final String FEATURES_DIR = "features/"; - - private final PlexusContainer session; - - private final File target; - - private Map archives; - - /** - * If true, generated update site will include plugins folders for plugins with - * PluginRef.unpack. If false, will include plugin jars regardless of PluginRef.unpack. - */ - private boolean unpackPlugins; - - /** - * If true, generated update site will include feature directories. If false, generated update - * site will include feature jars. - */ - private boolean unpackFeatures; - - public UpdateSiteAssembler(PlexusContainer session, File target) { - this.session = session; - this.target = target; - } - - @Override - public boolean visitFeature(FeatureDescription feature) { - File location = feature.getLocation(true); - String artifactId = feature.getKey().getId(); - String version = feature.getKey().getVersion(); - - ReactorProject featureProject = feature.getMavenProject(); - - if (featureProject != null) { - version = featureProject.getExpandedVersion(); - - location = featureProject.getArtifact(feature.getClassifier()); - - if (location == null) { - throw new IllegalStateException(featureProject.getId() - + " does not provide an artifact with classifier '" + feature.getClassifier() + "'"); - } - - if (location.isDirectory()) { - throw new IllegalStateException("Should at least run ``package'' phase"); - } - } - - if (unpackFeatures) { - File outputJar = getOutputFile(FEATURES_DIR, artifactId, version, null); - if (location.isDirectory()) { - copyDir(location, outputJar); - } else { - unpackJar(location, outputJar); - } - } else { - File outputJar = getOutputFile(FEATURES_DIR, artifactId, version, ".jar"); - if (location.isDirectory()) { - packDir(location, outputJar); - } else { - copyFile(location, outputJar); - } - } - - return true; // keep visiting - } - - private File getOutputFile(String prefix, String id, String version, String extension) { - StringBuilder sb = new StringBuilder(prefix); - sb.append(id); - sb.append('_'); - sb.append(version); - if (extension != null) { - sb.append(extension); - } - - return new File(target, sb.toString()); - } - - @Override - public void visitPlugin(PluginDescription plugin) { - String bundleId = plugin.getKey().getId(); - String version = plugin.getKey().getVersion(); - - String relPath = PLUGINS_DIR + bundleId + "_" + version + ".jar"; - if (archives != null && archives.containsKey(relPath)) { - copyUrl(archives.get(relPath), new File(target, relPath)); - return; - } - - if (plugin.getLocation(true) == null) { - throw new IllegalStateException("Unresolved bundle reference " + bundleId + "_" + version); - } - - ReactorProject bundleProject = plugin.getMavenProject(); - File location = null; - if (bundleProject != null) { - location = bundleProject.getArtifact(plugin.getClassifier()); - if (location == null) { - throw new IllegalStateException(bundleProject.getId() - + " does not provide an artifact with classifier '" + plugin.getClassifier() + "'"); - } - if (location.isDirectory()) { - throw new RuntimeException("Bundle project " + bundleProject.getId() - + " artifact is a directory. The build should at least run ``package'' phase."); - } - version = bundleProject.getExpandedVersion(); - } else { - location = plugin.getLocation(true); - } - - if (unpackPlugins && isDirectoryShape(plugin, location)) { - // need a directory - File outputJar = getOutputFile(PLUGINS_DIR, bundleId, version, null); - - if (location.isDirectory()) { - copyDir(location, outputJar); - } else { - unpackJar(location, outputJar); - } - } else { - // need a jar - File outputJar = getOutputFile(PLUGINS_DIR, bundleId, version, ".jar"); - - if (location.isDirectory()) { - packDir(location, outputJar); - } else { - copyFile(location, outputJar); - } - } - } - - protected boolean isDirectoryShape(PluginDescription plugin, File location) { - PluginRef pluginRef = plugin.getPluginRef(); - return ((pluginRef != null && pluginRef.isUnpack()) || location.isDirectory()); - } - - private void unpackJar(File location, File outputJar) { - ZipUnArchiver unzip; - FileLockService fileLockService; - try { - unzip = session.lookup(ZipUnArchiver.class, "zip"); - fileLockService = (FileLockService) session.lookup(FileLockService.class.getName()); - } catch (ComponentLookupException e) { - throw new RuntimeException("Could not lookup required component", e); - } - - outputJar.mkdirs(); - - if (!outputJar.isDirectory()) { - throw new RuntimeException("Could not create output directory " + outputJar.getAbsolutePath()); - } - - unzip.setSourceFile(location); - unzip.setDestDirectory(outputJar); - try (var locked = fileLockService.lock(location)) { - unzip.extract(); - } catch (ArchiverException | IOException e) { - throw new RuntimeException("Could not unpack jar", e); - } - } - - private void copyDir(File location, File outputJar) { - try { - FileUtils.copyDirectoryStructure(location, outputJar); - } catch (IOException e) { - throw new RuntimeException("Could not copy directory", e); - } - } - - private void copyUrl(String source, File destination) { - try { - URL url = new URL(source); - try (InputStream is = url.openStream(); - OutputStream os = new BufferedOutputStream(new FileOutputStream(destination))) { - is.transferTo(os); - } - } catch (IOException e) { - throw new RuntimeException("Could not copy URL contents", e); - } - } - - private void copyFile(File source, File destination) { - try { - FileUtils.copyFile(source, destination); - } catch (IOException e) { - throw new RuntimeException("Could not copy file", e); - } - } - - private void packDir(File sourceDir, File targetZip) { - ZipArchiver archiver; - try { - archiver = session.lookup(ZipArchiver.class, "zip"); - } catch (ComponentLookupException e) { - throw new RuntimeException("Unable to resolve ZipArchiver", e); - } - - archiver.setDestFile(targetZip); - try { - archiver.addDirectory(sourceDir); - archiver.createArchive(); - } catch (IOException | ArchiverException e) { - throw new RuntimeException("Error packing zip", e); - } - } - - public void setArchives(Map archives) { - this.archives = archives; - } - - public void setUnpackPlugins(boolean unpack) { - this.unpackPlugins = unpack; - } - - public void setUnpackFeatures(boolean unpack) { - this.unpackFeatures = unpack; - } -}