From 4ac921646d3a547aa56558b30c57652e9074a41c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Thu, 11 Jul 2024 09:02:04 +0200 Subject: [PATCH] Add mavenproject artifacts as implicit repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christoph Läubrich --- org.eclipse.m2e.bnd.ui/META-INF/MANIFEST.MF | 4 +++- .../eclipse/m2e/bnd/ui/BndPluginAdapter.java | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/org.eclipse.m2e.bnd.ui/META-INF/MANIFEST.MF b/org.eclipse.m2e.bnd.ui/META-INF/MANIFEST.MF index 70bd69be7a..69c958f9ac 100644 --- a/org.eclipse.m2e.bnd.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.bnd.ui/META-INF/MANIFEST.MF @@ -5,7 +5,9 @@ Bundle-SymbolicName: org.eclipse.m2e.bnd.ui Bundle-Version: 1.0.0.qualifier Import-Package: aQute.bnd.build;version="[4.5.0,5.0.0)", aQute.bnd.maven.lib.configuration;version="1.2.0", - aQute.bnd.osgi;version="[7.0.0,8.0.0)" + aQute.bnd.maven.lib.resolve;version="[1.3.0,2.0.0)", + aQute.bnd.osgi;version="[7.0.0,8.0.0)", + aQute.bnd.repository.fileset;version="[1.1.0,2.0.0)" Require-Bundle: org.eclipse.equinox.common, org.eclipse.core.resources, org.eclipse.m2e.core, diff --git a/org.eclipse.m2e.bnd.ui/src/org/eclipse/m2e/bnd/ui/BndPluginAdapter.java b/org.eclipse.m2e.bnd.ui/src/org/eclipse/m2e/bnd/ui/BndPluginAdapter.java index bad17e7aff..3dee965432 100644 --- a/org.eclipse.m2e.bnd.ui/src/org/eclipse/m2e/bnd/ui/BndPluginAdapter.java +++ b/org.eclipse.m2e.bnd.ui/src/org/eclipse/m2e/bnd/ui/BndPluginAdapter.java @@ -12,10 +12,14 @@ *******************************************************************************/ package org.eclipse.m2e.bnd.ui; +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Properties; +import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.AdapterTypes; @@ -29,6 +33,7 @@ import aQute.bnd.build.Project; import aQute.bnd.build.Workspace; import aQute.bnd.maven.lib.configuration.BeanProperties; +import aQute.bnd.maven.lib.resolve.ImplicitFileSetRepository; import aQute.bnd.osgi.Processor; /** @@ -60,12 +65,21 @@ public T getAdapter(Object adaptableObject, Class adapterType) { } } Processor processor = new Processor(processorProperties, false); - + Collection list = new ArrayList(); + if (mp != null) { + for (Artifact artifact : mp.getArtifacts()) { + list.add(artifact.getFile()); + } + } + ImplicitFileSetRepository repository = new ImplicitFileSetRepository("Project Artifacts", list); // TODO propertiesFile = new BndConfiguration(project, // mojoExecution).loadProperties(builder); + // TODO + // aQute.bnd.maven.lib.resolve.BndrunContainer.getFileSetRepository(MavenProject) Workspace standaloneWorkspace = Workspace.createStandaloneWorkspace(processor, mavenProject.getPomFile().getParentFile().toURI()); + standaloneWorkspace.addBasicPlugin(repository); if (mp == null) { standaloneWorkspace.set("workspaceName", mavenProject.getArtifactKey().toPortableString()); } else { @@ -76,6 +90,7 @@ public T getAdapter(Object adaptableObject, Class adapterType) { standaloneWorkspace.set("workspaceDescription", description); } } + standaloneWorkspace.refresh(); Project bndProject = new Project(standaloneWorkspace, null, null); bndProject.setBase(null); return adapterType.cast(bndProject);