1 package org
.argeo
.osgi
.boot
.a2
;
4 import java
.io
.IOException
;
5 import java
.nio
.file
.FileVisitResult
;
6 import java
.nio
.file
.Files
;
7 import java
.nio
.file
.Path
;
8 import java
.nio
.file
.Paths
;
9 import java
.nio
.file
.SimpleFileVisitor
;
10 import java
.nio
.file
.attribute
.BasicFileAttributes
;
12 import org
.argeo
.osgi
.boot
.OsgiBootUtils
;
13 import org
.osgi
.framework
.Version
;
15 public class FsM2Source
extends ProvisioningSource
{
16 private final Path base
;
18 public FsM2Source(Path base
) {
23 void load() throws IOException
{
24 Files
.walkFileTree(base
, new ArtifactFileVisitor());
27 class ArtifactFileVisitor
extends SimpleFileVisitor
<Path
> {
30 public FileVisitResult
visitFile(Path file
, BasicFileAttributes attrs
) throws IOException
{
31 // OsgiBootUtils.debug("Processing " + file);
32 if (file
.toString().endsWith(".jar")) {
35 version
= new Version(readVersionFromModule(file
));
36 } catch (Exception e
) {
38 return FileVisitResult
.CONTINUE
;
40 String moduleName
= readSymbolicNameFromModule(file
);
41 Path groupPath
= file
.getParent().getParent().getParent();
42 Path relGroupPath
= base
.relativize(groupPath
);
43 String contributionName
= relGroupPath
.toString().replace(File
.separatorChar
, '.');
44 A2Contribution contribution
= getOrAddContribution(contributionName
);
45 A2Component component
= contribution
.getOrAddComponent(moduleName
);
46 A2Module module
= component
.getOrAddModule(version
, file
);
47 if (OsgiBootUtils
.isDebug())
48 OsgiBootUtils
.debug("Registered " + module
);
50 return super.visitFile(file
, attrs
);
55 public static void main(String
[] args
) {
57 FsM2Source context
= new FsM2Source(Paths
.get("/home/mbaudier/.m2/repository"));
60 } catch (Exception e
) {