From 0f99be683a31f3a52dbd0886f858caf78ab246a4 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 | 6 + .../core/osgitools/OsgiBundleProject.java | 41 +-- .../tycho/core/osgitools/P2IUProject.java | 9 +- .../tycho/core/osgitools/P2SiteProject.java | 9 +- .../tycho/packaging/PackageFeatureMojo.java | 16 -- .../tycho/packaging/UpdateSiteAssembler.java | 264 ------------------ 6 files changed, 9 insertions(+), 336 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 0e0d7dbf48..a67ae03286 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -78,6 +78,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 @@ -98,6 +99,11 @@ 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. + + ## 4.0.3 ### new option to filter added repository-references when assembling a p2-repository 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 bc22535cf2..8dcdefe0c0 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.osgi.container.namespaces.EclipsePlatformNamespace; import org.eclipse.osgi.internal.framework.FilterImpl; import org.eclipse.tycho.ArtifactDescriptor; @@ -58,10 +57,8 @@ import org.eclipse.tycho.ResolvedArtifactKey; import org.eclipse.tycho.TargetEnvironment; 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.PluginDescription; import org.eclipse.tycho.core.TargetPlatformConfiguration; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils; @@ -73,9 +70,6 @@ import org.eclipse.tycho.core.osgitools.project.EclipsePluginProjectImpl; import org.eclipse.tycho.core.resolver.P2ResolverFactory; import org.eclipse.tycho.core.utils.TychoProjectUtils; -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; @@ -118,40 +112,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-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 c4c393f64c..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,13 +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. - */ - @Parameter(defaultValue = "false") - private boolean deployableFeature = false; - @Parameter(defaultValue = "${project.build.directory}/site") private File target; @@ -200,10 +193,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { } project.getArtifact().setFile(outputJar); - - if (deployableFeature) { - assembleDeployableFeature(); - } } } @@ -278,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; - } -}