Skip to content

Commit

Permalink
Add mavenproject artifacts as implicit repository
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Läubrich <[email protected]>
  • Loading branch information
laeubi committed Jul 11, 2024
1 parent a1e492d commit 4ac9216
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion org.eclipse.m2e.bnd.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -60,12 +65,21 @@ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
}
}
Processor processor = new Processor(processorProperties, false);

Collection<File> list = new ArrayList<File>();
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 {
Expand All @@ -76,6 +90,7 @@ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
standaloneWorkspace.set("workspaceDescription", description);
}
}
standaloneWorkspace.refresh();
Project bndProject = new Project(standaloneWorkspace, null, null);
bndProject.setBase(null);
return adapterType.cast(bndProject);
Expand Down

0 comments on commit 4ac9216

Please sign in to comment.